How can I relate two tables in Leaflet - database
I am mapping bibliographic information of Mars and would like to relate two tables(key column: feature_ID) in Leaflet. My objective is to show pop up of the csv table 2 info window when clicking a feature in the geojson table 1. However, I have no idea how to do this. Does anyone have any idea where should I refer to?
$.getJSON("mapdata.geojson",function(hoodData){
L.geoJson( hoodData , {
style: function(feature){
var fillColor,
number_of_papers = feature.properties.number_of_papers;
if ( number_of_papers > 80 ) fillColor = "#006837";
else if ( number_of_papers > 40 ) fillColor = "#31a354";
else if ( number_of_papers > 20 ) fillColor = "#78c679";
else if ( number_of_papers > 10 ) fillColor = "#c2e699";
else if ( number_of_papers > 0 ) fillColor = "#ffffcc";
else fillColor = "#f7f7f7"; // no data
return { color: "#999", weight: 1, fillColor: fillColor, fillOpacity: .6 };
},
onEachFeature: function( feature, layer ){
layer.bindPopup( "<strong>" + feature.properties.Clean_Feature_Name + "</strong><br/>" + "Number of Papers: " + feature.properties.number_of_papers + "<br/>" + "Number of Citing Papers: " + feature.properties.number_of_citing_papers + "<br/>" + "Number of self citations: " + feature.properties.number_of_self_citations + "<br/>" + "Total number of citations: " + feature.properties.total_number_of_citations + "<br/>" + "Number of referred citations: " + feature.properties.total_number_of_refereed_citations )
}
} ).addTo(map);
Map I created so far: https://shinjjo.github.io/heatmap.html
Data: https://github.com/shinjjo/shinjjo.github.io
The Table 1 has geographic information (geojson)
The Table 2 has publication information (csv)
Table 2
Related
Build a dynamic string to filter a rest call
I'm trying to build a dynamic string but I'm facing a problem, so I kindly ask help to the community. A have a string to build a rest call filter, but I'm lost with the and's This query only works if only one filter condition is provided, but I have to provide as AND var query; var queryDefault = "IsLastForLevelAndParticipant eq 1"; this.state.participantFirstName ? query += "substringof('" + this.state.participantFirstName + "',Participant/FirstName)" : queryDefault this.state.participantLastName ? query += "substringof('" + this.state.participantLastName + "',Participant/LastName)" : queryDefault So let´s see. If I start building this and only one filter is provided I'll have a plus and var query; var queryDefault = "IsLastForLevelAndParticipant eq 1"; this.state.participantFirstName ? query += "substringof('" + this.state.participantFirstName + "',Participant/FirstName) and " : queryDefault this.state.participantLastName ? query += "substringof('" + this.state.participantLastName + "',Participant/LastName)" : queryDefault query += " and " + queryDefault I have 12 filters and I must know how many have values in order to provide the and clause This is my state //Filters Certificates startEmission: string; endEmission: string; startValidity: string; endValidity: string; participantFirstName: string; participantLastName: string; paticipantCertNumber: string; selectYesNo: string; selectLevel: string; Any help is a bonus.
Add all possible filters to an array, filter the falsy values and finally join all items with " and ". var query = [ queryDefault, this.state.participantFirstName && "substringof('" + this.state.participantFirstName + "',Participant/FirstName)" this.state.participantLastName && "substringof('" + this.state.participantLastName + "',Participant/LastName)" ] .filter(item => !!item) .join(" and "); BTW. are you using OData? the structure of the filter looks familiar. If you do, I would recommend you to use this library: https://github.com/techniq/odata-query#readme
Since I'm using datetime also, here it is the final solution var queryDefault = "IsLastForLevelAndParticipant eq 1"; var query = [ queryDefault, this.state.startEmission && "(Date1 ge datetime'" + moment.utc(this.state.startEmission).toISOString() + "') and (Date1 le datetime'" + moment.utc(this.state.endEmission).toISOString() + "')", this.state.startValidity && "(Validto ge datetime'" + moment.utc(this.state.startValidity).toISOString() + "') and (Validto le datetime'" + moment.utc(this.state.endValidity).toISOString() + "')", this.state.participantFirstName && "(substringof('" + this.state.participantFirstName + "',Participant/FirstName))", this.state.participantLastName && "(substringof('" + this.state.participantLastName + "',Participant/LastName))", this.state.selectYesNo && "IsPrinted eq " + this.state.selectYesNo, this.state.selectLevel && "Level/Title eq '" + this.state.selectLevel + "'" ] .filter(filter => !! filter) .join(" and "); var q = JSON.stringify(query).substring(1).slice(0, -1); console.log(JSON.stringify(query));
Getting Syntax error in this python code, how to eleminate?
////// section begins /* use this afl when buy is different from cover and sell is different from short / RequestTimedRefresh( 1, onlyvisible = False ) ; _SECTION_BEGIN( "Algoji.com intraday.afl" ); intra = ParamToggle( "Activate Intraday Mode", "NO|YES" ); per10 = Param( "Trade Entry From(HHMM)", 920, 900, 2300, 1 ); per11 = Param( "Trade Entry Upto(HHMM)", 1445, 900, 2300, 1 ); per12 = Param( "Trade Exit(HHMM)", 1515, 900, 2300, 100 ); pop= ParamToggle( "Percentage or Points", "Points|Percentage"); slp = Param( "StopLoss", 0, 0, 1000, 0.1 ); tsl= Param("Trail Stop", 0, 0, 1000, 0.1); tgtp = Param( "Target", 0, 0, 1000, 0.1 ); Col = ParamColor( "Color of Modified Signals", colorYellow ); delay= ParamToggle("Trade Intrabar?", "YES|Candle Completion"); dlong= ParamToggle("Disable Long?", "NO|YES"); dshort= ParamToggle("Disable Short?", "NO|YES"); if(dlong){Buy=Sell=0;} if(dshort){Short=Cover=0;} dd= DaysSince1900(); d=prof= 0; if(delay) {Buy=Ref(Buy,-1); Sell=Ref(Sell,-1); Short= Ref(Short,-1); Cover= Ref(Cover,-1);} qt= Param("Trade Quantity", 0, 0, 1000000) ; exposure= Param("Exposure", 0, 0, 1000000) ; if(exposure>0) qt= round(exposure/ValueWhen(Day()!=Ref(Day(),-1), C)); maxl= Param("Qty using SL (MaxLoss)",0,0,100000 ); if(maxl>0 AND !pop) qt= round(maxl/slp); if(maxl>0 AND pop) { basicprice= LastValue(ValueWhen(Day()!=Ref(Day(),-1), C)); sl= slpbasicprice/100; qt= round(maxl/sl); } intraex = intra AND (TimeNum() > per12 * 100); intraen = !intra OR ( TimeNum() <= per11 * 100 AND TimeNum() >= per10 * 100 ); Buy1 = Buy; Sell1 = Sell; Short1 = Short; Cover1 = Cover; Buy=Sell=Short=Cover=0; bflag = sflag = sp=bp = 0; slarr = tgtarr = qtarr= Null; for ( i = 10; i < BarCount; i++ ) { if ( ( Cover1[i] OR intraex[i]OR( H[i] > slarr[i-1] AND (sl>0 OR tsl>0) ) OR ( L[i] < tgtarr[i-1] AND tgt > 0 ) ) AND sflag ) { Cover[i] = 1; CoverPrice[i]= C[i]; sflag = 0; d= dd[i]; prof= sp-C[i]; } if ( ( Sell1[i] OR intraex[i] OR( L[i] < slarr[i-1] AND (sl>0 OR tsl>0) ) OR ( H[i] > tgtarr[i-1] AND tgt > 0 ) ) AND bflag ) { Sell[i] = 1; SellPrice[i]= C[i]; bflag = 0; d= dd[i]; prof= C[i]- bp; } if ( Buy1[i] AND intraen[i] AND bflag == 0 ) { Buy[i] = 1; bflag = 1; bp= C[i]; sl=slp; tgt= tgtp; if(pop) {sl= slpbp/100; tgt= tgtpbp/100;} if ( slp ) slarr[i] = bp-sl; if ( tgtp ) tgtarr[i] = bp+tgt; } if ( bflag AND Buy[i]==0 ) { slarr[i] = slarr[i-1]; tgtarr[i] = tgtarr[i-1]; if(tsl>0 AND pop) slarr[i] = Max(slarr[i-1], H[i](1-tsl/100)); if(tsl>0 AND !pop) slarr[i] = Max(slarr[i-1], H[i]-tsl); } if ( Short1[i] AND intraen[i] AND sflag == 0 ) { Short[i] = 1; sflag = 1; Sp= C[i]; sl= slp; tgt= tgtp; if(pop) {sl= slpSp/100; tgt= tgtpSp/100;} if ( slp ) slarr[i] = sp + sl; if ( tgtp ) tgtarr[i] = sp - tgt; } if ( sflag AND Short[i] == 0 ) { slarr[i] = slarr[i-1]; tgtarr[i] = tgtarr[i-1]; if(tsl>0 AND pop) slarr[i] = Min(slarr[i-1], L[i](1+tsl/100)); if(tsl>0 AND !pop) slarr[i] = Min(slarr[i-1], L[i]+tsl); } } Plot( slarr, "SL", Col, styleThick ); Plot( tgtarr, "TGT", Col, styleThick ); PlotShapes( IIf( Buy, shapeUpArrow, shapeNone ), Col, 0, H, Offset = 15 ); PlotShapes( IIf( Short, shapeDownArrow, shapeNone ), Col, 0, L, Offset = 15 ); PlotShapes( IIf( Cover, shapeStar, shapeNone ), Col, 0, H, Offset = -25 ); PlotShapes( IIf( Sell, shapeStar, shapeNone ), Col, 0, L, Offset = -25 ); sig = IIf( BarsSince( Buy ) < BarsSince( Short ), 1, 0 ); messageboard = ParamToggle( "Message Board", "Show|Hide", 1 ); if ( messageboard == 1 ) { GfxSelectFont( "Tahoma", 13, 100 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); GfxSelectSolidBrush( colorDarkTeal ); // this is the box background color pxHeight = Status( "pxchartheight" ) ; xx = Status( "pxchartwidth" ); Left = 1100; width = 310; x = 5; x2 = 310; y = pxHeight; GfxSelectPen( colorGreen, 1 ); // broader color GfxRoundRect( x, y - 160, x2, y , 7, 7 ) ; GfxTextOut( ""+WriteIf(intra, "Intraday Mode Activated", "Intraday Mode Not Activated" ), 13, y-160 ); GfxTextOut( ( "Current Qty "+qt ), 13, y-140 ); GfxTextOut( ( "Last" + " Signal came " + ( BarsSince( Buy OR Short ) ) * Interval() / 60 + " mins ago" ), 13, y - 120 ) ; // The text format location GfxTextOut( ( "" + WriteIf( sig == 1, "BUY # " + ValueWhen(Buy,C) , "SHORT # " + ValueWhen(Short,C) ) ), 13, y - 100 ); GfxTextOut( "Stop Loss : " + WriteIf(slp==0, "Not Activated", ""+slarr), 13, y - 80 ); GfxTextOut( "Target : " + WriteIf(tgtp==0, "Not Activated", ""+tgtarr), 13, y - 60 ); GfxTextOut( ( "Current P/L : " + WriteVal( IIf( sig == 1, (C-ValueWhen(Buy,C))*qt, (ValueWhen(Short,C)-C)*qt ), 2.2 ) ), 13, y-40 ); // GfxTextOut( ( "jhjh " ), 13, y-20 ); } //section begins for auto trade instr= ParamList("Instrument Name","EQ|FUTIDX|FUTSTK|OPTIDX|OPTSTK|FUTCOM"); stag= ParamStr("Strategy Tag", "STG1"); qty= NumToStr(qt[BarCount-1], 1.0, False) ; bp= sp= NumToStr(Close[BarCount-1],1.2, False); if(dlong){Buy=Sell=0;} if(dshort){Short=Cover=0;} if(delay) {Buy=Ref(Buy,-1); Sell=Ref(Sell,-1); Short= Ref(Short,-1); Cover= Ref(Cover,-1);} global algoji; algoji = Name() + NumToStr( Interval() / 60, 1.0, False ) ; procedure aStaticVarSet( SName, Svalue ) { global algoji; StaticVarSet( Sname + algoji, Svalue ); } function aStaticVarGet( SName ) { global algoji; Var = StaticVarGet( Sname + algoji ); if ( IsNull( Var = StaticVarGet( Sname + algoji ) ) ) Var = 0; return Var; } sym = Name(); //_TRACE("t"+t); Checkdt=Nz(aStaticVarGet("lastdt")); dt = LastValue( DateTime() ); Checkdtss=Nz(aStaticVarGet("lastdtss")); dtss = LastValue( DateTime() ); Checkdtc=Nz(aStaticVarGet("lastdtc")); dtc = LastValue( DateTime() ); Checkdts=Nz(aStaticVarGet("lastdts")); dts = LastValue( DateTime() ); RTBuy = LastValue( Buy) AND Checkdt != dt; RTShort = LastValue( Short) AND Checkdtss != dtss; RTCover = LastValue( Cover) AND Checkdtc != dtc; RTSell = LastValue( Sell) AND Checkdts != dts; if ( RTCover ) { aStaticVarSet("lastdtc",dtc ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",SX,"+sym+",,," +bp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SX",sym,"M","",bp,qty,instr,stag); } if ( RTSell ) { aStaticVarSet("lastdts",dts ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",LX,"+sym+",,," +sp +","+qty+",,,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LX",sym,"M","",sp,qty,instr,stag); } if ( RTBuy ) { aStaticVarSet("lastdt",dt ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); _TRACE( "#"+Nz(StaticVarGet("counter"))+",LE,"+sym+",,," +bp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LE",sym,"M","",bp,qty,instr,stag); } if ( RTShort ) { aStaticVarSet("lastdtss",dtss ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); sp= NumToStr(Close[BarCount-1],1.2, False); _TRACE( "#"+Nz(StaticVarGet("counter"))+",SE,"+sym+",,," +sp +","+qty+","+instr+",,"); Algoji_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SE",sym,"M","",bp,qty,instr,stag); } Button = ParamToggle( "Enable Button Trading", "YES|NO" ); expiry= ParamStr("Expiry",""); strike= ParamStr("Strike",""); type= ParamStr("Option Type", ""); sym = Name()+ "|"+expiry+ "|" +strike+ "|" +type; function GetSecondNum() { Time = Now( 4 ); Seconds = int( Time % 100 ); Minutes = int( Time / 100 % 100 ); Hours = int( Time / 10000 % 100 ); SecondNum = int( Hours * 60 * 60 + Minutes * 60 + Seconds ); return SecondNum; } function PopupWindowEx( popupID, bodytext, captiontext, timeout, left, top ) { displayText = bodytext + captiontext; if ( ( StaticVarGetText( "prevPopup" + popupID ) != displayText) OR ( StaticVarGet( "prevPopupTime" + popupID ) < GetSecondNum() ) ) { StaticVarSetText( "prevPopup" + popupID, displayText); StaticVarSet( "prevPopupTime" + popupID, GetSecondNum() + timeout ); PopupWindow( bodytext, Captiontext + popupID, timeout, Left, top ); } } x1= Status( "pxchartleft" )+10; y1= Status( "pxcharttop" )+20; if ( Button == 0 ) { click = GetCursorMouseButtons() == 9; Px = GetCursorXPosition( 1 ); Py = GetCursorYPosition( 1 ); x2 = x1 + 60; y2 = y1 + 60; GfxSelectSolidBrush( ColorRGB( 0, 102, 0 ) ); //buy GfxSelectFont( "Tahoma", 13, 100 ); GfxSetBkMode( 1 ); GfxSetTextColor( colorWhite ); GfxRoundRect( x1, y1, x2, y2 , 7, 7 ) ; GfxTextOut( "LE", x1 + 20, y1 + 20 ); sx1 = x2; sy1 = y1; sx2 = sx1 + 60; sy2 = sy1 + 60; GfxSelectSolidBrush( ColorRGB( 255, 204, 204 ) );//sell GfxRoundRect( sx1, sy1, sx2, sy2 , 7, 7 ) ; GfxSetTextColor( ColorRGB( 153, 0, 0 ) ); GfxTextOut( "SE", sx1 + 20, sy1 + 20 ); ex1 = x1; ey1 = y1+60; ex2 = ex1 + 60; ey2 = ey1 + 60; GfxSelectSolidBrush( ColorRGB( 255, 204, 204 ) );//sell GfxRoundRect( ex1, ey1, ex2, ey2 , 7, 7 ) ; GfxSetTextColor( ColorRGB( 153, 0, 0 ) ); GfxTextOut( "LX", ex1 + 20, ey1 + 20 ); GfxSelectSolidBrush( ColorRGB( 0, 102, 0 ) );//sell GfxRoundRect( ex2, ey1, ex2+60, ey2 , 7, 7 ) ; GfxSetTextColor( colorWhite ); GfxTextOut( "SX", ex2 + 20, ey1 + 20 ); if ( px > x1 AND pxy1 AND py < y2 AND Click ) { _TRACE( "# ," + NumToStr(Nz(StaticVarGet("counter")),0,False) + ", BUY triggered from button, " ); AlertIf( 1, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 1, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:1", "BUY", "Buy Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LE",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > sx1 AND pxsy1 AND py < sy2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", SHORT triggered from button, " ); AlertIf( 2, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:3", "SHORT", "Short Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SE",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > ex1 AND pxey1 AND py<ey2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", SELL triggered from button, " ); AlertIf( 3, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:3", "SELL", "Sell Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "LX",sym,"M","",sp,qty,instr,stag); } //https://algoji.com/ if ( px > ex2 AND px<(ex2+60) AND py>ey1 AND py < ey2 AND Click ) { _TRACE( "# ," + NumToStr( DateTime(), formatDateTime ) + ", Cover triggered from button, " ); AlertIf( 4, "SOUND C:\Windows\Media\tada.wav", "Audio alert", 2, 2, 1 ); StaticVarSet("counter", Nz(StaticVarGet("counter"))+1 ); PopupWindowEx( "ID:3", "Cover", "Cover Triggered from Button "+Name(), 1, -1, -1 ); AlgoJi_Signal(NumToStr(Nz(StaticVarGet("counter")),0,False), "SX",sym,"M","",sp,qty,instr,stag); } }
It is not a Python, it is AFL. It will be much easier if you post it as a code. If you run it in AFL Formula Editor it will help you to debug it - simply click "Apply" and you will have all errors highlined. I've found that you missed some "*" in your formula.
fnDrawCallback how to loop through each row
How do i loop through the enitre datset within the in datatables method? "fnFooterCallback": function (nFoot, aData, iStart, iEnd, aiDisplay) { $(aData).each(function (index) { $(".it").append("<div class='mapdata' id='" + nFoot + "B' title='" + aData[index][14] + "|" + aData[index][15] + "' >"); }); }, The above works if the pagination is removed. But if iDisplayLength is set to 25 for example then it only goes through 25 records, not all 100 etc.
"fnFooterCallback": function (nFoot, aData, iStart, iEnd, aiDisplay) { $(aData).each(function (index) { $(".it").append("<div class='mapdata' id='" + nFoot + "B' title='" + aData[index][14] + "|" + aData[index][15] + "' data-id='true' data-id2='" + aData[index][1] + "' data-isapprove='" + aData[index][12] + "' ><div class='gTab1'><div class='info'><div class='maptitle'>" + aData[index][1] + "</div><div class='location'></div></div></div ></div >"); }); }, The above did it
How to add extra column to protractor-html-screenshot-reporter like duration for each "it" block
I am trying to add an extra column to the HTML report. Like duration of each "it" block. I tried this inside jsonparser.js file. phssr.makeHTMLPage = function(tableHtml, reporterOptions){ var styleTag = phssr.makeHardCodedStyleTag(reporterOptions); var scrpTag = phssr.makeScriptTag(); var staticHTMLContentprefix = "<html><head><meta charset='utf-8'/>"; //Add title if it was in config setup if (typeof (reporterOptions.docTitle) !== 'undefined' && _.isString(reporterOptions.docTitle) ){ staticHTMLContentprefix += "<title>" + reporterOptions.docTitle + "</title>"; } else { staticHTMLContentprefix += "<title></title>"; } staticHTMLContentprefix += styleTag + scrpTag + " </head><body>"; staticHTMLContentprefix += "<h1>" + reporterOptions.docHeader + "</h1><table class='header'>"; staticHTMLContentprefix += "<tr><th class='desc-col'>Description</th><th class='status-col'>Passed</th>"; staticHTMLContentprefix += "<th class='browser-col'>Browser</th>"; staticHTMLContentprefix += "<th class='os-col'>OS</th><th class='msg-col'>Message</th>"; staticHTMLContentprefix += "<th class='msg-col'>Duration</th>"; staticHTMLContentprefix += "<th class='img-col'>Screenshot</th></tr></table>"; var staticHTMLContentpostfix = "</body></html>"; var htmlComplete = staticHTMLContentprefix + tableHtml + staticHTMLContentpostfix; return htmlComplete; } phssr.getTimestamp = function (date) { function pad(n) { return n < 10 ? '0' + n : n; } var currentDate = date !== undefined ? date : new Date(), month = currentDate.getMonth() + 1, day = currentDate.getDate(); return (currentDate.getFullYear() + "-" + pad(month) + "-" + pad(day) + " " + pad(currentDate.getHours()) + ":" + pad(currentDate.getMinutes()) + ":" + pad(currentDate.getSeconds())); } var sTime = new Date(); var startTime = phssr.getTimestamp(sTime); console.log("sTime***********************",startTime); var passCount=0, failCount=0, loopCount=0; function generateHTML(data){ var eTime = new Date(); var endTime = phssr.getTimestamp(eTime); console.log("eTime***********************",endTime); var diffTime = (eTime-sTime)/1000; console.log("dTime***********************",diffTime); data.passed? passCount++: failCount++; var str = '<table><tr>'; str += '<td class="desc-col">' + data.desc + '</td>'; var bgColor = data.passed? 'green': 'red'; str += '<td class="status-col" style="color:#fff;background-color: '+ bgColor+'">' + data.passed + '</td>'; str += '<td class="browser-col">' + data.browser.name+ ':' +data.browser.version + '</td>'; str += '<td class="os-col">' + data.os + '</td>'; var stackTraceInfo = data.passed? '': '<br/><a onclick="showTrace(event)" href="#trace-modal'+loopCount+'">View Stack Trace Info</a><br/> <div id="#trace-modal'+loopCount+'" class="traceinfo"><div>X' + data.trace + '</div></div>'; str += '<td class="msg-col">' + data.message+ stackTraceInfo+ '</td>'; str += '<td class="msg-col">' + diffTime + '</td>'; if(!(reporterOptions.takeScreenShotsOnlyForFailedSpecs && data.passed)) { str += '<td class="img-col">View </td>'; } else{ str += '<td class="img-col"></td>'; } str += '</tr></table>'; loopCount++; return str; } I can see the extra column in the report. The problem was it is not showing the correct time. In the console it is printing like this sTime*********************** 2015-08-28 13:26:44 Using the selenium server at http://localhost:4444/wd/hub .eTime*********************** 2015-08-28 13:26:48 dTime*********************** 3.312 .eTime*********************** 2015-08-28 13:26:52 dTime*********************** 7.984 eTime*********************** 2015-08-28 13:26:52 dTime*********************** 7.984 . Finished in 12.123 seconds 3 tests, 3 assertions, 0 failures eTime*********************** 2015-08-28 13:26:57 dTime*********************** 12.325 eTime*********************** 2015-08-28 13:26:57 dTime*********************** 12.325 eTime*********************** 2015-08-28 13:26:57 dTime*********************** 12.325 here, I don't know why it is executing two times. In the report it is showing 12.325 for all blocks. I don't know where I am doing wrong. please help me. Tests: describe('Title', function() { it('TESTCASE-1 : Should have a title', function() { expect(browser.getTitle()).toContain('Test'); }); it('TESTCASE-2 : Should accept a valid email address and password', function() { element(by.id('email')).sendKeys('*********'); element(by.id('password')).sendKeys('*********'); element(by.css('.btn')).click(); expect(browser.getCurrentUrl()).toEqual('*********/app/#/home'); }); it('TESTCASE-4: Dashboard Selection.....', function(){ var menubutton = element.all(by.css('.btn')).get(0); menubutton.click(); expect(browser.getCurrentUrl()).toEqual('*************************/students/1'); }); });
Script to export layer coordinates to excel
I have found a script that export my layers coordinates form photoshop CS5 to XML I hope somebody here can help me to edit that script to record coordinates to xls file? Also if is possible to have each coordinates on separate row will be great. Below is script I want to modify to do what I need. // // This script exports extended layer.bounds information to [psd_file_name].xml // by pattesdours // function docCheck() { // ensure that there is at least one document open if (!documents.length) { alert('There are no documents open.'); return; // quit } } docCheck(); var originalRulerUnits = preferences.rulerUnits; preferences.rulerUnits = Units.PIXELS; var docRef = activeDocument; var docWidth = docRef.width.value; var docHeight = docRef.height.value; var mySourceFilePath = activeDocument.fullName.path + "/"; // Code to get layer index / descriptor // cTID = function(s) { return app.charIDToTypeID(s); }; sTID = function(s) { return app.stringIDToTypeID(s); }; function getLayerDescriptor (doc, layer) { var ref = new ActionReference(); ref.putEnumerated(cTID("Lyr "), cTID("Ordn"), cTID("Trgt")); return executeActionGet(ref) }; function getLayerID(doc, layer) { var d = getLayerDescriptor(doc, layer); return d.getInteger(cTID('LyrI')); }; var stackorder = 0; // function from Xbytor to traverse all layers traverseLayers = function(doc, ftn, reverse) { function _traverse(doc, layers, ftn, reverse) { var ok = true; for (var i = 1; i <= layers.length && ok != false; i++) { var index = (reverse == true) ? layers.length-i : i - 1; var layer = layers[index]; if (layer.typename == "LayerSet") { ok = _traverse(doc, layer.layers, ftn, reverse); } else { stackorder = stackorder + 1; ok = ftn(doc, layer, stackorder); } } return ok; }; return _traverse(doc, doc.layers, ftn, reverse); }; // create a string to hold the data var str =""; // class using a contructor function cLayer(doc, layer) { //this.layerID = Stdlib.getLayerID(doc, layer); this.layerID = getLayerID(doc, layer); //alert("layer ID: " + this.layerID); this.layerWidth = layer.bounds[2].value - layer.bounds[0].value; this.layerHeight = layer.bounds[3].value - layer.bounds[1].value; // these return object coordinates relative to canvas this.upperLeftX = layer.bounds[0].value; this.upperLeftY = layer.bounds[1].value; this.upperCenterX = this.layerWidth / 2 + layer.bounds[0].value; this.upperCenterY = layer.bounds[1].value; this.upperRightX = layer.bounds[2].value; this.upperRightY = layer.bounds[1].value; this.middleLeftX = layer.bounds[0].value; this.middleLeftY = this.layerHeight / 2 + layer.bounds[1].value; this.middleCenterX = this.layerWidth / 2 + layer.bounds[0].value; this.middleCenterY = this.layerHeight / 2 + layer.bounds[1].value; this.middleRightX = layer.bounds[2].value; this.middleRightY = this.layerHeight / 2 + layer.bounds[1].value; this.lowerLeftX = layer.bounds[0].value; this.lowerLeftY = layer.bounds[3].value; this.lowerCenterX = this.layerWidth / 2 + layer.bounds[0].value; this.lowerCenterY = layer.bounds[3].value; this.lowerRightX = layer.bounds[2].value; this.lowerRightY = layer.bounds[3].value; // I'm adding these for easier editing of flash symbol transformation point (outputs a 'x, y' format) // because I like to assign shortcut keys that use the numeric pad keyboard, like such: // 7 8 9 // 4 5 6 // 1 2 3 // this.leftBottom = this.lowerLeftX + ", " + this.lowerLeftY; this.bottomCenter = this.lowerCenterX + ", " + this.lowerCenterY; this.rightBottom = this.lowerRightX + ", " + this.lowerRightY; this.leftCenter = this.middleLeftX + ", " + this.middleLeftY; this.center = this.middleCenterX + ", " + this.middleCenterY; this.rightCenter = this.middleRightX + ", " + this.middleRightY; this.leftTop = this.upperLeftX + ", " + this.upperLeftY; this.topCenter = this.upperCenterX + ", " + this.upperCenterY; this.rightTop = this.upperRightX + ", " + this.upperRightY; // these return object coordinates relative to layer bounds this.relUpperLeftX = layer.bounds[1].value - layer.bounds[1].value; this.relUpperLeftY = layer.bounds[0].value - layer.bounds[0].value; this.relUpperCenterX = this.layerWidth / 2; this.relUpperCenterY = layer.bounds[0].value - layer.bounds[0].value; this.relUpperRightX = this.layerWidth; this.relUpperRightY = layer.bounds[0].value - layer.bounds[0].value; this.relMiddleLeftX = layer.bounds[1].value - layer.bounds[1].value; this.relMiddleLeftY = this.layerHeight / 2; this.relMiddleCenterX = this.layerWidth / 2; this.relMiddleCenterY = this.layerHeight / 2; this.relMiddleRightX = this.layerWidth; this.relMiddleRightY = this.layerHeight / 2; this.relLowerLeftX = layer.bounds[1].value - layer.bounds[1].value; this.relLowerLeftY = this.layerHeight; this.relLowerCenterX = this.layerWidth / 2; this.relLowerCenterY = this.layerHeight / 2; this.relLowerRightY = this.layerHeight; this.relLowerRightX = this.layerWidth; this.relLowerRightY = this.layerHeight; return this; } // add header line //str = "<psd filename=\"" + docRef.name + "\" path=\"" + mySourceFilePath + "\" width=\"" + docWidth + "\" height=\"" + docHeight + "\">\n"; // now a function to collect the data function exportBounds(doc, layer, i) { var isVisible = layer.visible; var layerData = cLayer(doc, layer); // if(isVisible){ // Layer object main coordinates relative to its active pixels var str2 = leftTop // this is the // + "\" layerwidth=\"" + layerData.layerWidth // + "\" layerheight=\"" + layerData.layerHeight // + "\" transformpoint=\"" + "center" + "\">" // hard-coding 'center' as the default transformation point +"\" \"" + layer.name + ".png" + "</layer>\n" // I have to put some content here otherwise sometimes tags are ignored str += str2.toString(); }; //}; // call X's function using the one above traverseLayers(app.activeDocument, exportBounds, true); // Use this to export XML file to same directory where PSD file is located var mySourceFilePath = activeDocument.fullName.path + "/"; // create a reference to a file for output var csvFile = new File(mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xls"); // open the file, write the data, then close the file csvFile.open('w'); csvFile.writeln(str + "</psd>"); csvFile.close(); preferences.rulerUnits = originalRulerUnits; // Confirm that operation has completed alert("Operation Complete!" + "\n" + "Layer coordinates were successfully exported to:" + "\n" + "\n" + mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xml");
Change var str2 = leftTop // this is the // + "\" layerwidth=\"" + layerData.layerWidth // + "\" layerheight=\"" + layerData.layerHeight // + "\" transformpoint=\"" + "center" + "\">" // hard-coding 'center' as the default transformation point +"\" \"" + layer.name + ".png" + "</layer>\n" // I have to put some content here otherwise sometimes tags are ignored str += str2.toString(); to var str2 = leftTop + ","+ layer.name + "\n" str += str2.toString(); and var csvFile = new File(mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".xls"); to var csvFile = new File(mySourceFilePath.toString().match(/([^\.]+)/)[1] + app.activeDocument.name.match(/([^\.]+)/)[1] + ".csv"); This works great for me!