modules/admin-full: rework wifi status templates
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / wifi_status.htm
index 8c50843..ba99acf 100644 (file)
@@ -1,12 +1,11 @@
 <%+cbi/valueheader%>
 
-<script type="text/javascript"><![CDATA[
+<script type="text/javascript">//<![CDATA[
        var iwxhr = new XHR();
-       (function() {
+       var update_status = function() {
                iwxhr.get('<%=luci.dispatcher.build_url("admin", "network", "wireless_status", self.ifname)%>', null,
-                       function(x)
+                       function(x, iw)
                        {
-                               var iw = x.responseText ? eval('(' + x.responseText + ')') : null;
                                if (iw && (iw = iw[0]))
                                {
                                        var is_assoc = (iw.bssid && iw.channel);
@@ -30,7 +29,7 @@
                                        var s = document.getElementById('<%=self.option%>-iw-signal');
                                        if (s)
                                                s.innerHTML = String.format(
-                                                       '<img src="%s" title="<%:Signal%>: %d dBm / <%Noise%>: %d dBm" /><br />' +
+                                                       '<img src="%s" title="<%:Signal%>: %d dBm / <%:Noise%>: %d dBm" /><br />' +
                                                        '<small>%d%%</small>', icon, iw.signal, iw.noise, p
                                                );
 
@@ -38,7 +37,7 @@
                                        if (d && is_assoc)
                                                d.innerHTML = String.format(
                                                        '<strong><%:Mode%>:</strong> %s | ' +
-                                                       '<strong><%:SSID%>:</strong> %s<br />' +
+                                                       '<strong><%:SSID%>:</strong> %h<br />' +
                                                        '<strong><%:BSSID%>:</strong> %s | ' +
                                                        '<strong><%:Encryption%>:</strong> %s<br />' +
                                                        '<strong><%:Channel%>:</strong> %d (%.3f GHz) | ' +
                                                                iw.bitrate ? (iw.bitrate / 1000) : 0, iw.country
                                                );
                                        else if (d)
-                                               d.innerHTML = '<%:Wireless is disabled or not associated%>';
+                                               d.innerHTML = String.format(
+                                                       '<strong><%:SSID%>:</strong> %h | ' +
+                                                       '<strong><%:Mode%>:</strong> %s<br />' +
+                                                       '<em><%:Wireless is disabled or not associated%></em>',
+                                                               iw.ssid || '?', iw.mode
+                                               );
                                }
+
+                               window.setTimeout(update_status, 5000);
                        }
                )
+       };
 
-               window.setTimeout(arguments.callee, 5000);
-       })();
-]]></script>
+       update_status();
+//]]></script>
 
 <table>
        <tr class="cbi-section-table">