3 <script type="text/javascript">//<![CDATA[
4 var freqlist = <%= luci.http.write_json(self.freqlist) %>;
5 var hwmodes = <%= luci.http.write_json(self.hwmodes) %>;
6 var htmodes = <%= luci.http.write_json(self.htmodes) %>;
17 for (var i = 0; i < freqlist.length; i++)
18 channels[(freqlist[i].mhz > 2484) ? '11a' : '11g'].push(
20 '%d (%d MHz)'.format(freqlist[i].channel, freqlist[i].mhz),
21 !freqlist[i].restricted
27 'ac', 'AC', hwmodes.ac
35 'HT20', '20 MHz', htmodes.HT20,
36 'HT40', '40 MHz', htmodes.HT40
39 'VHT20', '20 MHz', htmodes.VHT20,
40 'VHT40', '40 MHz', htmodes.VHT40,
41 'VHT80', '80 MHz', htmodes.VHT80,
42 'VHT160', '160 MHz', htmodes.VHT160
48 '11g', '2.4 GHz', (channels['11g'].length > 3),
49 '11a', '5 GHz', (channels['11a'].length > 3)
52 '11g', '2.4 GHz', (channels['11g'].length > 3),
53 '11a', '5 GHz', (channels['11a'].length > 3)
60 function cbi_set_values(sel, vals)
63 sel.vals.selected = sel.selectedIndex;
65 while (sel.options[0])
68 for (var i = 0; vals && i < vals.length; i += 3)
73 var opt = document.createElement('option');
74 opt.value = vals[i+0];
80 if (!isNaN(vals.selected))
81 sel.selectedIndex = vals.selected;
83 sel.parentNode.style.display = (sel.options.length <= 1) ? 'none' : '';
87 function cbi_toggle_wifi_mode(id)
89 cbi_toggle_wifi_htmode(id);
90 cbi_toggle_wifi_band(id);
93 function cbi_toggle_wifi_htmode(id)
95 var mode = document.getElementById(id + '.mode');
96 var bwdt = document.getElementById(id + '.htmode');
98 cbi_set_values(bwdt, htmodes[mode.value]);
101 function cbi_toggle_wifi_band(id)
103 var mode = document.getElementById(id + '.mode');
104 var band = document.getElementById(id + '.band');
106 cbi_set_values(band, bands[mode.value]);
107 cbi_toggle_wifi_channel(id);
110 function cbi_toggle_wifi_channel(id)
112 var band = document.getElementById(id + '.band');
113 var chan = document.getElementById(id + '.channel');
115 cbi_set_values(chan, channels[band.value]);
118 function cbi_init_wifi(id)
120 var mode = document.getElementById(id + '.mode');
121 var band = document.getElementById(id + '.band');
122 var chan = document.getElementById(id + '.channel');
123 var bwdt = document.getElementById(id + '.htmode');
125 cbi_set_values(mode, modes);
127 if (/VHT20|VHT40|VHT80|VHT160/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>))
129 else if (/HT20|HT40/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>))
134 cbi_toggle_wifi_mode(id);
136 if (/a/.test(<%= luci.http.write_json(self.map:get(section, "hwmode")) %>))
141 cbi_toggle_wifi_band(id);
143 bwdt.value = <%= luci.http.write_json(self.map:get(section, "htmode")) %>;
144 chan.value = <%= luci.http.write_json(self.map:get(section, "channel")) %>;
148 <label style="float:left; margin-right:3px">
150 <select style="width:auto" id="<%= cbid %>.mode" name="<%= cbid %>.mode" onchange="cbi_toggle_wifi_mode('<%= cbid %>')"></select>
152 <label style="float:left; margin-right:3px">
154 <select style="width:auto" id="<%= cbid %>.band" name="<%= cbid %>.band" onchange="cbi_toggle_wifi_band('<%= cbid %>')"></select>
156 <label style="float:left; margin-right:3px">
158 <select style="width:auto" id="<%= cbid %>.channel" name="<%= cbid %>.channel"></select>
160 <label style="float:left; margin-right:3px">
162 <select style="width:auto" id="<%= cbid %>.htmode" name="<%= cbid %>.htmode"></select>
164 <br style="clear:left" />
166 <script type="text/javascript">cbi_init_wifi('<%= cbid %>');</script>