| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 cr.define('options', function() { | 5 cr.define('options', function() { |
| 6 var OptionsPage = options.OptionsPage; | 6 var OptionsPage = options.OptionsPage; |
| 7 | 7 |
| 8 ///////////////////////////////////////////////////////////////////////////// | 8 ///////////////////////////////////////////////////////////////////////////// |
| 9 // InternetOptions class: | 9 // InternetOptions class: |
| 10 | 10 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 $('wiredSection').hidden = (templateData.wiredList.length == 0); | 47 $('wiredSection').hidden = (templateData.wiredList.length == 0); |
| 48 $('wirelessSection').hidden = (templateData.wirelessList.length == 0); | 48 $('wirelessSection').hidden = (templateData.wirelessList.length == 0); |
| 49 $('rememberedSection').hidden = (templateData.rememberedList.length == 0); | 49 $('rememberedSection').hidden = (templateData.rememberedList.length == 0); |
| 50 InternetOptions.setupAttributes(templateData); | 50 InternetOptions.setupAttributes(templateData); |
| 51 $('detailsInternetDismiss').addEventListener('click', function(event) { | 51 $('detailsInternetDismiss').addEventListener('click', function(event) { |
| 52 OptionsPage.closeOverlay(); | 52 OptionsPage.closeOverlay(); |
| 53 }); | 53 }); |
| 54 $('detailsInternetLogin').addEventListener('click', function(event) { | 54 $('detailsInternetLogin').addEventListener('click', function(event) { |
| 55 InternetOptions.loginFromDetails(); | 55 InternetOptions.loginFromDetails(); |
| 56 });; | 56 }); |
| 57 $('activateDetails').addEventListener('click', function(event) { | 57 $('activateDetails').addEventListener('click', function(event) { |
| 58 InternetOptions.activateFromDetails(); | 58 InternetOptions.activateFromDetails(); |
| 59 }); | 59 }); |
| 60 $('enableWifi').addEventListener('click', function(event) { | 60 $('enableWifi').addEventListener('click', function(event) { |
| 61 event.target.disabled = true; | 61 event.target.disabled = true; |
| 62 chrome.send('enableWifi', []); | 62 chrome.send('enableWifi', []); |
| 63 }); | 63 }); |
| 64 $('disableWifi').addEventListener('click', function(event) { | 64 $('disableWifi').addEventListener('click', function(event) { |
| 65 event.target.disabled = true; | 65 event.target.disabled = true; |
| 66 chrome.send('disableWifi', []); | 66 chrome.send('disableWifi', []); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 var page = $('detailsInternetPage'); | 206 var page = $('detailsInternetPage'); |
| 207 page.removeAttribute('cellplanloading'); | 207 page.removeAttribute('cellplanloading'); |
| 208 if (data.plans && data.plans.length) { | 208 if (data.plans && data.plans.length) { |
| 209 page.removeAttribute('nocellplan'); | 209 page.removeAttribute('nocellplan'); |
| 210 page.setAttribute('hascellplan', true); | 210 page.setAttribute('hascellplan', true); |
| 211 $('planList').load(data.plans); | 211 $('planList').load(data.plans); |
| 212 } else { | 212 } else { |
| 213 page.setAttribute('nocellplan', true); | 213 page.setAttribute('nocellplan', true); |
| 214 page.removeAttribute('hascellplan'); | 214 page.removeAttribute('hascellplan'); |
| 215 } | 215 } |
| 216 if (!data.needsPlan) { | 216 |
| 217 if (!data.needsPlan) |
| 217 page.setAttribute('hasactiveplan', true); | 218 page.setAttribute('hasactiveplan', true); |
| 218 } else { | 219 else |
| 219 page.removeAttribute('hasactiveplan'); | 220 page.removeAttribute('hasactiveplan'); |
| 220 } | 221 |
| 221 if (data.activated) { | 222 if (data.activated) { |
| 222 page.setAttribute('activated', true); | 223 page.setAttribute('activated', true); |
| 223 } else { | 224 } else { |
| 224 page.removeAttribute('activated'); | 225 page.removeAttribute('activated'); |
| 226 $('detailsInternetLogin').classList.add('hidden'); |
| 225 } | 227 } |
| 226 | 228 |
| 229 // CSS selectors don't like me anymore, switching to classList |
| 230 if (data.showBuyButton) |
| 231 $('buyplanDetails').classList.remove('hidden'); |
| 232 else |
| 233 $('buyplanDetails').classList.add('hidden'); |
| 234 |
| 235 if (data.showActivateButton) |
| 236 $('activateDetails').classList.remove('hidden'); |
| 237 else |
| 238 $('activateDetails').classList.add('hidden'); |
| 239 |
| 227 // Nudge webkit so that it redraws the details overlay page. | 240 // Nudge webkit so that it redraws the details overlay page. |
| 228 // See http://crosbug.com/9616 for details. | 241 // See http://crosbug.com/9616 for details. |
| 229 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=50176 | 242 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=50176 |
| 230 var dummy = page.ownerDocument.createTextNode(' '); | 243 var dummy = page.ownerDocument.createTextNode(' '); |
| 231 page.appendChild(dummy); | 244 page.appendChild(dummy); |
| 232 page.removeChild(dummy); | 245 page.removeChild(dummy); |
| 233 }; | 246 }; |
| 234 | 247 |
| 235 InternetOptions.showPasswordEntry = function (data) { | 248 InternetOptions.showPasswordEntry = function (data) { |
| 236 var element = $(data.servicePath); | 249 var element = $(data.servicePath); |
| 237 element.showPassword(); | 250 element.showPassword(); |
| 238 }; | 251 }; |
| 239 | 252 |
| 240 InternetOptions.showDetailedInfo = function (data) { | 253 InternetOptions.showDetailedInfo = function (data) { |
| 241 var page = $('detailsInternetPage'); | 254 var page = $('detailsInternetPage'); |
| 242 if (data.connected) { | 255 $('buyplanDetails').classList.add('hidden'); |
| 243 $('inetTitle').textContent = localStrings.getString('inetStatus'); | 256 $('activateDetails').classList.add('hidden'); |
| 244 } else { | 257 $('detailsInternetLogin').classList.add('hidden'); |
| 245 $('inetTitle').textContent = localStrings.getString('inetConnect'); | |
| 246 } | |
| 247 if (data.connecting) { | 258 if (data.connecting) { |
| 248 page.setAttribute('connecting', data.connecting); | 259 page.setAttribute('connecting', data.connecting); |
| 249 } else { | 260 } else { |
| 250 page.removeAttribute('connecting'); | 261 page.removeAttribute('connecting'); |
| 251 } | 262 } |
| 252 if (data.connected) { | 263 if (data.connected) { |
| 253 page.setAttribute('connected', data.connected); | 264 page.setAttribute('connected', data.connected); |
| 265 $('inetTitle').textContent = localStrings.getString('inetStatus'); |
| 254 } else { | 266 } else { |
| 255 page.removeAttribute('connected'); | 267 page.removeAttribute('connected'); |
| 268 $('inetTitle').textContent = localStrings.getString('inetConnect'); |
| 269 $('detailsInternetLogin').classList.remove('hidden'); |
| 256 } | 270 } |
| 257 $('connectionState').textContent = data.connectionState; | 271 $('connectionState').textContent = data.connectionState; |
| 258 var address = $('inetAddress'); | 272 var address = $('inetAddress'); |
| 259 address.data = data; | 273 address.data = data; |
| 260 if (data.ipconfigs && data.ipconfigs.length) { | 274 if (data.ipconfigs && data.ipconfigs.length) { |
| 261 // We will be displaying only the first ipconfig info for now until we | 275 // We will be displaying only the first ipconfig info for now until we |
| 262 // start supporting multiple IP addresses per connection. | 276 // start supporting multiple IP addresses per connection. |
| 263 address.textContent = data.ipconfigs[0].address; | 277 address.textContent = data.ipconfigs[0].address; |
| 264 $('inetSubnetAddress').textContent = data.ipconfigs[0].subnetAddress; | 278 $('inetSubnetAddress').textContent = data.ipconfigs[0].subnetAddress; |
| 265 $('inetGateway').textContent = data.ipconfigs[0].gateway; | 279 $('inetGateway').textContent = data.ipconfigs[0].gateway; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 $('esn').textContent = data.esn; | 346 $('esn').textContent = data.esn; |
| 333 $('min').textContent = data.min; | 347 $('min').textContent = data.min; |
| 334 if (!data.gsm) { | 348 if (!data.gsm) { |
| 335 page.removeAttribute('gsm'); | 349 page.removeAttribute('gsm'); |
| 336 } else { | 350 } else { |
| 337 $('operatorName').textContent = data.operatorName; | 351 $('operatorName').textContent = data.operatorName; |
| 338 $('operatorCode').textContent = data.operatorCode; | 352 $('operatorCode').textContent = data.operatorCode; |
| 339 $('imsi').textContent = data.imsi; | 353 $('imsi').textContent = data.imsi; |
| 340 page.setAttribute('gsm', true); | 354 page.setAttribute('gsm', true); |
| 341 } | 355 } |
| 356 |
| 357 // CSS selectors don't like me anymore, switching to classList |
| 358 if (data.showBuyButton) |
| 359 $('buyplanDetails').classList.remove('hidden'); |
| 360 else |
| 361 $('buyplanDetails').classList.add('hidden'); |
| 362 |
| 363 if (data.showActivateButton) { |
| 364 $('activateDetails').classList.remove('hidden') |
| 365 $('detailsInternetLogin').classList.add('hidden'); |
| 366 } else { |
| 367 $('activateDetails').classList.add('hidden'); |
| 368 } |
| 369 |
| 342 page.removeAttribute('hascellplan'); | 370 page.removeAttribute('hascellplan'); |
| 343 if (data.connected) { | 371 if (data.connected) { |
| 344 page.removeAttribute('nocellplan'); | 372 page.removeAttribute('nocellplan'); |
| 345 page.setAttribute('cellplanloading', true); | 373 page.setAttribute('cellplanloading', true); |
| 346 chrome.send('refreshCellularPlan', [data.servicePath]) | 374 chrome.send('refreshCellularPlan', [data.servicePath]) |
| 347 } else { | 375 } else { |
| 348 page.setAttribute('nocellplan', true); | 376 page.setAttribute('nocellplan', true); |
| 349 page.removeAttribute('cellplanloading'); | 377 page.removeAttribute('cellplanloading'); |
| 350 } | 378 } |
| 351 } else { | 379 } else { |
| 352 OptionsPage.showTab($('internetNavTab')); | 380 OptionsPage.showTab($('internetNavTab')); |
| 353 page.setAttribute('ethernet', true); | 381 page.setAttribute('ethernet', true); |
| 354 page.removeAttribute('wireless'); | 382 page.removeAttribute('wireless'); |
| 355 page.removeAttribute('cert'); | 383 page.removeAttribute('cert'); |
| 356 page.removeAttribute('certPkcs'); | 384 page.removeAttribute('certPkcs'); |
| 357 page.removeAttribute('cellular'); | 385 page.removeAttribute('cellular'); |
| 358 page.removeAttribute('gsm'); | 386 page.removeAttribute('gsm'); |
| 359 } | 387 } |
| 360 OptionsPage.navigateToPage('detailsInternetPage'); | 388 OptionsPage.navigateToPage('detailsInternetPage'); |
| 361 }; | 389 }; |
| 362 | 390 |
| 363 // Export | 391 // Export |
| 364 return { | 392 return { |
| 365 InternetOptions: InternetOptions | 393 InternetOptions: InternetOptions |
| 366 }; | 394 }; |
| 367 }); | 395 }); |
| OLD | NEW |