modules/admin-full: more javascript fixes
[project/luci.git] / modules / admin-full / luasrc / view / admin_network / wifi_status.htm
index e4ba48277063c6212099227006b7b3f00680b4fd..76635bf70230c02447ecbe88a09f4db3fc4e0a45 100644 (file)
@@ -1,15 +1,18 @@
 <%+cbi/valueheader%>
 
-<script type="text/javascript"><![CDATA[
+<script type="text/javascript">//<![CDATA[
        var iwxhr = new XHR();
-       var update_status = function() {
+
+       (function() {
+               var func = arguments.callee;
+
                iwxhr.get('<%=luci.dispatcher.build_url("admin", "network", "wireless_status", self.ifname)%>', null,
                        function(x, iw)
                        {
                                if (iw && (iw = iw[0]))
                                {
-                                       var is_assoc = (iw.bssid && iw.channel);
-                                       var p = (100 / iw.quality_max * iw.quality);
+                                       var is_assoc = (iw.bssid && iw.bssid != '00:00:00:00:00:00' && iw.channel);
+                                       var p = iw.quality;
                                        var q = is_assoc ? p : -1;
 
                                        var icon;
@@ -37,7 +40,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) | ' +
                                                        '<strong><%:Bit Rate%>:</strong> %.1f MBit/s | ' +
                                                        '<strong><%:Country%>:</strong> %s',
                                                                iw.mode, iw.ssid, iw.bssid,
-                                                               iw.encryption ? iw.encryption.description : '<%:None%>',
-                                                               iw.channel, iw.frequency ? (iw.frequency / 1000) : 0,
+                                                               iw.encryption ? iw.encryption : '<%:None%>',
+                                                               iw.channel, iw.frequency ? iw.frequency : 0,
                                                                iw.txpower, iw.signal, iw.noise,
-                                                               iw.bitrate ? (iw.bitrate / 1000) : 0, iw.country
+                                                               iw.bitrate ? iw.bitrate : 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(func, 5000);
                        }
                )
-       };
-
-       update_status();
-]]></script>
+       })();
+//]]></script>
 
 <table>
        <tr class="cbi-section-table">