Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 /** | |
| 6 * Updates the Connectivity Status section. | |
| 7 * @param {String} connStatus Dictionary containing connectivity status. | |
| 8 */ | |
| 9 function updateConnectivityStatus(connStatus) { | |
| 10 var deviceTypes = ['wlan0', 'wwan0', 'eth0', 'eth1']; | |
| 11 var deviceNames = ['Wi-Fi', '3G', 'Ethernet0', 'Ethernet1']; | |
| 12 for (var i = 0; i < deviceTypes.length; i++) { | |
| 13 var deviceName = deviceNames[i]; | |
| 14 var name_element = document.createElement('h2'); | |
|
James Hawkins
2012/08/06 16:05:39
s/name_element/nameElement/
Here and elsewhere.
hshi1
2012/08/06 17:30:55
Done.
| |
| 15 name_element.appendChild(document.createTextNode(deviceName)); | |
| 16 $('connectivity-status').appendChild(name_element); | |
| 17 | |
| 18 var deviceType = deviceTypes[i]; | |
| 19 var deviceStatus = connStatus[deviceType]; | |
| 20 var statusMessage; | |
| 21 if (typeof deviceStatus == 'undefined') { | |
| 22 statusMessage = 'Device not found.'; | |
| 23 } else if (typeof deviceStatus.flags == 'undefined' || | |
|
James Hawkins
2012/08/06 16:05:39
Just use !deviceStatus.flags.
hshi1
2012/08/06 17:30:55
Done.
| |
| 24 deviceStatus.flags.indexOf('up') == -1) { | |
| 25 statusMessage = 'Device disabled.'; | |
| 26 } else if (typeof deviceStatus.ipv4 == 'undefined') { | |
| 27 statusMessage = 'IPv4 address unavailable.'; | |
| 28 } else { | |
| 29 statusMessage = 'IPv4 address: ' + deviceStatus.ipv4.addrs; | |
| 30 } | |
| 31 var status_element = document.createElement('p'); | |
| 32 status_element.appendChild(document.createTextNode(statusMessage)); | |
| 33 $('connectivity-status').appendChild(status_element); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 document.addEventListener('DOMContentLoaded', function() { | |
| 38 chrome.send('pageLoaded'); | |
| 39 }); | |
| OLD | NEW |