3 <script type=
"text/javascript">//<![CDATA[
4 var freqlist = <%= luci.http.write_json(self.iwinfo.freqlist) %
>;
5 var hwmodes = <%= luci.http.write_json(self.iwinfo.hwmodelist or {}) %
>;
6 var htmodes = <%= luci.http.write_json(self.iwinfo.htmodelist) %
>;
7 var acs = <%= luci.http.write_json(self.hostapd_acs or
0) %
>;
19 channels[(freqlist[freqlist.length -
1].mhz
> 2484) ? '
11a' : '
11g'].length =
0;
22 for (var i =
0; i < freqlist.length; i++)
23 channels[(freqlist[i].mhz
> 2484) ? '
11a' : '
11g'].push(
25 '%d (%d MHz)'.format(freqlist[i].channel, freqlist[i].mhz),
26 !freqlist[i].restricted
32 'ac', 'AC', hwmodes.ac
40 'HT20', '
20 MHz', htmodes.HT20,
41 'HT40', '
40 MHz', htmodes.HT40
44 'VHT20', '
20 MHz', htmodes.VHT20,
45 'VHT40', '
40 MHz', htmodes.VHT40,
46 'VHT80', '
80 MHz', htmodes.VHT80,
47 'VHT160', '
160 MHz', htmodes.VHT160
53 '
11g', '
2.4 GHz', (channels['
11g'].length
> 3),
54 '
11a', '
5 GHz', (channels['
11a'].length
> 3)
57 '
11g', '
2.4 GHz', (channels['
11g'].length
> 3),
58 '
11a', '
5 GHz', (channels['
11a'].length
> 3)
65 function cbi_set_values(sel, vals)
68 sel.vals.selected = sel.selectedIndex;
70 while (sel.options[
0])
73 for (var i =
0; vals && i < vals.length; i +=
3)
78 var opt = document.createElement('option');
79 opt.value = vals[i+
0];
85 if (!isNaN(vals.selected))
86 sel.selectedIndex = vals.selected;
88 sel.parentNode.style.display = (sel.options.length <=
1) ? 'none' : '';
92 function cbi_toggle_wifi_mode(id)
94 cbi_toggle_wifi_htmode(id);
95 cbi_toggle_wifi_band(id);
98 function cbi_toggle_wifi_htmode(id)
100 var mode = document.getElementById(id + '.mode');
101 var bwdt = document.getElementById(id + '.htmode');
103 cbi_set_values(bwdt, htmodes[mode.value]);
106 function cbi_toggle_wifi_band(id)
108 var mode = document.getElementById(id + '.mode');
109 var band = document.getElementById(id + '.band');
111 cbi_set_values(band, bands[mode.value]);
112 cbi_toggle_wifi_channel(id);
115 function cbi_toggle_wifi_channel(id)
117 var band = document.getElementById(id + '.band');
118 var chan = document.getElementById(id + '.channel');
120 cbi_set_values(chan, channels[band.value]);
123 function cbi_init_wifi(id)
125 var mode = document.getElementById(id + '.mode');
126 var band = document.getElementById(id + '.band');
127 var chan = document.getElementById(id + '.channel');
128 var bwdt = document.getElementById(id + '.htmode');
130 cbi_set_values(mode, modes);
132 if (/VHT20|VHT40|VHT80|VHT160/.test(<%= luci.http.write_json(self.map:get(section,
"htmode")) %
>))
134 else if (/HT20|HT40/.test(<%= luci.http.write_json(self.map:get(section,
"htmode")) %
>))
139 cbi_toggle_wifi_mode(id);
141 if (/a/.test(<%= luci.http.write_json(self.map:get(section,
"hwmode")) %
>))
146 cbi_toggle_wifi_band(id);
148 bwdt.value = <%= luci.http.write_json(self.map:get(section,
"htmode")) %
>;
149 chan.value = <%= luci.http.write_json(self.map:get(section,
"channel")) %
>;
153 <label style=
"float:left; margin-right:3px">
155 <select style=
"width:auto" id=
"<%= cbid %>.mode" name=
"<%= cbid %>.mode" onchange=
"cbi_toggle_wifi_mode('<%= cbid %>')"></select>
157 <label style=
"float:left; margin-right:3px">
159 <select style=
"width:auto" id=
"<%= cbid %>.band" name=
"<%= cbid %>.band" onchange=
"cbi_toggle_wifi_band('<%= cbid %>')"></select>
161 <label style=
"float:left; margin-right:3px">
163 <select style=
"width:auto" id=
"<%= cbid %>.channel" name=
"<%= cbid %>.channel"></select>
165 <label style=
"float:left; margin-right:3px">
167 <select style=
"width:auto" id=
"<%= cbid %>.htmode" name=
"<%= cbid %>.htmode"></select>
169 <br style=
"clear:left" />
171 <script type=
"text/javascript">cbi_init_wifi('<%= cbid %
>');
</script>