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 const ArrayDataModel = cr.ui.ArrayDataModel; | 7 const ArrayDataModel = cr.ui.ArrayDataModel; |
8 | 8 |
9 ///////////////////////////////////////////////////////////////////////////// | 9 ///////////////////////////////////////////////////////////////////////////// |
10 // InternetOptions class: | 10 // InternetOptions class: |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 inetGateway = data.ipconfigStatic.gateway; | 354 inetGateway = data.ipconfigStatic.gateway; |
355 inetDns = data.ipconfigStatic.dns; | 355 inetDns = data.ipconfigStatic.dns; |
356 $('ipTypeStatic').checked = true; | 356 $('ipTypeStatic').checked = true; |
357 } else if (data.ipconfigDHCP) { | 357 } else if (data.ipconfigDHCP) { |
358 inetAddress = data.ipconfigDHCP.address; | 358 inetAddress = data.ipconfigDHCP.address; |
359 inetSubnetAddress = data.ipconfigDHCP.subnetAddress; | 359 inetSubnetAddress = data.ipconfigDHCP.subnetAddress; |
360 inetGateway = data.ipconfigDHCP.gateway; | 360 inetGateway = data.ipconfigDHCP.gateway; |
361 inetDns = data.ipconfigDHCP.dns; | 361 inetDns = data.ipconfigDHCP.dns; |
362 } | 362 } |
363 | 363 |
| 364 // Hide the dhcp/static radio if not ethernet or wifi |
| 365 var ethernet_wifi = data.type == options.internet.Constants.TYPE_WIFI || |
| 366 data.type == options.internet.Constants.TYPE_ETHERNET; |
| 367 $('ipTypeDHCPDiv').hidden = !ethernet_wifi; |
| 368 $('ipTypeStaticDiv').hidden = !ethernet_wifi; |
| 369 |
364 var ipConfigList = $('ipConfigList'); | 370 var ipConfigList = $('ipConfigList'); |
365 ipConfigList.disabled = $('ipTypeDHCP').checked; | 371 ipConfigList.disabled = $('ipTypeDHCP').checked || !ethernet_wifi; |
366 options.internet.IPConfigList.decorate(ipConfigList); | 372 options.internet.IPConfigList.decorate(ipConfigList); |
367 ipConfigList.autoExpands = true; | 373 ipConfigList.autoExpands = true; |
368 var model = new ArrayDataModel([]); | 374 var model = new ArrayDataModel([]); |
369 model.push({ | 375 model.push({ |
370 'property': 'inetAddress', | 376 'property': 'inetAddress', |
371 'name': localStrings.getString('inetAddress'), | 377 'name': localStrings.getString('inetAddress'), |
372 'value': inetAddress, | 378 'value': inetAddress, |
373 }); | 379 }); |
374 model.push({ | 380 model.push({ |
375 'property': 'inetSubnetAddress', | 381 'property': 'inetSubnetAddress', |
(...skipping 23 matching lines...) Expand all Loading... |
399 ipConfigList.dataModel.updateIndex(0); | 405 ipConfigList.dataModel.updateIndex(0); |
400 ipConfigList.dataModel.updateIndex(1); | 406 ipConfigList.dataModel.updateIndex(1); |
401 ipConfigList.dataModel.updateIndex(2); | 407 ipConfigList.dataModel.updateIndex(2); |
402 ipConfigList.dataModel.updateIndex(3); | 408 ipConfigList.dataModel.updateIndex(3); |
403 // Unselect all so we don't keep the currently selected field editable. | 409 // Unselect all so we don't keep the currently selected field editable. |
404 ipConfigList.selectionModel.unselectAll(); | 410 ipConfigList.selectionModel.unselectAll(); |
405 ipConfigList.disabled = true; | 411 ipConfigList.disabled = true; |
406 }); | 412 }); |
407 | 413 |
408 $('ipTypeStatic').addEventListener('click', function(event) { | 414 $('ipTypeStatic').addEventListener('click', function(event) { |
409 // enable ipConfigList and switch back to static values (if any) | 415 // enable ipConfigList |
410 if (data.ipconfigStatic) { | |
411 ipConfigList.dataModel.item(0).value = data.ipconfigStatic.address; | |
412 ipConfigList.dataModel.item(1).value = | |
413 data.ipconfigStatic.subnetAddress; | |
414 ipConfigList.dataModel.item(2).value = data.ipconfigStatic.gateway; | |
415 ipConfigList.dataModel.item(3).value = data.ipconfigStatic.dns; | |
416 } | |
417 ipConfigList.dataModel.updateIndex(0); | |
418 ipConfigList.dataModel.updateIndex(1); | |
419 ipConfigList.dataModel.updateIndex(2); | |
420 ipConfigList.dataModel.updateIndex(3); | |
421 ipConfigList.disabled = false; | 416 ipConfigList.disabled = false; |
422 ipConfigList.focus(); | 417 ipConfigList.focus(); |
423 ipConfigList.selectionModel.selectedIndex = 0; | 418 ipConfigList.selectionModel.selectedIndex = 0; |
424 }); | 419 }); |
425 | 420 |
426 if (data.hardwareAddress) { | 421 if (data.hardwareAddress) { |
427 $('hardwareAddress').textContent = data.hardwareAddress; | 422 $('hardwareAddress').textContent = data.hardwareAddress; |
428 $('hardwareAddressRow').style.display = 'table-row'; | 423 $('hardwareAddressRow').style.display = 'table-row'; |
429 } else { | 424 } else { |
430 // This is most likely a device without a hardware address. | 425 // This is most likely a device without a hardware address. |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 detailsPage.gsm = false; | 522 detailsPage.gsm = false; |
528 } | 523 } |
529 OptionsPage.navigateToPage('detailsInternetPage'); | 524 OptionsPage.navigateToPage('detailsInternetPage'); |
530 }; | 525 }; |
531 | 526 |
532 // Export | 527 // Export |
533 return { | 528 return { |
534 InternetOptions: InternetOptions | 529 InternetOptions: InternetOptions |
535 }; | 530 }; |
536 }); | 531 }); |
OLD | NEW |