3 <script type="text/javascript">//<![CDATA[
4 var freqlist = <%= luci.http.write_json(self.freqlist) %>;
5 var hwmodes = <%= luci.http.write_json(self.hwmodes) %>;
16 for (var i = 0; i < freqlist.length; i++)
17 channels[(freqlist[i].mhz > 2484) ? '11a' : '11g'].push(
19 '%d (%d MHz)'.format(freqlist[i].channel, freqlist[i].mhz),
20 !freqlist[i].restricted
26 'ac', 'AC', hwmodes.ac
34 'HT20', '20 MHz', true,
35 'HT40', '40 MHz', true
38 'VHT20', '20 MHz', true,
39 'VHT40', '40 MHz', true,
40 'VHT80', '80 MHz', true,
41 'VHT160', '160 MHz', true
47 '11g', '2.4 GHz', (channels['11g'].length > 3),
48 '11a', '5 GHz', (channels['11a'].length > 3)
51 '11g', '2.4 GHz', (channels['11g'].length > 3),
52 '11a', '5 GHz', (channels['11a'].length > 3)
59 function cbi_set_values(sel, vals)
62 sel.vals.selected = sel.selectedIndex;
64 while (sel.options[0])
67 for (var i = 0; vals && i < vals.length; i += 3)
72 var opt = document.createElement('option');
73 opt.value = vals[i+0];
79 if (!isNaN(vals.selected))
80 sel.selectedIndex = vals.selected;
82 sel.parentNode.style.display = (sel.options.length <= 1) ? 'none' : '';
86 function cbi_toggle_wifi_mode(id)
88 cbi_toggle_wifi_htmode(id);
89 cbi_toggle_wifi_band(id);
92 function cbi_toggle_wifi_htmode(id)
94 var mode = document.getElementById(id + '.mode');
95 var bwdt = document.getElementById(id + '.htmode');
97 cbi_set_values(bwdt, htmodes[mode.value]);
100 function cbi_toggle_wifi_band(id)
102 var mode = document.getElementById(id + '.mode');
103 var band = document.getElementById(id + '.band');
105 cbi_set_values(band, bands[mode.value]);
106 cbi_toggle_wifi_channel(id);
109 function cbi_toggle_wifi_channel(id)
111 var band = document.getElementById(id + '.band');
112 var chan = document.getElementById(id + '.channel');
114 cbi_set_values(chan, channels[band.value]);
117 function cbi_init_wifi(id)
119 var mode = document.getElementById(id + '.mode');
120 var band = document.getElementById(id + '.band');
121 var chan = document.getElementById(id + '.channel');
122 var bwdt = document.getElementById(id + '.htmode');
124 cbi_set_values(mode, modes);
126 if (/VHT20|VHT40|VHT80|VHT160/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>))
128 else if (/HT20|HT40/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>))
133 cbi_toggle_wifi_mode(id);
135 if (/a/.test(<%= luci.http.write_json(self.map:get(section, "hwmode")) %>))
140 cbi_toggle_wifi_band(id);
142 bwdt.value = <%= luci.http.write_json(self.map:get(section, "htmode")) %>;
143 chan.value = <%= luci.http.write_json(self.map:get(section, "channel")) %>;
147 <label style="float:left; margin-right:3px">
149 <select style="width:auto" id="<%= cbid %>.mode" name="<%= cbid %>.mode" onchange="cbi_toggle_wifi_mode('<%= cbid %>')"></select>
151 <label style="float:left; margin-right:3px">
153 <select style="width:auto" id="<%= cbid %>.band" name="<%= cbid %>.band" onchange="cbi_toggle_wifi_band('<%= cbid %>')"></select>
155 <label style="float:left; margin-right:3px">
157 <select style="width:auto" id="<%= cbid %>.channel" name="<%= cbid %>.channel"></select>
159 <label style="float:left; margin-right:3px">
161 <select style="width:auto" id="<%= cbid %>.htmode" name="<%= cbid %>.htmode"></select>
163 <br style="clear:left" />
165 <script type="text/javascript">cbi_init_wifi('<%= cbid %>');</script>