+ var step=steps[i];
+ var instCodes=step[0].split('-');
+ // Assemble instruction text
+ var instText="<b>"+(i+1)+".</b> ";
+ instText+=TURN_INSTRUCTIONS[instCodes[0]];
+ if (instCodes[1]) { instText+="exit "+instCodes[1]+" "; }
+ if (instCodes[0]!=15) { instText+=step[1] ? "<b>"+step[1]+"</b>" : "(unnamed)"; }
+ // Distance
+ var dist=step[2];
+ if (dist<5) { dist=""; }
+ else if (dist<200) { dist=Math.round(dist/10)*10+"m"; }
+ else if (dist<1500) { dist=Math.round(dist/100)*100+"m"; }
+ else if (dist<5000) { dist=Math.round(dist/100)/10+"km"; }
+ else { dist=Math.round(dist/1000)+"km"; }
+ // Add to table
+ var row=$("<tr class='turn'/>");
+ row.append("<td class='direction i"+instCodes[0]+"'> ");
+ row.append("<td class='instruction'>"+instText);
+ row.append("<td class='distance'>"+dist);
+ with ({n: i}) { row.on('click',function(e) { r.clickTurn(n); });
+ }
+ $('#turnbyturn').append(row);