Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Side by Side Diff: chrome/browser/resources/settings/internet_page/network_nameservers.js

Issue 2651483002: MD Settings: Eliminate use of ES6 for Chrome OS (Closed)
Patch Set: . Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 /** 5 /**
6 * @fileoverview Polymer element for displaying network nameserver options. 6 * @fileoverview Polymer element for displaying network nameserver options.
7 */ 7 */
8 Polymer({ 8 Polymer({
9 is: 'network-nameservers', 9 is: 'network-nameservers',
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 }, 103 },
104 104
105 /** 105 /**
106 * @param {string} nameserversType 106 * @param {string} nameserversType
107 * @param {!Array<string>} nameservers 107 * @param {!Array<string>} nameservers
108 * @private 108 * @private
109 */ 109 */
110 setNameservers_: function(nameserversType, nameservers) { 110 setNameservers_: function(nameserversType, nameservers) {
111 if (nameserversType == 'custom') { 111 if (nameserversType == 'custom') {
112 // Add empty entries for unset custom nameservers. 112 // Add empty entries for unset custom nameservers.
113 for (let i = nameservers.length; i < this.MAX_NAMESERVERS; ++i) 113 for (var i = nameservers.length; i < this.MAX_NAMESERVERS; ++i)
114 nameservers[i] = ''; 114 nameservers[i] = '';
115 } 115 }
116 this.nameservers_ = nameservers; 116 this.nameservers_ = nameservers;
117 // Set nameserversType_ after dom-repeat has been stamped. 117 // Set nameserversType_ after dom-repeat has been stamped.
118 this.async(function() { 118 this.async(function() {
119 this.nameserversType_ = nameserversType; 119 this.nameserversType_ = nameserversType;
120 }.bind(this)); 120 }.bind(this));
121 }, 121 },
122 122
123 /** 123 /**
(...skipping 22 matching lines...) Expand all
146 146
147 /** 147 /**
148 * Event triggered when the selected type changes. Updates nameservers and 148 * Event triggered when the selected type changes. Updates nameservers and
149 * sends the change value if necessary. 149 * sends the change value if necessary.
150 * @param {!Event} event 150 * @param {!Event} event
151 * @private 151 * @private
152 */ 152 */
153 onTypeChange_: function(event) { 153 onTypeChange_: function(event) {
154 if (this.nameserversType_ == 'custom') 154 if (this.nameserversType_ == 'custom')
155 this.savedNameservers_ = this.nameservers_; 155 this.savedNameservers_ = this.nameservers_;
156 let target = /** @type {!HTMLSelectElement} */ (event.target); 156 var target = /** @type {!HTMLSelectElement} */ (event.target);
157 let type = target.value; 157 var type = target.value;
158 this.nameserversType_ = type; 158 this.nameserversType_ = type;
159 if (type == 'custom') { 159 if (type == 'custom') {
160 // Restore the saved nameservers. 160 // Restore the saved nameservers.
161 this.setNameservers_(type, this.savedNameservers_); 161 this.setNameservers_(type, this.savedNameservers_);
162 // Only send custom nameservers if they are not empty. 162 // Only send custom nameservers if they are not empty.
163 if (this.savedNameservers_.length == 0) 163 if (this.savedNameservers_.length == 0)
164 return; 164 return;
165 } 165 }
166 this.sendNameServers_(); 166 this.sendNameServers_();
167 }, 167 },
(...skipping 12 matching lines...) Expand all
180 }, 180 },
181 181
182 /** 182 /**
183 * Sends the current nameservers type (for automatic) or value. 183 * Sends the current nameservers type (for automatic) or value.
184 * @private 184 * @private
185 */ 185 */
186 sendNameServers_: function() { 186 sendNameServers_: function() {
187 var type = this.nameserversType_; 187 var type = this.nameserversType_;
188 188
189 if (type == 'custom') { 189 if (type == 'custom') {
190 let nameservers = []; 190 var nameservers = [];
dpapad 2017/01/23 19:12:54 Nit: You can use Array#map instead. var nameserve
stevenjb 2017/01/24 02:02:04 MAX_NAMESERVERS is a number, not an Array. But I c
191 for (let i = 0; i < this.MAX_NAMESERVERS; ++i) { 191 for (var i = 0; i < this.MAX_NAMESERVERS; ++i) {
192 let id = 'nameserver' + i; 192 var id = 'nameserver' + i;
193 let nameserverInput = this.$$('#' + id); 193 var nameserverInput = this.$$('#' + id);
194 let nameserver = ''; 194 var nameserver = '';
195 if (nameserverInput) 195 if (nameserverInput)
196 nameserver = this.$$('#' + id).value; 196 nameserver = this.$$('#' + id).value;
197 nameservers.push(nameserver); 197 nameservers.push(nameserver);
198 } 198 }
199 this.fire('nameservers-change', { 199 this.fire('nameservers-change', {
200 field: 'NameServers', 200 field: 'NameServers',
201 value: nameservers, 201 value: nameservers,
202 }); 202 });
203 } else if (type == 'google') { 203 } else if (type == 'google') {
204 let nameservers = this.GOOGLE_NAMESERVERS;
205 this.fire('nameservers-change', { 204 this.fire('nameservers-change', {
206 field: 'NameServers', 205 field: 'NameServers',
207 value: nameservers, 206 value: this.GOOGLE_NAMESERVERS,
208 }); 207 });
209 } else { 208 } else {
210 // automatic 209 // automatic
211 this.fire('nameservers-change', { 210 this.fire('nameservers-change', {
212 field: 'NameServersConfigType', 211 field: 'NameServersConfigType',
213 value: CrOnc.IPConfigType.DHCP, 212 value: CrOnc.IPConfigType.DHCP,
214 }); 213 });
215 } 214 }
216 }, 215 },
217 }); 216 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698