OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 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 * | 7 * |
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 28 matching lines...) Expand all Loading... |
39 this.sidebarResizeElement.className = "sidebar-resizer-vertical"; | 39 this.sidebarResizeElement.className = "sidebar-resizer-vertical"; |
40 this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDr
agging.bind(this), false); | 40 this.sidebarResizeElement.addEventListener("mousedown", this._startSidebarDr
agging.bind(this), false); |
41 this.element.appendChild(this.sidebarResizeElement); | 41 this.element.appendChild(this.sidebarResizeElement); |
42 | 42 |
43 this.sidebarTreeElement = document.createElement("ol"); | 43 this.sidebarTreeElement = document.createElement("ol"); |
44 this.sidebarTreeElement.className = "sidebar-tree"; | 44 this.sidebarTreeElement.className = "sidebar-tree"; |
45 this.sidebarElement.appendChild(this.sidebarTreeElement); | 45 this.sidebarElement.appendChild(this.sidebarTreeElement); |
46 | 46 |
47 this.sidebarTree = new TreeOutline(this.sidebarTreeElement); | 47 this.sidebarTree = new TreeOutline(this.sidebarTreeElement); |
48 | 48 |
49 this.databaseViews = document.createElement("div"); | 49 this.databasesListTreeElement = new WebInspector.SidebarSectionTreeElement(W
ebInspector.UIString("DATABASES"), {}, true); |
50 this.databaseViews.id = "database-views"; | 50 this.sidebarTree.appendChild(this.databasesListTreeElement); |
51 this.element.appendChild(this.databaseViews); | 51 this.databasesListTreeElement.expand(); |
| 52 |
| 53 this.localStorageListTreeElement = new WebInspector.SidebarSectionTreeElemen
t(WebInspector.UIString("LOCAL STORAGE"), {}, true); |
| 54 this.sidebarTree.appendChild(this.localStorageListTreeElement); |
| 55 this.localStorageListTreeElement.expand(); |
| 56 |
| 57 this.sessionStorageListTreeElement = new WebInspector.SidebarSectionTreeElem
ent(WebInspector.UIString("SESSION STORAGE"), {}, true); |
| 58 this.sidebarTree.appendChild(this.sessionStorageListTreeElement); |
| 59 this.sessionStorageListTreeElement.expand(); |
| 60 |
| 61 this.storageViews = document.createElement("div"); |
| 62 this.storageViews.id = "storage-views"; |
| 63 this.element.appendChild(this.storageViews); |
52 | 64 |
53 this.reset(); | 65 this.reset(); |
54 } | 66 } |
55 | 67 |
56 WebInspector.DatabasesPanel.prototype = { | 68 WebInspector.DatabasesPanel.prototype = { |
57 toolbarItemClass: "databases", | 69 toolbarItemClass: "databases", |
58 | 70 |
59 get toolbarItemLabel() | 71 get toolbarItemLabel() |
60 { | 72 { |
61 return WebInspector.UIString("Databases"); | 73 return WebInspector.UIString("Databases"); |
(...skipping 12 matching lines...) Expand all Loading... |
74 for (var i = 0; i < databasesLength; ++i) { | 86 for (var i = 0; i < databasesLength; ++i) { |
75 var database = this._databases[i]; | 87 var database = this._databases[i]; |
76 | 88 |
77 delete database._tableViews; | 89 delete database._tableViews; |
78 delete database._queryView; | 90 delete database._queryView; |
79 } | 91 } |
80 } | 92 } |
81 | 93 |
82 this._databases = []; | 94 this._databases = []; |
83 | 95 |
84 this.sidebarTree.removeChildren(); | 96 if (this._domStorage) { |
85 this.databaseViews.removeChildren(); | 97 var domStorageLength = this._domStorage.length; |
| 98 for (var i = 0; i < domStorageLength; ++i) { |
| 99 var domStorage = this._domStorage[i]; |
| 100 |
| 101 delete domStorage._domStorageView; |
| 102 } |
| 103 } |
| 104 |
| 105 this._domStorage = []; |
| 106 |
| 107 this.databasesListTreeElement.removeChildren(); |
| 108 this.localStorageListTreeElement.removeChildren(); |
| 109 this.sessionStorageListTreeElement.removeChildren(); |
| 110 this.storageViews.removeChildren(); |
86 }, | 111 }, |
87 | 112 |
88 handleKeyEvent: function(event) | 113 handleKeyEvent: function(event) |
89 { | 114 { |
90 this.sidebarTree.handleKeyEvent(event); | 115 this.sidebarTree.handleKeyEvent(event); |
91 }, | 116 }, |
92 | 117 |
93 addDatabase: function(database) | 118 addDatabase: function(database) |
94 { | 119 { |
95 this._databases.push(database); | 120 this._databases.push(database); |
96 | 121 |
97 var databaseTreeElement = new WebInspector.DatabaseSidebarTreeElement(da
tabase); | 122 var databaseTreeElement = new WebInspector.DatabaseSidebarTreeElement(da
tabase); |
98 database._databasesTreeElement = databaseTreeElement; | 123 database._databasesTreeElement = databaseTreeElement; |
99 | 124 this.databasesListTreeElement.appendChild(databaseTreeElement); |
100 this.sidebarTree.appendChild(databaseTreeElement); | 125 }, |
| 126 |
| 127 addDOMStorage: function(domStorage) |
| 128 { |
| 129 this._domStorage.push(domStorage); |
| 130 var domStorageTreeElement = new WebInspector.DOMStorageSidebarTreeElemen
t(domStorage); |
| 131 domStorage._domStorageTreeElement = domStorageTreeElement; |
| 132 if (domStorage.isLocalStorage) |
| 133 this.localStorageListTreeElement.appendChild(domStorageTreeElement); |
| 134 else |
| 135 this.sessionStorageListTreeElement.appendChild(domStorageTreeElement
); |
101 }, | 136 }, |
102 | 137 |
103 showDatabase: function(database, tableName) | 138 showDatabase: function(database, tableName) |
104 { | 139 { |
105 if (!database) | 140 if (!database) |
106 return; | 141 return; |
107 | 142 |
108 if (this.visibleDatabaseView) | 143 if (this.visibleView) |
109 this.visibleDatabaseView.hide(); | 144 this.visibleView.hide(); |
110 | 145 |
111 var view; | 146 var view; |
112 if (tableName) { | 147 if (tableName) { |
113 if (!("_tableViews" in database)) | 148 if (!("_tableViews" in database)) |
114 database._tableViews = {}; | 149 database._tableViews = {}; |
115 view = database._tableViews[tableName]; | 150 view = database._tableViews[tableName]; |
116 if (!view) { | 151 if (!view) { |
117 view = new WebInspector.DatabaseTableView(database, tableName); | 152 view = new WebInspector.DatabaseTableView(database, tableName); |
118 database._tableViews[tableName] = view; | 153 database._tableViews[tableName] = view; |
119 } | 154 } |
120 } else { | 155 } else { |
121 view = database._queryView; | 156 view = database._queryView; |
122 if (!view) { | 157 if (!view) { |
123 view = new WebInspector.DatabaseQueryView(database); | 158 view = new WebInspector.DatabaseQueryView(database); |
124 database._queryView = view; | 159 database._queryView = view; |
125 } | 160 } |
126 } | 161 } |
127 | 162 |
128 view.show(this.databaseViews); | 163 view.show(this.storageViews); |
129 | 164 |
130 this.visibleDatabaseView = view; | 165 this.visibleView = view; |
| 166 }, |
| 167 |
| 168 showDOMStorage: function(domStorage) |
| 169 { |
| 170 if (!domStorage) |
| 171 return; |
| 172 |
| 173 if (this.visibleView) |
| 174 this.visibleView.hide(); |
| 175 |
| 176 var view; |
| 177 view = domStorage._domStorageView; |
| 178 if (!view) { |
| 179 view = new WebInspector.DOMStorageItemsView(domStorage); |
| 180 domStorage._domStorageView = view; |
| 181 } |
| 182 |
| 183 view.show(this.storageViews); |
| 184 |
| 185 this.visibleView = view; |
131 }, | 186 }, |
132 | 187 |
133 closeVisibleView: function() | 188 closeVisibleView: function() |
134 { | 189 { |
135 if (this.visibleDatabaseView) | 190 if (this.visibleView) |
136 this.visibleDatabaseView.hide(); | 191 this.visibleView.hide(); |
137 delete this.visibleDatabaseView; | 192 delete this.visibleView; |
138 }, | 193 }, |
139 | 194 |
140 updateDatabaseTables: function(database) | 195 updateDatabaseTables: function(database) |
141 { | 196 { |
142 if (!database || !database._databasesTreeElement) | 197 if (!database || !database._databasesTreeElement) |
143 return; | 198 return; |
144 | 199 |
145 database._databasesTreeElement.shouldRefreshChildren = true; | 200 database._databasesTreeElement.shouldRefreshChildren = true; |
146 | 201 |
147 if (!("_tableViews" in database)) | 202 if (!("_tableViews" in database)) |
148 return; | 203 return; |
149 | 204 |
150 var tableNamesHash = {}; | 205 var tableNamesHash = {}; |
151 var tableNames = database.tableNames; | 206 var tableNames = database.tableNames; |
152 var tableNamesLength = tableNames.length; | 207 var tableNamesLength = tableNames.length; |
153 for (var i = 0; i < tableNamesLength; ++i) | 208 for (var i = 0; i < tableNamesLength; ++i) |
154 tableNamesHash[tableNames[i]] = true; | 209 tableNamesHash[tableNames[i]] = true; |
155 | 210 |
156 for (var tableName in database._tableViews) { | 211 for (var tableName in database._tableViews) { |
157 if (!(tableName in tableNamesHash)) { | 212 if (!(tableName in tableNamesHash)) { |
158 if (this.visibleDatabaseView === database._tableViews[tableName]
) | 213 if (this.visibleView === database._tableViews[tableName]) |
159 this.closeVisibleView(); | 214 this.closeVisibleView(); |
160 delete database._tableViews[tableName]; | 215 delete database._tableViews[tableName]; |
161 } | 216 } |
162 } | 217 } |
163 }, | 218 }, |
164 | 219 |
165 dataGridForResult: function(result) | 220 dataGridForResult: function(result) |
166 { | 221 { |
167 if (!result.rows.length) | 222 if (!result.rows.length) |
168 return null; | 223 return null; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 columns[columnIdentifier].width += "%"; | 289 columns[columnIdentifier].width += "%"; |
235 | 290 |
236 var dataGrid = new WebInspector.DataGrid(columns); | 291 var dataGrid = new WebInspector.DataGrid(columns); |
237 var length = nodes.length; | 292 var length = nodes.length; |
238 for (var i = 0; i < length; ++i) | 293 for (var i = 0; i < length; ++i) |
239 dataGrid.appendChild(nodes[i]); | 294 dataGrid.appendChild(nodes[i]); |
240 | 295 |
241 return dataGrid; | 296 return dataGrid; |
242 }, | 297 }, |
243 | 298 |
| 299 dataGridForDOMStorage: function(domStorage) |
| 300 { |
| 301 if (!domStorage.length) |
| 302 return null; |
| 303 |
| 304 var columns = {}; |
| 305 columns[0] = {}; |
| 306 columns[1] = {}; |
| 307 columns[0].title = WebInspector.UIString("Key"); |
| 308 columns[0].width = columns[0].title.length; |
| 309 columns[1].title = WebInspector.UIString("Value"); |
| 310 columns[1].width = columns[0].title.length; |
| 311 |
| 312 var nodes = []; |
| 313 |
| 314 var length = domStorage.length; |
| 315 for (index = 0; index < domStorage.length; index++) { |
| 316 var data = {}; |
| 317 |
| 318 var key = String(domStorage.key(index)); |
| 319 data[0] = key; |
| 320 if (key.length > columns[0].width) |
| 321 columns[0].width = key.length; |
| 322 |
| 323 var value = String(domStorage.getItem(key)); |
| 324 data[1] = value; |
| 325 if (value.length > columns[1].width) |
| 326 columns[1].width = value.length; |
| 327 var node = new WebInspector.DataGridNode(data, false); |
| 328 node.selectable = false; |
| 329 nodes.push(node); |
| 330 } |
| 331 |
| 332 var totalColumnWidths = columns[0].width + columns[1].width; |
| 333 width = Math.round((columns[0].width * 100) / totalColumnWidths); |
| 334 const minimumPrecent = 10; |
| 335 if (width < minimumPrecent) |
| 336 width = minimumPrecent; |
| 337 if (width > 100 - minimumPrecent) |
| 338 width = 100 - minimumPrecent; |
| 339 columns[0].width = width; |
| 340 columns[1].width = 100 - width; |
| 341 columns[0].width += "%"; |
| 342 columns[1].width += "%"; |
| 343 |
| 344 var dataGrid = new WebInspector.DataGrid(columns); |
| 345 var length = nodes.length; |
| 346 for (var i = 0; i < length; ++i) |
| 347 dataGrid.appendChild(nodes[i]); |
| 348 |
| 349 return dataGrid; |
| 350 }, |
| 351 |
244 _startSidebarDragging: function(event) | 352 _startSidebarDragging: function(event) |
245 { | 353 { |
246 WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDr
agging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize"); | 354 WebInspector.elementDragStart(this.sidebarResizeElement, this._sidebarDr
agging.bind(this), this._endSidebarDragging.bind(this), event, "col-resize"); |
247 }, | 355 }, |
248 | 356 |
249 _sidebarDragging: function(event) | 357 _sidebarDragging: function(event) |
250 { | 358 { |
251 this._updateSidebarWidth(event.pageX); | 359 this._updateSidebarWidth(event.pageX); |
252 | 360 |
253 event.preventDefault(); | 361 event.preventDefault(); |
(...skipping 16 matching lines...) Expand all Loading... |
270 this._currentSidebarWidth = this.sidebarElement.offsetWidth; | 378 this._currentSidebarWidth = this.sidebarElement.offsetWidth; |
271 | 379 |
272 if (typeof width === "undefined") | 380 if (typeof width === "undefined") |
273 width = this._currentSidebarWidth; | 381 width = this._currentSidebarWidth; |
274 | 382 |
275 width = Number.constrain(width, Preferences.minSidebarWidth, window.inne
rWidth / 2); | 383 width = Number.constrain(width, Preferences.minSidebarWidth, window.inne
rWidth / 2); |
276 | 384 |
277 this._currentSidebarWidth = width; | 385 this._currentSidebarWidth = width; |
278 | 386 |
279 this.sidebarElement.style.width = width + "px"; | 387 this.sidebarElement.style.width = width + "px"; |
280 this.databaseViews.style.left = width + "px"; | 388 this.storageViews.style.left = width + "px"; |
281 this.sidebarResizeElement.style.left = (width - 3) + "px"; | 389 this.sidebarResizeElement.style.left = (width - 3) + "px"; |
282 } | 390 } |
283 } | 391 } |
284 | 392 |
285 WebInspector.DatabasesPanel.prototype.__proto__ = WebInspector.Panel.prototype; | 393 WebInspector.DatabasesPanel.prototype.__proto__ = WebInspector.Panel.prototype; |
286 | 394 |
287 WebInspector.DatabaseSidebarTreeElement = function(database) | 395 WebInspector.DatabaseSidebarTreeElement = function(database) |
288 { | 396 { |
289 this.database = database; | 397 this.database = database; |
290 | 398 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 } | 456 } |
349 | 457 |
350 WebInspector.SidebarDatabaseTableTreeElement.prototype = { | 458 WebInspector.SidebarDatabaseTableTreeElement.prototype = { |
351 onselect: function() | 459 onselect: function() |
352 { | 460 { |
353 WebInspector.panels.databases.showDatabase(this.database, this.tableName
); | 461 WebInspector.panels.databases.showDatabase(this.database, this.tableName
); |
354 } | 462 } |
355 } | 463 } |
356 | 464 |
357 WebInspector.SidebarDatabaseTableTreeElement.prototype.__proto__ = WebInspector.
SidebarTreeElement.prototype; | 465 WebInspector.SidebarDatabaseTableTreeElement.prototype.__proto__ = WebInspector.
SidebarTreeElement.prototype; |
| 466 |
| 467 WebInspector.DOMStorageSidebarTreeElement = function(domStorage) |
| 468 { |
| 469 |
| 470 this.domStorage = domStorage; |
| 471 |
| 472 WebInspector.SidebarTreeElement.call(this, "domstorage-sidebar-tree-item", d
omStorage, "", null, false); |
| 473 |
| 474 this.refreshTitles(); |
| 475 } |
| 476 |
| 477 WebInspector.DOMStorageSidebarTreeElement.prototype = { |
| 478 onselect: function() |
| 479 { |
| 480 WebInspector.panels.databases.showDOMStorage(this.domStorage); |
| 481 }, |
| 482 |
| 483 get mainTitle() |
| 484 { |
| 485 return this.domStorage.domain; |
| 486 }, |
| 487 |
| 488 set mainTitle(x) |
| 489 { |
| 490 // Do nothing. |
| 491 }, |
| 492 |
| 493 get subtitle() |
| 494 { |
| 495 return ""; //this.database.displayDomain; |
| 496 }, |
| 497 |
| 498 set subtitle(x) |
| 499 { |
| 500 // Do nothing. |
| 501 } |
| 502 } |
| 503 |
| 504 WebInspector.DOMStorageSidebarTreeElement.prototype.__proto__ = WebInspector.Sid
ebarTreeElement.prototype; |
OLD | NEW |