OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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.internet', function() { | 5 cr.define('options.internet', function() { |
6 /** @const */ var EditableTextField = options.EditableTextField; | 6 /** @const */ var EditableTextField = options.EditableTextField; |
7 | 7 |
8 /** | 8 /** |
9 * The regular expression that matches an IP address. String to match against | 9 * The regular expression that matches an IP address. String to match against |
10 * should have all whitespace stripped already. | 10 * should have all whitespace stripped already. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 var rangeCorrect = true; | 62 var rangeCorrect = true; |
63 if (matches != null) { | 63 if (matches != null) { |
64 for (var i = 1; i < matches.length; ++i) { | 64 for (var i = 1; i < matches.length; ++i) { |
65 var value = parseInt(matches[i], 10); | 65 var value = parseInt(matches[i], 10); |
66 if (value < 0 || value > 255) { | 66 if (value < 0 || value > 255) { |
67 rangeCorrect = false; | 67 rangeCorrect = false; |
68 break; | 68 break; |
69 } | 69 } |
70 } | 70 } |
71 } | 71 } |
72 return this.editField.validity.valid && matches != null && | 72 return this.editField.validity.valid && matches != null && rangeCorrect && |
73 rangeCorrect && matches.length == 5; | 73 matches.length == 5; |
74 }, | 74 }, |
75 | 75 |
76 /** @override */ | 76 /** @override */ |
77 get hasBeenEdited() { | 77 get hasBeenEdited() { |
78 return this.editField.value != this.model.value; | 78 return this.editField.value != this.model.value; |
79 }, | 79 }, |
80 | 80 |
81 /** | 81 /** |
82 * Overrides superclass to mutate the input during a successful commit. For | 82 * Overrides superclass to mutate the input during a successful commit. For |
83 * the purposes of entering IP addresses, this just means stripping off | 83 * the purposes of entering IP addresses, this just means stripping off |
(...skipping 19 matching lines...) Expand all Loading... |
103 result.push(parseInt(matches[i], 10)); | 103 result.push(parseInt(matches[i], 10)); |
104 } | 104 } |
105 return result.join('.'); | 105 return result.join('.'); |
106 }, | 106 }, |
107 }; | 107 }; |
108 | 108 |
109 return { | 109 return { |
110 IPAddressField: IPAddressField, | 110 IPAddressField: IPAddressField, |
111 }; | 111 }; |
112 }); | 112 }); |
OLD | NEW |