wifi_status.htm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <%+cbi/valueheader%>
  2. <script type="text/javascript">//<![CDATA[
  3. XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "network", "wireless_status", self.ifname)%>', null,
  4. function(x, iw)
  5. {
  6. if (iw && (iw = iw[0]))
  7. {
  8. var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel && !iw.disabled);
  9. var p = iw.quality;
  10. var q = is_assoc ? p : -1;
  11. var icon;
  12. if (q < 0)
  13. icon = "<%=resource%>/icons/signal-none.png";
  14. else if (q == 0)
  15. icon = "<%=resource%>/icons/signal-0.png";
  16. else if (q < 25)
  17. icon = "<%=resource%>/icons/signal-0-25.png";
  18. else if (q < 50)
  19. icon = "<%=resource%>/icons/signal-25-50.png";
  20. else if (q < 75)
  21. icon = "<%=resource%>/icons/signal-50-75.png";
  22. else
  23. icon = "<%=resource%>/icons/signal-75-100.png";
  24. var s = document.getElementById('<%=self.option%>-iw-signal');
  25. if (s)
  26. s.innerHTML = String.format(
  27. '<img src="%s" title="<%:Signal%>: %d <%:dBm%> / <%:Noise%>: %d <%:dBm%>" /><br />' +
  28. '<small>%d%%</small>', icon, iw.signal, iw.noise, p
  29. );
  30. var d = document.getElementById('<%=self.option%>-iw-description');
  31. if (d && is_assoc)
  32. d.innerHTML = String.format(
  33. '<strong><%:Mode%>:</strong> %s | ' +
  34. '<strong><%:SSID%>:</strong> %h<br />' +
  35. '<strong><%:BSSID%>:</strong> %s | ' +
  36. '<strong><%:Encryption%>:</strong> %s<br />' +
  37. '<strong><%:Channel%>:</strong> %d (%.3f <%:GHz%>) | ' +
  38. '<strong><%:Tx-Power%>:</strong> %d <%:dBm%><br />' +
  39. '<strong><%:Signal%>:</strong> %d <%:dBm%> | ' +
  40. '<strong><%:Noise%>:</strong> %d <%:dBm%><br />' +
  41. '<strong><%:Bitrate%>:</strong> %.1f <%:Mbit/s%> | ' +
  42. '<strong><%:Country%>:</strong> %s',
  43. iw.mode, iw.ssid, iw.bssid,
  44. iw.encryption ? iw.encryption : '<%:None%>',
  45. iw.channel, iw.frequency ? iw.frequency : 0,
  46. iw.txpower, iw.signal, iw.noise,
  47. iw.bitrate ? iw.bitrate : 0, iw.country
  48. );
  49. else if (d)
  50. d.innerHTML = String.format(
  51. '<strong><%:SSID%>:</strong> %h | ' +
  52. '<strong><%:Mode%>:</strong> %s<br />' +
  53. '<em><%:Wireless is disabled or not associated%></em>',
  54. iw.ssid || '?', iw.mode
  55. );
  56. }
  57. }
  58. );
  59. //]]></script>
  60. <table>
  61. <tr class="cbi-section-table">
  62. <td></td>
  63. <td class="cbi-value-field" style="width:16px; padding:3px" id="<%=self.option%>-iw-signal">
  64. <img src="<%=resource%>/icons/signal-none.png" title="<%:Not associated%>" /><br />
  65. <small>0%</small>
  66. </td>
  67. <td class="cbi-value-field" style="vertical-align:middle; text-align:left; padding:3px" id="<%=self.option%>-iw-description">
  68. <em><%:Collecting data...%></em>
  69. </td>
  70. </tr>
  71. </table>
  72. <%+cbi/valuefooter%>