applications/luci-ffwizard: initial
[project/luci.git] / applications / luci-ffwizard / luasrc / view / cbi / osmll_value.htm
1 <%#
2 cc-by-sa Andreas Pittrich <andreas.pittrich@web.de>
3 in behalf of the german pirate party (Piratenpartei)
4 www.piratenpartei.de
5
6 $Id$
7
8 -%>
9 <%+cbi/valueheader%>
10 <script type="text/javascript">
11 function set_lat_lon() {
12         var net
13         var entry
14         var lon
15         var lat
16         var zoom
17         net = document.getElementById('cbid.ffwizward.1.net').value;
18         if (!net){
19                 return
20         }
21         
22         lon = document.getElementById('cbid.ffwizward.1.latlon.centerlon');
23         lat = document.getElementById('cbid.ffwizward.1.latlon.centerlat');
24         zoom = document.getElementById('cbid.ffwizward.1.latlon.zoom'); 
25         if ( !lon.value || lon.value == '' || lon.value == 0 || lon.value == 10 ) {
26                 for ( var i = 0 ; true ; i++ ) {
27                         if (i == cbi_d.length) {
28                                 break;
29                         }
30                         if (cbi_d[i].id == 'cbi-ffwizward-1-net_lon') {
31                                 entry = cbi_d[i];
32                                 for (var j=0; true; j++) {
33                                         if ( entry.node.children[0].children[j] ){
34                                                 if ( entry.node.children[0].children[j].value == net ) {
35                                                         lon.value = entry.node.children[0].children[j].text;
36                                                         zoom.value = '14';
37                                                         break;
38                                 }
39                                         } else {
40                                                 break;
41                                         }
42                                 }
43                                 break;
44                         }
45                 }
46         }
47         if ( !lat.value || lat.value == '' || lat.value == 0 || lat.value == 52 ) {
48                 for (var i=0; true; i++) {
49                         if (i == cbi_d.length) {
50                                 break;
51                         }
52                         if (cbi_d[i].id == 'cbi-ffwizward-1-net_lat') {
53                                 entry = cbi_d[i];
54                                 for (var j=0; true; j++) {
55                                         if ( entry.node.children[0].children[j] ){
56                                                 if ( entry.node.children[0].children[j].value == net ) {
57                                                         lat.value = entry.node.children[0].children[j].text;
58                                                         break;
59                                 }
60                                         } else {
61                                                 break;
62                                         }                                       
63                                 }
64                                 break;
65                         }
66                 }
67         }
68 }
69 </script>
70
71                 <% if self:cfgvalue(section) ~= false then %>
72                         <% if self.latfield and self.lonfield then %>
73                                 <input type="hidden" <%= attr("value", string.format('cbid.%s.%s.%s', self.config, section, self.latfield))..attr("id", cbid..".latfield")..attr("name", cbid..".latfield")%>/>
74                                 <input type="hidden" <%= attr("value", string.format('cbid.%s.%s.%s', self.config, section, self.lonfield))..attr("id", cbid..".lonfield")..attr("name", cbid..".lonfield")%>/>
75                         <% end %>
76                         <input type="hidden" <%= attr("value", self.centerlat)..attr("id", cbid..".centerlat")..attr("name", cbid..".centerlat")%>/>
77                         <input type="hidden" <%= attr("value", self.centerlon)..attr("id", cbid..".centerlon")..attr("name", cbid..".centerlon")%>/>
78                         <input type="hidden" <%= attr("value", self.zoom)..attr("id", cbid..".zoom")..attr("name", cbid..".zoom")%>/>
79                 <% end %>
80
81                 <% if self.popup then %>
82                         <input class="cbi-input-button" type="button"<%= attr("name", cbid..".button")..attr("id", cbid..".button")..attr("value", self.displaytext)%> 
83                                         onclick="
84                                                 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');
85                                                 popup.focus();
86                                         "
87                         />
88         </div>
89         <div>           
90                 <% else %>
91                         <input class="cbi-input-button" type="button"<%= attr("name", cbid..".displayosm")..attr("id", cbid..".displayosm")..attr("value", self.displaytext)%> 
92                                         onclick="
93                                                 set_lat_lon();
94                                                 document.getElementById('<%=cbid..".hideosm"%>').style.display='inline';
95                                                 document.getElementById('<%=cbid..".displayosm"%>').style.display='none';
96                                                 for(var i = 0; Math.min(i, window.frames.length)!=window.frames.lengths; i++){
97                                                         if(frames[i].name=='<%=cbid..".iframe"%>'){                                                             
98                                                                 document.getElementById('<%=cbid..".iframediv"%>').style.display='block';
99                                                                 frames[i].location.href='/luci-static/resources/OSMLatLon.htm';
100                                                         }
101                                                 }
102                                         "
103                         />
104                         <input class="cbi-input-button" style="display:none" type="button"<%= attr("name", cbid..".hideosm")..attr("id", cbid..".hideosm")..attr("value", self.hidetext)%> 
105                                         onclick="
106                                                 document.getElementById('<%=cbid..".displayosm"%>').style.display='inline';
107                                                 document.getElementById('<%=cbid..".hideosm"%>').style.display='none';
108                                                 document.getElementById('<%=cbid..".iframediv"%>').style.display='none';
109                                         "
110                         />
111         </div>
112         <div class="cbi-value-osmiframesection" id="<%=cbid..".iframediv"%>" style="display:none">
113                         <iframe src="" <%= attr("id", cbid..".iframe")..attr("name", cbid..".iframe")..attr("width", self.width)..attr("height", self.height)%> frameborder="0" scrolling="no"></iframe>
114                 <%end%>
115
116 <%+cbi/valuefooter%>