Your Ad Here

Posted By

f on 02/11/09


Tagged

siteDependent


Versions (?)

你的地圖網


 / Published in: JavaScript
 

URL: http://www.urmap.com/

幫公車加上“台北市大眾運輸公車路線查詢系統”的公車資料連結。

不過含有Non-ascii characters的公車車號仍需要對Non-ascii character做進一步的轉換,目前已知encodeURIComponent無法將其轉換為正確的字串。

  1. /*
  2. javascript: (function() { var boldTexts = document.getElementById("routingResultDiv").getElementsByTagName("b"); var ch, cl; var busIds; var end; for (ch = 0; ch < boldTexts.length; ch++) { busIds = /([^\[\]]+)/.exec(boldTexts[ch].textContent)[0].split(","); busIds = busIds.sort(); busIds = busIds.sort(function(a, b) { return parseInt(a) - parseInt(b) ? parseInt(a) - parseInt(b) : -1; }); for (cl = 0; cl < busIds.length; cl++) busIds[cl] = "<a href=\"http://www.taipeibus.taipei.gov.tw/emap/program/html/bus_cnt.asp?s=" + busIds[cl] + "\">" + busIds[cl] + "<\/a>"; boldTexts[ch].innerHTML = "[" + busIds + "] 路公車"; } })();
  3. */
  4. javascript:
  5. (function()
  6. {
  7. var boldTexts = document.getElementById("routingResultDiv").getElementsByTagName("b");
  8. var ch, cl;
  9. var busIds;
  10. var end;
  11. for (ch = 0; ch < boldTexts.length; ch++)
  12. {
  13. busIds = /([^\[\]]+)/.exec(boldTexts[ch].textContent)[0].split(",");
  14. busIds = busIds.sort();
  15. busIds = busIds.sort(function(a, b) { return parseInt(a) - parseInt(b) ? parseInt(a) - parseInt(b) : -1; });
  16. for (cl = 0; cl < busIds.length; cl++)
  17. busIds[cl] = "<a href=\"http://www.taipeibus.taipei.gov.tw/emap/program/html/bus_cnt.asp?s=" + busIds[cl] + "\">" + busIds[cl] + "<\/a>";
  18. boldTexts[ch].innerHTML = "[" + busIds + "] 路公車";
  19. }
  20. })();

Report this snippet  

You need to login to post a comment.