wireless_modefreq.htm 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <%+cbi/valueheader%>
  2. <script type="text/javascript">//<![CDATA[
  3. var freqlist = <%= luci.http.write_json(self.iwinfo.freqlist) %>;
  4. var hwmodes = <%= luci.http.write_json(self.iwinfo.hwmodelist or {}) %>;
  5. var htmodes = <%= luci.http.write_json(self.iwinfo.htmodelist) %>;
  6. var acs = <%= luci.http.write_json(self.hostapd_acs or 0) %>;
  7. var channels = {
  8. '11g': [
  9. 'auto', 'auto', true
  10. ],
  11. '11a': [
  12. 'auto', 'auto', true
  13. ]
  14. };
  15. if (acs < 1) {
  16. channels[(freqlist[freqlist.length - 1].mhz > 2484) ? '11a' : '11g'].length = 0;
  17. }
  18. for (var i = 0; i < freqlist.length; i++)
  19. channels[(freqlist[i].mhz > 2484) ? '11a' : '11g'].push(
  20. freqlist[i].channel,
  21. '%d (%d MHz)'.format(freqlist[i].channel, freqlist[i].mhz),
  22. !freqlist[i].restricted
  23. );
  24. var modes = [
  25. '', 'Legacy', true,
  26. 'n', 'N', hwmodes.n,
  27. 'ac', 'AC', hwmodes.ac,
  28. 'ax', 'AX', hwmodes.ax,
  29. 'be', 'BE', hwmodes.be
  30. ];
  31. var htmodes = {
  32. '': [
  33. '', '-', true
  34. ],
  35. 'n': [
  36. 'HT20', '20 MHz', htmodes.HT20,
  37. 'HT40', '40 MHz', htmodes.HT40
  38. ],
  39. 'ac': [
  40. 'VHT20', '20 MHz', htmodes.VHT20,
  41. 'VHT40', '40 MHz', htmodes.VHT40,
  42. 'VHT80', '80 MHz', htmodes.VHT80,
  43. 'VHT160', '160 MHz', htmodes.VHT160
  44. ],
  45. 'ax': [
  46. 'HE20', '20 MHz', htmodes.HE20,
  47. 'HE40', '40 MHz', htmodes.HE40,
  48. 'HE80', '80 MHz', htmodes.HE80,
  49. 'HE160', '160 MHz', htmodes.HE160
  50. ],
  51. 'be': [
  52. 'EHT20', '20 MHz', htmodes.EHT20,
  53. 'EHT40', '40 MHz', htmodes.EHT40,
  54. 'EHT80', '80 MHz', htmodes.EHT80,
  55. 'EHT160', '160 MHz', htmodes.EHT160,
  56. 'EHT320', '320 MHz', htmodes.EHT320
  57. ]
  58. };
  59. var bands = {
  60. '': [
  61. '11g', '2.4 GHz', (channels['11g'].length > 3),
  62. '11a', '5 GHz', (channels['11a'].length > 3)
  63. ],
  64. 'n': [
  65. '11g', '2.4 GHz', (channels['11g'].length > 3),
  66. '11a', '5 GHz', (channels['11a'].length > 3)
  67. ],
  68. 'ac': [
  69. '11a', '5 GHz', true
  70. ],
  71. 'ax': [
  72. '11a', '2 GHz', true,
  73. '11a', '5 GHz', true
  74. ],
  75. 'be': [
  76. '11a', '2 GHz', true,
  77. '11a', '5 GHz', true,
  78. '11a', '6 GHz', true
  79. ]
  80. };
  81. function cbi_set_values(sel, vals)
  82. {
  83. if (sel.vals)
  84. sel.vals.selected = sel.selectedIndex;
  85. while (sel.options[0])
  86. sel.remove(0);
  87. for (var i = 0; vals && i < vals.length; i += 3)
  88. {
  89. if (!vals[i+2])
  90. continue;
  91. var opt = document.createElement('option');
  92. opt.value = vals[i+0];
  93. opt.text = vals[i+1];
  94. sel.add(opt);
  95. }
  96. if (!isNaN(vals.selected))
  97. sel.selectedIndex = vals.selected;
  98. sel.parentNode.style.display = (sel.options.length <= 1) ? 'none' : '';
  99. sel.vals = vals;
  100. }
  101. function cbi_toggle_wifi_mode(id)
  102. {
  103. cbi_toggle_wifi_htmode(id);
  104. cbi_toggle_wifi_band(id);
  105. }
  106. function cbi_toggle_wifi_htmode(id)
  107. {
  108. var mode = document.getElementById(id + '.mode');
  109. var bwdt = document.getElementById(id + '.htmode');
  110. cbi_set_values(bwdt, htmodes[mode.value]);
  111. }
  112. function cbi_toggle_wifi_band(id)
  113. {
  114. var mode = document.getElementById(id + '.mode');
  115. var band = document.getElementById(id + '.band');
  116. cbi_set_values(band, bands[mode.value]);
  117. cbi_toggle_wifi_channel(id);
  118. }
  119. function cbi_toggle_wifi_channel(id)
  120. {
  121. var band = document.getElementById(id + '.band');
  122. var chan = document.getElementById(id + '.channel');
  123. cbi_set_values(chan, channels[band.value]);
  124. }
  125. function cbi_init_wifi(id)
  126. {
  127. var mode = document.getElementById(id + '.mode');
  128. var band = document.getElementById(id + '.band');
  129. var chan = document.getElementById(id + '.channel');
  130. var bwdt = document.getElementById(id + '.htmode');
  131. cbi_set_values(mode, modes);
  132. if (/EHT20|EHT40|EHT80|EHT160|EHT320/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>))
  133. mode.value = 'be';
  134. else if (/HE20|HE40|HE80|HE160/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>))
  135. mode.value = 'ax';
  136. else if (/VHT20|VHT40|VHT80|VHT160/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>))
  137. mode.value = 'ac';
  138. else if (/HT20|HT40/.test(<%= luci.http.write_json(self.map:get(section, "htmode")) %>))
  139. mode.value = 'n';
  140. else
  141. mode.value = '';
  142. cbi_toggle_wifi_mode(id);
  143. if (/a/.test(<%= luci.http.write_json(self.map:get(section, "hwmode")) %>))
  144. band.value = '11a';
  145. else
  146. band.value = '11g';
  147. 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")) %>;
  150. }
  151. //]]></script>
  152. <label style="float:left; margin-right:3px">
  153. <%:Mode%><br />
  154. <select style="width:auto" id="<%= cbid %>.mode" name="<%= cbid %>.mode" onchange="cbi_toggle_wifi_mode('<%= cbid %>')"></select>
  155. </label>
  156. <label style="float:left; margin-right:3px">
  157. <%:Band%><br />
  158. <select style="width:auto" id="<%= cbid %>.band" name="<%= cbid %>.band" onchange="cbi_toggle_wifi_band('<%= cbid %>')"></select>
  159. </label>
  160. <label style="float:left; margin-right:3px">
  161. <%:Channel%><br />
  162. <select style="width:auto" id="<%= cbid %>.channel" name="<%= cbid %>.channel"></select>
  163. </label>
  164. <label style="float:left; margin-right:3px">
  165. <%:Width%><br />
  166. <select style="width:auto" id="<%= cbid %>.htmode" name="<%= cbid %>.htmode"></select>
  167. </label>
  168. <br style="clear:left" />
  169. <script type="text/javascript">cbi_init_wifi('<%= cbid %>');</script>
  170. <%+cbi/valuefooter%>