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

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

Issue 2623743002: DevTools: extract modules (non-extensions) (Closed)
Patch Set: rebaseline 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 /* 1 /*
2 * Copyright (C) 2008 Nokia Inc. All rights reserved. 2 * Copyright (C) 2008 Nokia Inc. All rights reserved.
3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 var rootNode = this._dataGrid.rootNode(); 117 var rootNode = this._dataGrid.rootNode();
118 var children = rootNode.children; 118 var children = rootNode.children;
119 119
120 this.deleteButton.setVisible(true); 120 this.deleteButton.setVisible(true);
121 121
122 for (var i = 0; i < children.length; ++i) { 122 for (var i = 0; i < children.length; ++i) {
123 if (children[i].data.key === storageData.key) 123 if (children[i].data.key === storageData.key)
124 return; 124 return;
125 } 125 }
126 126
127 var childNode = new UI.DataGridNode({key: storageData.key, value: storageDat a.value}, false); 127 var childNode = new DataGrid.DataGridNode({key: storageData.key, value: stor ageData.value}, false);
128 rootNode.insertChild(childNode, children.length - 1); 128 rootNode.insertChild(childNode, children.length - 1);
129 } 129 }
130 130
131 /** 131 /**
132 * @param {!Common.Event} event 132 * @param {!Common.Event} event
133 */ 133 */
134 _domStorageItemUpdated(event) { 134 _domStorageItemUpdated(event) {
135 if (!this.isShowing() || !this._dataGrid) 135 if (!this.isShowing() || !this._dataGrid)
136 return; 136 return;
137 137
(...skipping 29 matching lines...) Expand all
167 _showDOMStorageItems(error, items) { 167 _showDOMStorageItems(error, items) {
168 if (error) 168 if (error)
169 return; 169 return;
170 170
171 this._dataGrid = this._dataGridForDOMStorageItems(items); 171 this._dataGrid = this._dataGridForDOMStorageItems(items);
172 this._dataGrid.asWidget().show(this.element); 172 this._dataGrid.asWidget().show(this.element);
173 this.deleteButton.setVisible(this._dataGrid.rootNode().children.length > 1); 173 this.deleteButton.setVisible(this._dataGrid.rootNode().children.length > 1);
174 } 174 }
175 175
176 _dataGridForDOMStorageItems(items) { 176 _dataGridForDOMStorageItems(items) {
177 var columns = /** @type {!Array<!UI.DataGrid.ColumnDescriptor>} */ ([ 177 var columns = /** @type {!Array<!DataGrid.DataGrid.ColumnDescriptor>} */ ([
178 {id: 'key', title: Common.UIString('Key'), sortable: false, editable: true , weight: 50}, 178 {id: 'key', title: Common.UIString('Key'), sortable: false, editable: true , weight: 50},
179 {id: 'value', title: Common.UIString('Value'), sortable: false, editable: true, weight: 50} 179 {id: 'value', title: Common.UIString('Value'), sortable: false, editable: true, weight: 50}
180 ]); 180 ]);
181 181
182 var nodes = []; 182 var nodes = [];
183 183
184 var keys = []; 184 var keys = [];
185 var length = items.length; 185 var length = items.length;
186 for (var i = 0; i < items.length; i++) { 186 for (var i = 0; i < items.length; i++) {
187 var key = items[i][0]; 187 var key = items[i][0];
188 var value = items[i][1]; 188 var value = items[i][1];
189 var node = new UI.DataGridNode({key: key, value: value}, false); 189 var node = new DataGrid.DataGridNode({key: key, value: value}, false);
190 node.selectable = true; 190 node.selectable = true;
191 nodes.push(node); 191 nodes.push(node);
192 keys.push(key); 192 keys.push(key);
193 } 193 }
194 194
195 var dataGrid = new UI.DataGrid(columns, this._editingCallback.bind(this), th is._deleteCallback.bind(this)); 195 var dataGrid = new DataGrid.DataGrid(columns, this._editingCallback.bind(thi s), this._deleteCallback.bind(this));
196 dataGrid.setName('DOMStorageItemsView'); 196 dataGrid.setName('DOMStorageItemsView');
197 length = nodes.length; 197 length = nodes.length;
198 for (var i = 0; i < length; ++i) 198 for (var i = 0; i < length; ++i)
199 dataGrid.rootNode().appendChild(nodes[i]); 199 dataGrid.rootNode().appendChild(nodes[i]);
200 dataGrid.addCreationNode(false); 200 dataGrid.addCreationNode(false);
201 if (length > 0) 201 if (length > 0)
202 nodes[0].selected = true; 202 nodes[0].selected = true;
203 return dataGrid; 203 return dataGrid;
204 } 204 }
205 205
(...skipping 20 matching lines...) Expand all
226 if (typeof oldText === 'string') 226 if (typeof oldText === 'string')
227 domStorage.removeItem(oldText); 227 domStorage.removeItem(oldText);
228 domStorage.setItem(newText, editingNode.data.value || ''); 228 domStorage.setItem(newText, editingNode.data.value || '');
229 this._removeDupes(editingNode); 229 this._removeDupes(editingNode);
230 } else { 230 } else {
231 domStorage.setItem(editingNode.data.key || '', newText); 231 domStorage.setItem(editingNode.data.key || '', newText);
232 } 232 }
233 } 233 }
234 234
235 /** 235 /**
236 * @param {!UI.DataGridNode} masterNode 236 * @param {!DataGrid.DataGridNode} masterNode
237 */ 237 */
238 _removeDupes(masterNode) { 238 _removeDupes(masterNode) {
239 var rootNode = this._dataGrid.rootNode(); 239 var rootNode = this._dataGrid.rootNode();
240 var children = rootNode.children; 240 var children = rootNode.children;
241 for (var i = children.length - 1; i >= 0; --i) { 241 for (var i = children.length - 1; i >= 0; --i) {
242 var childNode = children[i]; 242 var childNode = children[i];
243 if ((childNode.data.key === masterNode.data.key) && (masterNode !== childN ode)) 243 if ((childNode.data.key === masterNode.data.key) && (masterNode !== childN ode))
244 rootNode.removeChild(childNode); 244 rootNode.removeChild(childNode);
245 } 245 }
246 } 246 }
247 247
248 _deleteCallback(node) { 248 _deleteCallback(node) {
249 if (!node || node.isCreationNode) 249 if (!node || node.isCreationNode)
250 return; 250 return;
251 251
252 if (this.domStorage) 252 if (this.domStorage)
253 this.domStorage.removeItem(node.data.key); 253 this.domStorage.removeItem(node.data.key);
254 } 254 }
255 }; 255 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698