| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 var DetailsView = (function() { | 5 var DetailsView = (function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 // We inherit from DivView. | 8 // We inherit from DivView. |
| 9 var superClass = DivView; | 9 var superClass = DivView; |
| 10 | 10 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 __proto__: superClass.prototype, | 34 __proto__: superClass.prototype, |
| 35 | 35 |
| 36 setData: function(sourceEntries) { | 36 setData: function(sourceEntries) { |
| 37 // Make a copy of the array (in case the caller mutates it), and sort it | 37 // Make a copy of the array (in case the caller mutates it), and sort it |
| 38 // by the source ID. | 38 // by the source ID. |
| 39 this.sourceEntries_ = createSortedCopy_(sourceEntries); | 39 this.sourceEntries_ = createSortedCopy_(sourceEntries); |
| 40 | 40 |
| 41 // Repaint the view. | 41 // Repaint the view. |
| 42 if (this.isVisible() && !this.outstandingRepaint_) { | 42 if (this.isVisible() && !this.outstandingRepaint_) { |
| 43 this.outstandingRepaint_ = true; | 43 this.outstandingRepaint_ = true; |
| 44 window.setTimeout(this.repaint.bind(this), | 44 window.setTimeout(this.repaint.bind(this), REPAINT_TIMEOUT_MS); |
| 45 REPAINT_TIMEOUT_MS); | |
| 46 } | 45 } |
| 47 }, | 46 }, |
| 48 | 47 |
| 49 repaint: function() { | 48 repaint: function() { |
| 50 this.outstandingRepaint_ = false; | 49 this.outstandingRepaint_ = false; |
| 51 this.sourceIdToDivMap_ = {}; | 50 this.sourceIdToDivMap_ = {}; |
| 52 this.getNode().innerHTML = ''; | 51 this.getNode().innerHTML = ''; |
| 53 | 52 |
| 54 var node = this.getNode(); | 53 var node = this.getNode(); |
| 55 | 54 |
| 56 for (var i = 0; i < this.sourceEntries_.length; ++i) { | 55 for (var i = 0; i < this.sourceEntries_.length; ++i) { |
| 57 if (i != 0) | 56 if (i != 0) |
| 58 addNode(node, 'hr'); | 57 addNode(node, 'hr'); |
| 59 | 58 |
| 60 var sourceEntry = this.sourceEntries_[i]; | 59 var sourceEntry = this.sourceEntries_[i]; |
| 61 var div = addNode(node, 'div'); | 60 var div = addNode(node, 'div'); |
| 62 div.className = 'log-source-entry'; | 61 div.className = 'log-source-entry'; |
| 63 | 62 |
| 64 var p = addNode(div, 'p'); | 63 var p = addNode(div, 'p'); |
| 65 addNodeWithText(p, 'h4', | 64 addNodeWithText( |
| 66 sourceEntry.getSourceId() + ': ' + | 65 p, 'h4', sourceEntry.getSourceId() + ': ' + |
| 67 sourceEntry.getSourceTypeString()); | 66 sourceEntry.getSourceTypeString()); |
| 68 | 67 |
| 69 if (sourceEntry.getDescription()) | 68 if (sourceEntry.getDescription()) |
| 70 addNodeWithText(p, 'h4', sourceEntry.getDescription()); | 69 addNodeWithText(p, 'h4', sourceEntry.getDescription()); |
| 71 | 70 |
| 72 var logEntries = sourceEntry.getLogEntries(); | 71 var logEntries = sourceEntry.getLogEntries(); |
| 73 var startDate = timeutil.convertTimeTicksToDate(logEntries[0].time); | 72 var startDate = timeutil.convertTimeTicksToDate(logEntries[0].time); |
| 74 var startTimeDiv = addNodeWithText(p, 'div', 'Start Time: '); | 73 var startTimeDiv = addNodeWithText(p, 'div', 'Start Time: '); |
| 75 timeutil.addNodeWithDate(startTimeDiv, startDate); | 74 timeutil.addNodeWithDate(startTimeDiv, startDate); |
| 76 | 75 |
| 77 sourceEntry.printAsText(div); | 76 sourceEntry.printAsText(div); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 function createSortedCopy_(origArray) { | 111 function createSortedCopy_(origArray) { |
| 113 var sortedArray = origArray.slice(0); | 112 var sortedArray = origArray.slice(0); |
| 114 sortedArray.sort(function(a, b) { | 113 sortedArray.sort(function(a, b) { |
| 115 return a.getSourceId() - b.getSourceId(); | 114 return a.getSourceId() - b.getSourceId(); |
| 116 }); | 115 }); |
| 117 return sortedArray; | 116 return sortedArray; |
| 118 } | 117 } |
| 119 | 118 |
| 120 return DetailsView; | 119 return DetailsView; |
| 121 })(); | 120 })(); |
| OLD | NEW |