| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 function showMessage(msg) { | 5 function showMessage(msg) { |
| 6 var area = $('message-area'); | 6 var area = $('message-area'); |
| 7 var entry = document.createElement('div'); | 7 var entry = document.createElement('div'); |
| 8 entry.textContent = msg; | 8 entry.textContent = msg; |
| 9 area.appendChild(entry); | 9 area.appendChild(entry); |
| 10 window.setTimeout(function() { | 10 window.setTimeout(function() { |
| 11 area.removeChild(entry); | 11 area.removeChild(entry); |
| 12 }, 3000); | 12 }, 3000); |
| 13 } | 13 } |
| 14 | 14 |
| 15 function getShowMessageCallback(message) { |
| 16 return function() { |
| 17 var error = chrome.runtime.lastError; |
| 18 if (error) { |
| 19 showMessage(message + ': ' + error.message); |
| 20 } else { |
| 21 showMessage(message + ': Success!'); |
| 22 } |
| 23 }; |
| 24 } |
| 25 |
| 15 function onPageLoad() { | 26 function onPageLoad() { |
| 16 var networkConfig = $('network-config'); | 27 var networkConfig = $('network-config'); |
| 17 network.config.NetworkConfig.decorate(networkConfig); | 28 network.config.NetworkConfig.decorate(networkConfig); |
| 18 | 29 |
| 19 $('close').onclick = function() { | 30 $('save').onclick = function() { |
| 20 networkConfig.applyUserSettings(); | 31 chrome.networkingPrivate.setProperties( |
| 32 networkConfig.networkId, |
| 33 networkConfig.userSettings, |
| 34 getShowMessageCallback('Set properties of ' + networkConfig.networkId)); |
| 21 }; | 35 }; |
| 22 | 36 |
| 23 $('connect').onclick = function() { | 37 $('connect').onclick = function() { |
| 24 chrome.networkingPrivate.startConnect( | 38 chrome.networkingPrivate.startConnect( |
| 25 networkConfig.networkId, | 39 networkConfig.networkId, |
| 26 function() { | 40 getShowMessageCallback( |
| 27 showMessage('Successfully requested connect to ' + | 41 'Requested connect to ' + networkConfig.networkId)); |
| 28 networkConfig.networkId + '!'); | |
| 29 }); | |
| 30 }; | 42 }; |
| 31 | 43 |
| 32 $('disconnect').onclick = function() { | 44 $('disconnect').onclick = function() { |
| 33 chrome.networkingPrivate.startDisconnect( | 45 chrome.networkingPrivate.startDisconnect( |
| 34 networkConfig.networkId, | 46 networkConfig.networkId, |
| 35 function() { | 47 getShowMessageCallback( |
| 36 showMessage('Successfully requested disconnect from ' + | 48 'Requested disconnect from ' + networkConfig.networkId)); |
| 37 networkConfig.networkId + '!'); | |
| 38 }); | |
| 39 }; | 49 }; |
| 40 } | 50 } |
| 41 | 51 |
| 42 document.addEventListener('DOMContentLoaded', onPageLoad); | 52 document.addEventListener('DOMContentLoaded', onPageLoad); |
| OLD | NEW |