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

Side by Side Diff: chrome/browser/resources/bluetooth_internals/device_table.js

Issue 2600683002: Run tools/clang-format-js on some of chrome/browser/resources/ (Closed)
Patch Set: . Created 4 years 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 * Javascript for DeviceTable UI, served from chrome://bluetooth-internals/. 6 * Javascript for DeviceTable UI, served from chrome://bluetooth-internals/.
7 */ 7 */
8 8
9 cr.define('device_table', function() { 9 cr.define('device_table', function() {
10 var COLUMNS = { 10 var COLUMNS = {
11 NAME: 0, 11 NAME: 0,
12 ADDRESS: 1, 12 ADDRESS: 1,
13 RSSI: 2, 13 RSSI: 2,
14 SERVICES: 3, 14 SERVICES: 3,
15 CONNECTION_STATE: 4, 15 CONNECTION_STATE: 4,
16 INSPECT_LINK: 5, 16 INSPECT_LINK: 5,
17 }; 17 };
18 18
19 /** 19 /**
20 * A table that lists the devices and responds to changes in the given 20 * A table that lists the devices and responds to changes in the given
21 * DeviceCollection. Fires events for inspection requests from listed 21 * DeviceCollection. Fires events for inspection requests from listed
22 * devices. 22 * devices.
23 * @constructor 23 * @constructor
24 * @extends {HTMLTableElement} 24 * @extends {HTMLTableElement}
25 */ 25 */
26 var DeviceTable = cr.ui.define(function() { 26 var DeviceTable = cr.ui.define(function() {
27 /** @private {?Array<device_collection.Device>} */ 27 /** @private {?Array<device_collection.Device>} */
28 this.devices_ = null; 28 this.devices_ = null;
29 29
30 return document.importNode($('table-template').content.children[0], 30 return document.importNode(
31 true /* deep */); 31 $('table-template').content.children[0], true /* deep */);
32 }); 32 });
33 33
34 DeviceTable.prototype = { 34 DeviceTable.prototype = {
35 __proto__: HTMLTableElement.prototype, 35 __proto__: HTMLTableElement.prototype,
36 36
37 /** 37 /**
38 * Decorates an element as a UI element class. Caches references to the 38 * Decorates an element as a UI element class. Caches references to the
39 * table body and headers. 39 * table body and headers.
40 */ 40 */
41 decorate: function() { 41 decorate: function() {
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 switch (device.connectionStatus) { 157 switch (device.connectionStatus) {
158 case device_collection.ConnectionStatus.DISCONNECTED: 158 case device_collection.ConnectionStatus.DISCONNECTED:
159 inspectLink.textContent = 'Inspect'; 159 inspectLink.textContent = 'Inspect';
160 break; 160 break;
161 case device_collection.ConnectionStatus.CONNECTED: 161 case device_collection.ConnectionStatus.CONNECTED:
162 inspectLink.textContent = 'Forget'; 162 inspectLink.textContent = 'Forget';
163 break; 163 break;
164 case device_collection.ConnectionStatus.CONNECTING: 164 case device_collection.ConnectionStatus.CONNECTING:
165 inspectLink.disabled = true; 165 inspectLink.disabled = true;
166 break; 166 break;
167 default: assert('case not handled'); 167 default:
168 assert('case not handled');
168 } 169 }
169 170
170 // Update the properties based on the header field path. 171 // Update the properties based on the header field path.
171 for (var i = 0; i < this.headers_.length; i++) { 172 for (var i = 0; i < this.headers_.length; i++) {
172 var header = this.headers_[i]; 173 var header = this.headers_[i];
173 var propName = header.dataset.field; 174 var propName = header.dataset.field;
174 175
175 var parts = propName.split('.'); 176 var parts = propName.split('.');
176 var obj = device; 177 var obj = device;
177 while (obj != null && parts.length > 0) { 178 while (obj != null && parts.length > 0) {
178 var part = parts.shift(); 179 var part = parts.shift();
179 obj = obj[part]; 180 obj = obj[part];
180 } 181 }
181 182
182 if (propName == 'is_gatt_connected') { 183 if (propName == 'is_gatt_connected') {
183 obj = obj ? 'Connected' : 'Not Connected'; 184 obj = obj ? 'Connected' : 'Not Connected';
184 } 185 }
185 186
186 var cell = row.cells[i]; 187 var cell = row.cells[i];
187 cell.textContent = obj == null ? 'Unknown' : obj; 188 cell.textContent = obj == null ? 'Unknown' : obj;
188 cell.dataset.label = header.textContent; 189 cell.dataset.label = header.textContent;
189 } 190 }
190 }, 191 },
191 }; 192 };
192 193
193 return { 194 return {
194 DeviceTable: DeviceTable, 195 DeviceTable: DeviceTable,
195 }; 196 };
196 }); 197 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698