luci-0.8: merge r4605 and r4606
[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 w = 1;
47 if (etx < 4) w++;
48 if (etx < 2) w++;
49 map.AddPolyline(new VEPolyline('id'+lineid, [points[fromip], points[toip]],
50 new VEColor(102,Math.floor(lq*255.0),Math.floor(nlq*255.0),1.0), w));
51 }
52 else
53 {
54 if (null == points[toip]) unkpos[toip] = '';
55 if (null == points[fromip]) unkpos[fromip] = '';
56 }
57 lineid++;
58 }
59
60 function PLink(fromip,toip,lq,nlq,etx,lata,lona,ishnaa,latb,lonb,ishnab)
61 {
62 Link(fromip,toip,lq,nlq,etx);
63 }
64
65 function ffmapinit()
66 {
67 if(null!=window.map)map.Dispose();
68 map = new VEMap('ffmap');
69 <%
70 local fd
71 local uci = require "luci.model.uci".cursor()
72
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
79 if fd then
80 while true do
81 local ln = fd:read("*l")
82 if not ln then break end
83 write(ln)
84 end
85 fd:close()
86 end
87 %>
88 }
89
90 function ffgoto(ip)
91 {
92 map.SetCenter(points[ip]);
93 }
94 </script>
95 <div id="ffmap" style="position:relative; width:100%; height:640px;"></div>
96 </body>
97 </html>