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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/network/EventSourceMessagesView.js

Issue 2466123002: DevTools: reformat front-end code to match chromium style. (Closed)
Patch Set: all done 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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
5 /** 4 /**
6 * @constructor 5 * @unrestricted
7 * @extends {WebInspector.VBox}
8 * @param {!WebInspector.NetworkRequest} request
9 */ 6 */
10 WebInspector.EventSourceMessagesView = function(request) 7 WebInspector.EventSourceMessagesView = class extends WebInspector.VBox {
11 { 8 /**
12 WebInspector.VBox.call(this); 9 * @param {!WebInspector.NetworkRequest} request
13 this.registerRequiredCSS("network/eventSourceMessagesView.css"); 10 */
14 this.element.classList.add("event-source-messages-view"); 11 constructor(request) {
12 super();
13 this.registerRequiredCSS('network/eventSourceMessagesView.css');
14 this.element.classList.add('event-source-messages-view');
15 this._request = request; 15 this._request = request;
16 16
17 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([ 17 var columns = /** @type {!Array<!WebInspector.DataGrid.ColumnDescriptor>} */ ([
18 {id: "id", title: WebInspector.UIString("Id"), sortable: true, weight: 8 }, 18 {id: 'id', title: WebInspector.UIString('Id'), sortable: true, weight: 8},
19 {id: "type", title: WebInspector.UIString("Type"), sortable: true, weigh t: 8}, 19 {id: 'type', title: WebInspector.UIString('Type'), sortable: true, weight: 8},
20 {id: "data", title: WebInspector.UIString("Data"), sortable: false, weig ht: 88}, 20 {id: 'data', title: WebInspector.UIString('Data'), sortable: false, weight : 88},
21 {id: "time", title: WebInspector.UIString("Time"), sortable: true, weigh t: 8} 21 {id: 'time', title: WebInspector.UIString('Time'), sortable: true, weight: 8}
22 ]); 22 ]);
23 23
24 this._dataGrid = new WebInspector.SortableDataGrid(columns); 24 this._dataGrid = new WebInspector.SortableDataGrid(columns);
25 this._dataGrid.setStickToBottom(true); 25 this._dataGrid.setStickToBottom(true);
26 this._dataGrid.markColumnAsSortedBy("time", WebInspector.DataGrid.Order.Asce nding); 26 this._dataGrid.markColumnAsSortedBy('time', WebInspector.DataGrid.Order.Asce nding);
27 this._sortItems(); 27 this._sortItems();
28 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortItems, this); 28 this._dataGrid.addEventListener(WebInspector.DataGrid.Events.SortingChanged, this._sortItems, this);
29 29
30 this._dataGrid.setName("EventSourceMessagesView"); 30 this._dataGrid.setName('EventSourceMessagesView');
31 this._dataGrid.asWidget().show(this.element); 31 this._dataGrid.asWidget().show(this.element);
32 }; 32 }
33 33
34 WebInspector.EventSourceMessagesView.prototype = { 34 /**
35 wasShown: function() 35 * @override
36 { 36 */
37 this._dataGrid.rootNode().removeChildren(); 37 wasShown() {
38 var messages = this._request.eventSourceMessages(); 38 this._dataGrid.rootNode().removeChildren();
39 for (var i = 0; i < messages.length; ++i) 39 var messages = this._request.eventSourceMessages();
40 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(m essages[i])); 40 for (var i = 0; i < messages.length; ++i)
41 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(message s[i]));
41 42
42 this._request.addEventListener(WebInspector.NetworkRequest.Events.EventS ourceMessageAdded, this._messageAdded, this); 43 this._request.addEventListener(
43 }, 44 WebInspector.NetworkRequest.Events.EventSourceMessageAdded, this._messag eAdded, this);
45 }
44 46
45 willHide: function() 47 /**
46 { 48 * @override
47 this._request.removeEventListener(WebInspector.NetworkRequest.Events.Eve ntSourceMessageAdded, this._messageAdded, this); 49 */
48 }, 50 willHide() {
51 this._request.removeEventListener(
52 WebInspector.NetworkRequest.Events.EventSourceMessageAdded, this._messag eAdded, this);
53 }
49 54
50 /** 55 /**
51 * @param {!WebInspector.Event} event 56 * @param {!WebInspector.Event} event
52 */ 57 */
53 _messageAdded: function(event) 58 _messageAdded(event) {
54 { 59 var message = /** @type {!WebInspector.NetworkRequest.EventSourceMessage} */ (event.data);
55 var message = /** @type {!WebInspector.NetworkRequest.EventSourceMessage } */ (event.data); 60 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(message)) ;
56 this._dataGrid.insertChild(new WebInspector.EventSourceMessageNode(messa ge)); 61 }
57 },
58 62
59 _sortItems: function() 63 _sortItems() {
60 { 64 var sortColumnId = this._dataGrid.sortColumnId();
61 var sortColumnId = this._dataGrid.sortColumnId(); 65 if (!sortColumnId)
62 if (!sortColumnId) 66 return;
63 return; 67 var comparator = WebInspector.EventSourceMessageNode.Comparators[sortColumnI d];
64 var comparator = WebInspector.EventSourceMessageNode.Comparators[sortCol umnId]; 68 if (!comparator)
65 if (!comparator) 69 return;
66 return; 70 this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscending()) ;
67 this._dataGrid.sortNodes(comparator, !this._dataGrid.isSortOrderAscendin g()); 71 }
68 },
69
70 __proto__: WebInspector.VBox.prototype
71 }; 72 };
72 73
73 /** 74 /**
74 * @constructor 75 * @unrestricted
75 * @extends {WebInspector.SortableDataGridNode}
76 * @param {!WebInspector.NetworkRequest.EventSourceMessage} message
77 */ 76 */
78 WebInspector.EventSourceMessageNode = function(message) 77 WebInspector.EventSourceMessageNode = class extends WebInspector.SortableDataGri dNode {
79 { 78 /**
79 * @param {!WebInspector.NetworkRequest.EventSourceMessage} message
80 */
81 constructor(message) {
80 var time = new Date(message.time * 1000); 82 var time = new Date(message.time * 1000);
81 var timeText = ("0" + time.getHours()).substr(-2) + ":" + ("0" + time.getMin utes()).substr(-2) + ":" + ("0" + time.getSeconds()).substr(-2) + "." + ("00" + time.getMilliseconds()).substr(-3); 83 var timeText = ('0' + time.getHours()).substr(-2) + ':' + ('0' + time.getMin utes()).substr(-2) + ':' +
82 var timeNode = createElement("div"); 84 ('0' + time.getSeconds()).substr(-2) + '.' + ('00' + time.getMillisecond s()).substr(-3);
85 var timeNode = createElement('div');
83 timeNode.createTextChild(timeText); 86 timeNode.createTextChild(timeText);
84 timeNode.title = time.toLocaleString(); 87 timeNode.title = time.toLocaleString();
85 WebInspector.SortableDataGridNode.call(this, {id: message.eventId, type: mes sage.eventName, data: message.data, time: timeNode}); 88 super({id: message.eventId, type: message.eventName, data: message.data, tim e: timeNode});
86 this._message = message; 89 this._message = message;
87 }; 90 }
88
89 WebInspector.EventSourceMessageNode.prototype = {
90 __proto__: WebInspector.SortableDataGridNode.prototype
91 }; 91 };
92 92
93 /** 93 /**
94 * @param {string} field 94 * @param {string} field
95 * @param {!WebInspector.EventSourceMessageNode} a 95 * @param {!WebInspector.EventSourceMessageNode} a
96 * @param {!WebInspector.EventSourceMessageNode} b 96 * @param {!WebInspector.EventSourceMessageNode} b
97 * @return {number} 97 * @return {number}
98 */ 98 */
99 WebInspector.EventSourceMessageNodeComparator = function(field, a, b) 99 WebInspector.EventSourceMessageNodeComparator = function(field, a, b) {
100 { 100 var aValue = a._message[field];
101 var aValue = a._message[field]; 101 var bValue = b._message[field];
102 var bValue = b._message[field]; 102 return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
103 return aValue < bValue ? -1 : aValue > bValue ? 1 : 0;
104 }; 103 };
105 104
106 /** @type {!Object.<string, !WebInspector.SortableDataGrid.NodeComparator>} */ 105 /** @type {!Object.<string, !WebInspector.SortableDataGrid.NodeComparator>} */
107 WebInspector.EventSourceMessageNode.Comparators = { 106 WebInspector.EventSourceMessageNode.Comparators = {
108 "id": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventId"), 107 'id': WebInspector.EventSourceMessageNodeComparator.bind(null, 'eventId'),
109 "type": WebInspector.EventSourceMessageNodeComparator.bind(null, "eventName" ), 108 'type': WebInspector.EventSourceMessageNodeComparator.bind(null, 'eventName'),
110 "time": WebInspector.EventSourceMessageNodeComparator.bind(null, "time") 109 'time': WebInspector.EventSourceMessageNodeComparator.bind(null, 'time')
111 }; 110 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698