diff options
Diffstat (limited to 'modules/freifunk/luasrc')
-rw-r--r-- | modules/freifunk/luasrc/model/cbi/freifunk/basics.lua | 62 | ||||
-rw-r--r-- | modules/freifunk/luasrc/view/cbi/osmll_value.htm | 55 |
2 files changed, 86 insertions, 31 deletions
diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua b/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua index 2c22f7b49f..247e8816c3 100644 --- a/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua +++ b/modules/freifunk/luasrc/model/cbi/freifunk/basics.lua @@ -2,6 +2,7 @@ LuCI - Lua Configuration Interface Copyright 2008 Steven Barth <steven@midlink.org> +Copyright 2011 Manuel Munz <freifunk at somakoma de> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -15,6 +16,7 @@ local util = require "luci.util" local uci = require "luci.model.uci".cursor() local profiles = "/etc/config/profile_" + m = Map("freifunk", translate ("Community")) c = m:section(NamedSection, "community", "public", nil, translate("These are the basic settings for your local wireless community. These settings define the default values for the wizard and DO NOT affect the actual configuration of the router.")) @@ -30,7 +32,12 @@ for k,v in ipairs(list) do community:value(n, name) end + n = Map("system", translate("Basic system settings")) +function n.on_after_commit(self) + luci.http.redirect(luci.dispatcher.build_url("admin", "freifunk", "basics")) +end + b = n:section(TypedSection, "system") b.anonymous = true @@ -42,25 +49,31 @@ loc = b:option(Value, "location", translate("Location")) loc.rmempty = false lat = b:option(Value, "latitude", translate("Latitude"), translate("e.g.") .. " 48.12345") +lat.datatype = "float" lat.rmempty = false lon = b:option(Value, "longitude", translate("Longitude"), translate("e.g.") .. " 10.12345") +lon.datatype = "float" lon.rmempty = false --[[ Opens an OpenStreetMap iframe or popup Makes use of resources/OSMLatLon.htm and htdocs/resources/osm.js -(is that the right place for files like these?) ]]-- ---[[ this needs to be fixed local class = util.class -local co = "profile_augsburg" -local syslat = uci:get_first(co, "community", "latitude") -local syslon = uci:get_first(co, "community", "longitude") - -OpenStreetMapLonLat = class(AbstractValue) +local ff = uci:get("freifunk", "community", "name") or "" +local co = "profile_" .. ff + +local deflat = uci:get_first("system", "system", "latitude") or uci:get_first(co, "community", "latitude") or 52 +local deflon = uci:get_first("system", "system", "longitude") or uci:get_first(co, "community", "longitude") or 10 +local zoom = 12 +if ( deflat == 52 and deflon == 10 ) then + zoom = 4 +end +OpenStreetMapLonLat = luci.util.class(AbstractValue) + function OpenStreetMapLonLat.__init__(self, ...) AbstractValue.__init__(self, ...) self.template = "cbi/osmll_value" @@ -76,29 +89,16 @@ function OpenStreetMapLonLat.__init__(self, ...) self.hidetext="X" -- text on button, that hides OSMap end - -f = SimpleForm("ffwizward", "OpenStreetMap", "Hier kann man die Geokoordinaten des Knotens herausfinden.") - -osm = f:field(OpenStreetMapLonLat, "latlon", "Geokoordinaten mit OpenStreetMap ermitteln:", "Klicken Sie auf Ihren Standort in der Karte. Diese Karte funktioniert nur, wenn das Gerät bereits eine Verbindung zum Internet hat.") -osm.latfield = "lat" -osm.lonfield = "lon" -osm.centerlat = syslat -osm.centerlon = syslon -osm.width = "100%" -osm.height = "600" -osm.popup = false - -syslatlengh = string.len(syslat) -if syslatlengh > 7 then - osm.zoom = "15" -elseif syslatlengh > 5 then - osm.zoom = "12" -else - osm.zoom = "6" -end - -osm.displaytext="OpenStreetMap anzeigen" -osm.hidetext="OpenStreetMap verbergen" -]] + osm = b:option(OpenStreetMapLonLat, "latlon", translate("Find your coordinates with OpenStreetMap"), translate("Select your location with a mouse click on the map. The map will only show up if you are connected to the Internet.")) + osm.latfield = "latitude" + osm.lonfield = "longitude" + osm.centerlat = uci:get_first("system", "system", "latitude") or deflat + osm.centerlon = uci:get_first("system", "system", "longitude") or deflon + osm.zoom = zoom + osm.width = "100%" + osm.height = "600" + osm.popup = false + osm.displaytext=translate("Show OpenStreetMap") + osm.hidetext=translate("Hide OpenStreetMap") return m, n diff --git a/modules/freifunk/luasrc/view/cbi/osmll_value.htm b/modules/freifunk/luasrc/view/cbi/osmll_value.htm new file mode 100644 index 0000000000..c368b67bdf --- /dev/null +++ b/modules/freifunk/luasrc/view/cbi/osmll_value.htm @@ -0,0 +1,55 @@ +<%# +cc-by-sa Andreas Pittrich <andreas.pittrich@web.de> +in behalf of the german pirate party (Piratenpartei) +www.piratenpartei.de + +$Id$ + +-%> +<%+cbi/valueheader%> + + <% if self:cfgvalue(section) ~= false then %> + <% if self.latfield and self.lonfield then %> + <input type="hidden" <%= attr("value", string.format('cbid.%s.%s.%s', self.config, section, self.latfield))..attr("id", cbid..".latfield")..attr("name", cbid..".latfield")%>/> + <input type="hidden" <%= attr("value", string.format('cbid.%s.%s.%s', self.config, section, self.lonfield))..attr("id", cbid..".lonfield")..attr("name", cbid..".lonfield")%>/> + <% end %> + <input type="hidden" <%= attr("value", self.centerlat)..attr("id", cbid..".centerlat")..attr("name", cbid..".centerlat")%>/> + <input type="hidden" <%= attr("value", self.centerlon)..attr("id", cbid..".centerlon")..attr("name", cbid..".centerlon")%>/> + <input type="hidden" <%= attr("value", self.zoom)..attr("id", cbid..".zoom")..attr("name", cbid..".zoom")%>/> + <% end %> + + <% if self.popup then %> + <input class="cbi-input-button" type="button"<%= attr("name", cbid..".button")..attr("id", cbid..".button")..attr("value", self.displaytext)%> + onclick=" + popup=window.open('/luci-static/resources/OSMLatLon.htm', '<%=cbid%>.window', 'innerWidth=<%=self.width%>, innerHeight=<%=self.height%>, location=no, menubar=no, scrollbars=no, status=no, toolbar=no'); + popup.focus(); + " + /> + </div> + <div> + <% else %> + <input class="cbi-input-button" type="button"<%= attr("name", cbid..".displayosm")..attr("id", cbid..".displayosm")..attr("value", self.displaytext)%> + onclick=" + document.getElementById('<%=cbid..".hideosm"%>').style.display='inline'; + document.getElementById('<%=cbid..".displayosm"%>').style.display='none'; + for(var i = 0; Math.min(i, window.frames.length)!=window.frames.lengths; i++){ + if(frames[i].name=='<%=cbid..".iframe"%>'){ + document.getElementById('<%=cbid..".iframediv"%>').style.display='block'; + frames[i].location.href='/luci-static/resources/OSMLatLon.htm'; + } + } + " + /> + <input class="cbi-input-button" style="display:none" type="button"<%= attr("name", cbid..".hideosm")..attr("id", cbid..".hideosm")..attr("value", self.hidetext)%> + onclick=" + document.getElementById('<%=cbid..".displayosm"%>').style.display='inline'; + document.getElementById('<%=cbid..".hideosm"%>').style.display='none'; + document.getElementById('<%=cbid..".iframediv"%>').style.display='none'; + " + /> + </div> + <div class="cbi-value-osmiframesection" id="<%=cbid..".iframediv"%>" style="display:none"> + <iframe src="" <%= attr("id", cbid..".iframe")..attr("name", cbid..".iframe")..attr("width", self.width)..attr("height", self.height)%> frameborder="0" scrolling="no"></iframe> + <%end%> + +<%+cbi/valuefooter%> |