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