diff options
author | Jo-Philipp Wich <jow@openwrt.org> | 2009-05-25 13:53:31 +0000 |
---|---|---|
committer | Jo-Philipp Wich <jow@openwrt.org> | 2009-05-25 13:53:31 +0000 |
commit | 7ae3fc5478312e6213d33b6300626eeb8cde9a5f (patch) | |
tree | 43aafb7fdafb4cba2d182070b280e8d39c5822dc /modules/freifunk/luasrc/view/freifunk-map/map.htm | |
parent | d70ff10fd6b7606e3c6b76ea3f407a4391cec9ab (diff) |
modules/freifunk: add map
Diffstat (limited to 'modules/freifunk/luasrc/view/freifunk-map/map.htm')
-rw-r--r-- | modules/freifunk/luasrc/view/freifunk-map/map.htm | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/modules/freifunk/luasrc/view/freifunk-map/map.htm b/modules/freifunk/luasrc/view/freifunk-map/map.htm new file mode 100644 index 0000000000..7ecf495210 --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk-map/map.htm @@ -0,0 +1,97 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> + <head> + <title>Map</title> + </head> + + <body style="margin:0"> + <script src="http://dev.virtualearth.net/mapcontrol/mapcontrol.ashx?v=6.1" type="text/javascript"></script> + <script type="text/javascript"> + var alias = new Array; + var points = new Array; + var unkpos = new Array; + var lineid = 0; + onload=new Function("if(null!=window.ffmapinit)ffmapinit();"); + + function Mid(mainip,aliasip) + { + alias[aliasip]=mainip; + } + + function Node(mainip,lat,lon,ishna,hnaip,name) + { + points[mainip] = new VELatLong(lat, lon); + map.AddPushpin(new VEPushpin(mainip, points[mainip], + '<%=luci.config.main.resourcebase%>/freifunk-map/'+(ishna?'hna':'node')+'.gif', 'Node:'+name, + '<br><img src="<%=luci.config.main.resourcebase%>/freifunk-map/'+(ishna?'hna':'node')+'.gif">'+ + '<br>IP:'+mainip+'<br>DefGW:'+hnaip)); + } + + function Self(mainip,lat,lon,ishna,hnaip,name) + { + //map.SetDashboardSize(VEDashboardSize.Small); + map.LoadMap(new VELatLong(lat, lon), 15, VEMapStyle.Hybrid); + map.SetScaleBarDistanceUnit(VEDistanceUnit.Kilometers); + map.ShowMiniMap(14, 474); + Node(mainip,lat,lon,ishna,hnaip,name); + } + + function Link(fromip,toip,lq,nlq,etx) + { + if (0==lineid && null!=window.ffmapstatic) ffmapstatic(); + if (null != alias[toip]) toip = alias[toip]; + if (null != alias[fromip]) fromip = alias[fromip]; + if (null != points[fromip] && null != points[toip]) + { + var w = 1; + if (etx < 4) w++; + if (etx < 2) w++; + map.AddPolyline(new VEPolyline('id'+lineid, [points[fromip], points[toip]], + new VEColor(102,Math.floor(lq*255.0),Math.floor(nlq*255.0),1.0), w)); + } + else + { + if (null == points[toip]) unkpos[toip] = ''; + if (null == points[fromip]) unkpos[fromip] = ''; + } + lineid++; + } + + function PLink(fromip,toip,lq,nlq,etx,lata,lona,ishnaa,latb,lonb,ishnab) + { + Link(fromip,toip,lq,nlq,etx); + } + + function ffmapinit() + { + if(null!=window.map)map.Dispose(); + map = new VEMap('ffmap'); + <% + local fd + local uci = require "luci.model.uci".cursor() + + uci:foreach("olsrd", "LoadPlugin", function(s) + if s.library == "olsrd_nameservice.so.0.3" and s.latlon_file then + fd = io.open(s.latlon_file) + end + end) + + if fd then + while true do + local ln = fd:read("*l") + if not ln then break end + write(ln) + end + fd:close() + end + %> + } + + function ffgoto(ip) + { + map.SetCenter(points[ip]); + } + </script> + <div id="ffmap" style="position:relative; width:100%; height:640px;"></div> + </body> +</html> |