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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/resources/ApplicationCacheItemsView.js

Issue 2444223002: [Devtools] Cleanup DataGrid's typecast and identifier naming (Closed)
Patch Set: changes Created 4 years, 1 month 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 /* 1 /*
2 * Copyright (C) 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 this._emptyWidget.detach(); 179 this._emptyWidget.detach();
180 this._deleteButton.setVisible(true); 180 this._deleteButton.setVisible(true);
181 181
182 // FIXME: For Chrome, put creationTime and updateTime somewhere. 182 // FIXME: For Chrome, put creationTime and updateTime somewhere.
183 // NOTE: localizedString has not yet been added. 183 // NOTE: localizedString has not yet been added.
184 // WebInspector.UIString("(%s) Created: %s Updated: %s", this._size, thi s._creationTime, this._updateTime); 184 // WebInspector.UIString("(%s) Created: %s Updated: %s", this._size, thi s._creationTime, this._updateTime);
185 }, 185 },
186 186
187 _createDataGrid: function() 187 _createDataGrid: function()
188 { 188 {
189 var columns = [ 189 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor> } */ ([
190 {title: WebInspector.UIString("Resource"), sort: WebInspector.DataGr id.Order.Ascending, sortable: true}, 190 {id: "resource", title: WebInspector.UIString("Resource"), sort: Web Inspector.DataGrid.Order.Ascending, sortable: true},
191 {title: WebInspector.UIString("Type"), sortable: true}, 191 {id: "type", title: WebInspector.UIString("Type"), sortable: true},
192 {title: WebInspector.UIString("Size"), align: WebInspector.DataGrid. Align.Right, sortable: true} 192 {id: "size", title: WebInspector.UIString("Size"), align: WebInspect or.DataGrid.Align.Right, sortable: true}
193 ]; 193 ]);
194 this._dataGrid = new WebInspector.DataGrid(columns); 194 this._dataGrid = new WebInspector.DataGrid(columns);
195 this._dataGrid.asWidget().show(this.element); 195 this._dataGrid.asWidget().show(this.element);
196 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._populateDataGrid, this); 196 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChan ged, this._populateDataGrid, this);
197 }, 197 },
198 198
199 _populateDataGrid: function() 199 _populateDataGrid: function()
200 { 200 {
201 var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.sele ctedNode.resource : null; 201 var selectedResource = this._dataGrid.selectedNode ? this._dataGrid.sele ctedNode.resource : null;
202 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1; 202 var sortDirection = this._dataGrid.isSortOrderAscending() ? 1 : -1;
203 203
204 function numberCompare(field, resource1, resource2) 204 function numberCompare(field, resource1, resource2)
205 { 205 {
206 return sortDirection * (resource1[field] - resource2[field]); 206 return sortDirection * (resource1[field] - resource2[field]);
207 } 207 }
208 function localeCompare(field, resource1, resource2) 208 function localeCompare(field, resource1, resource2)
209 { 209 {
210 return sortDirection * (resource1[field] + "").localeCompare(resourc e2[field] + ""); 210 return sortDirection * (resource1[field] + "").localeCompare(resourc e2[field] + "");
211 } 211 }
212 212
213 var comparator; 213 var comparator;
214 switch (parseInt(this._dataGrid.sortColumnIdentifier(), 10)) { 214 switch (parseInt(this._dataGrid.sortColumnId(), 10)) {
dgozman 2016/10/25 18:42:40 Compare to new ids instead.
allada 2016/10/25 18:56:14 Done.
215 case 0: comparator = localeCompare.bind(null, "name"); break; 215 case 0: comparator = localeCompare.bind(null, "name"); break;
216 case 1: comparator = localeCompare.bind(null, "type"); break; 216 case 1: comparator = localeCompare.bind(null, "type"); break;
217 case 2: comparator = numberCompare.bind(null, "size"); break; 217 case 2: comparator = numberCompare.bind(null, "size"); break;
218 default: localeCompare.bind(null, "resource"); // FIXME: comparator = ? 218 default: localeCompare.bind(null, "resource"); // FIXME: comparator = ?
219 } 219 }
220 220
221 this._resources.sort(comparator); 221 this._resources.sort(comparator);
222 this._dataGrid.rootNode().removeChildren(); 222 this._dataGrid.rootNode().removeChildren();
223 223
224 var nodeToSelect; 224 var nodeToSelect;
(...skipping 29 matching lines...) Expand all
254 _deleteCallback: function(node) 254 _deleteCallback: function(node)
255 { 255 {
256 // FIXME: Should we delete a single (selected) resource or all resources ? 256 // FIXME: Should we delete a single (selected) resource or all resources ?
257 // InspectorBackend.deleteCachedResource(...) 257 // InspectorBackend.deleteCachedResource(...)
258 // this._update(); 258 // this._update();
259 }, 259 },
260 260
261 __proto__: WebInspector.SimpleView.prototype 261 __proto__: WebInspector.SimpleView.prototype
262 } 262 }
263 263
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698