Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var NetworkUI = (function() { | 5 var NetworkUI = (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 // Properties to display in the network state table. Each entry can be either | 8 // Properties to display in the network state table. Each entry can be either |
| 9 // a single state field or an array of state fields. If more than one is | 9 // a single state field or an array of state fields. If more than one is |
| 10 // specified then the first non empty value is used. | 10 // specified then the first non empty value is used. |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 {'networkType': chrome.networkingPrivate.NetworkType.ALL, | 307 {'networkType': chrome.networkingPrivate.NetworkType.ALL, |
| 308 'visible': true}, | 308 'visible': true}, |
| 309 onVisibleNetworksReceived); | 309 onVisibleNetworksReceived); |
| 310 chrome.networkingPrivate.getNetworks( | 310 chrome.networkingPrivate.getNetworks( |
| 311 {'networkType': chrome.networkingPrivate.NetworkType.ALL, | 311 {'networkType': chrome.networkingPrivate.NetworkType.ALL, |
| 312 'configured': true}, | 312 'configured': true}, |
| 313 onFavoriteNetworksReceived); | 313 onFavoriteNetworksReceived); |
| 314 }; | 314 }; |
| 315 | 315 |
| 316 /** | 316 /** |
| 317 * Requests the global policy dictionary and updates the page. | |
| 318 */ | |
| 319 var requestGlobalPolicy = function() { | |
| 320 chrome.networkingPrivate.getGlobalPolicy(function(policy) { | |
| 321 document.querySelector('#global-policy').textContent = | |
|
Devlin
2017/01/10 15:25:21
Why document.querySelector('#foo') instead of $('f
stevenjb
2017/01/10 17:49:39
No particular reason, I just copied from somewhere
Devlin
2017/01/10 18:43:06
AFAIK, we still use $ liberally. It's also shorte
stevenjb
2017/01/10 18:58:29
I didn't mean to suggest that $ wasn't. We also ho
| |
| 322 JSON.stringify(policy); | |
| 323 }); | |
| 324 }; | |
| 325 | |
| 326 /** | |
| 317 * Sets refresh rate if the interval is found in the url. | 327 * Sets refresh rate if the interval is found in the url. |
| 318 */ | 328 */ |
| 319 var setRefresh = function() { | 329 var setRefresh = function() { |
| 320 var interval = parseQueryParams(window.location)['refresh']; | 330 var interval = parseQueryParams(window.location)['refresh']; |
| 321 if (interval && interval != '') | 331 if (interval && interval != '') |
| 322 setInterval(requestNetworks, parseInt(interval, 10) * 1000); | 332 setInterval(requestNetworks, parseInt(interval, 10) * 1000); |
| 323 }; | 333 }; |
| 324 | 334 |
| 325 /** | 335 /** |
| 326 * Gets network information from WebUI and sets custom items. | 336 * Gets network information from WebUI and sets custom items. |
| 327 */ | 337 */ |
| 328 document.addEventListener('DOMContentLoaded', function() { | 338 document.addEventListener('DOMContentLoaded', function() { |
| 329 let select = document.querySelector('cr-network-select'); | 339 let select = document.querySelector('cr-network-select'); |
| 330 select.customItems = [ | 340 select.customItems = [ |
| 331 {customItemName: 'Add WiFi', polymerIcon: 'cr:add', customData: 'WiFi'}, | 341 {customItemName: 'Add WiFi', polymerIcon: 'cr:add', customData: 'WiFi'}, |
| 332 {customItemName: 'Add VPN', polymerIcon: 'cr:add', customData: 'VPN'} | 342 {customItemName: 'Add VPN', polymerIcon: 'cr:add', customData: 'VPN'} |
| 333 ]; | 343 ]; |
| 334 $('refresh').onclick = requestNetworks; | 344 $('refresh').onclick = requestNetworks; |
| 335 setRefresh(); | 345 setRefresh(); |
| 336 requestNetworks(); | 346 requestNetworks(); |
| 347 requestGlobalPolicy(); | |
| 337 }); | 348 }); |
| 338 | 349 |
| 339 document.addEventListener('custom-item-selected', function(event) { | 350 document.addEventListener('custom-item-selected', function(event) { |
| 340 chrome.send('addNetwork', [event.detail.customData]); | 351 chrome.send('addNetwork', [event.detail.customData]); |
| 341 }); | 352 }); |
| 342 | 353 |
| 343 return { | 354 return { |
| 344 getShillPropertiesResult: getShillPropertiesResult | 355 getShillPropertiesResult: getShillPropertiesResult |
| 345 }; | 356 }; |
| 346 })(); | 357 })(); |
| OLD | NEW |