map.htm 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>Map</title>
  5. </head>
  6. <body style="margin:0">
  7. <script src="//dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1&s=1" type="text/javascript"></script>
  8. <script type="text/javascript">
  9. var alias = new Array;
  10. var points = new Array;
  11. var unkpos = new Array;
  12. var lineid = 0;
  13. onload=new Function("if(null!=window.ffmapinit)ffmapinit();");
  14. function Mid(mainip,aliasip)
  15. {
  16. alias[aliasip]=mainip;
  17. }
  18. function Node(mainip,lat,lon,ishna,hnaip,name)
  19. {
  20. points[mainip] = new VELatLong(lat, lon);
  21. map.AddPushpin(new VEPushpin(mainip, points[mainip],
  22. '<%=luci.config.main.resourcebase%>/freifunk-map/'+(ishna?'hna':'node')+'.gif', 'Node:'+name,
  23. '<br><img src="<%=luci.config.main.resourcebase%>/freifunk-map/'+(ishna?'hna':'node')+'.gif">'+
  24. '<br>IP:'+mainip+'<br>DefGW:'+hnaip));
  25. }
  26. function Self(mainip,lat,lon,ishna,hnaip,name)
  27. {
  28. //map.SetDashboardSize(VEDashboardSize.Small);
  29. map.LoadMap(new VELatLong(lat, lon), 15, VEMapStyle.Hybrid);
  30. map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers);
  31. map.ShowMiniMap(14, 474);
  32. Node(mainip,lat,lon,ishna,hnaip,name);
  33. }
  34. function Link(fromip,toip,lq,nlq,etx)
  35. {
  36. if (0==lineid && null!=window.ffmapstatic) ffmapstatic();
  37. if (null != alias[toip]) toip = alias[toip];
  38. if (null != alias[fromip]) fromip = alias[fromip];
  39. if (null != points[fromip] && null != points[toip])
  40. {
  41. var color;
  42. var red = 240;
  43. var green = 0;
  44. var blue = 0;
  45. var w = 1
  46. if (etx < 100) {red=252;green=102;blue=0;w=2};
  47. if (etx < 10) {red=255;green=203;blue=5;w=3};
  48. if (etx < 4) {red=240;green=255;blue=0;w=4};
  49. if (etx < 2) {red=0;green=204;blue=0;w=5};
  50. if (etx < 1) {red=80;green=0;blue=0;w=1};
  51. map.AddPolyline(new VEPolyline('id'+lineid, [points[fromip], points[toip]],
  52. new VEColor(red, green, blue, 0.5), w));
  53. }
  54. else
  55. {
  56. if (null == points[toip]) unkpos[toip] = '';
  57. if (null == points[fromip]) unkpos[fromip] = '';
  58. }
  59. lineid++;
  60. }
  61. function PLink(fromip,toip,lq,nlq,etx,lata,lona,ishnaa,latb,lonb,ishnab)
  62. {
  63. Link(fromip,toip,lq,nlq,etx);
  64. }
  65. function ffmapinit()
  66. {
  67. if(null!=window.map)map.Dispose();
  68. var INFINITE = 99.99;
  69. map = new VEMap('ffmap');
  70. <%
  71. local fd
  72. local uci = require "luci.model.uci".cursor()
  73. uci:foreach("olsrd", "LoadPlugin", function(s)
  74. if s.library == "olsrd_nameservice.so.0.3" and s.latlon_file then
  75. fd = io.open(s.latlon_file)
  76. end
  77. end)
  78. if fd then
  79. local data = fd:read("*a")
  80. fd:close()
  81. if data then
  82. local line
  83. for line in data:gmatch("[^\n]+") do
  84. if line:match(";$") then
  85. write(line .. "\n")
  86. else
  87. break
  88. end
  89. end
  90. end
  91. end
  92. %>
  93. }
  94. function ffgoto(ip)
  95. {
  96. map.SetCenter(points[ip]);
  97. }
  98. </script>
  99. <div id="ffmap" style="position:relative; width:100%; height:640px;"></div>
  100. </body>
  101. </html>