| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 /** | 5 /** |
| 6 * This view displays options for importing/exporting the captured data. Its | 6 * This view displays options for importing/exporting the captured data. Its |
| 7 * primarily usefulness is to allow users to copy-paste their data in an easy | 7 * primarily usefulness is to allow users to copy-paste their data in an easy |
| 8 * to read format for bug reports. | 8 * to read format for bug reports. |
| 9 * | 9 * |
| 10 * - Has a button to generate a text report. | 10 * - Has a button to generate a text report. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 this.passivelyCapturedCountBox_ = | 46 this.passivelyCapturedCountBox_ = |
| 47 document.getElementById(passivelyCapturedCountId); | 47 document.getElementById(passivelyCapturedCountId); |
| 48 document.getElementById(deleteAllId).onclick = | 48 document.getElementById(deleteAllId).onclick = |
| 49 g_browser.deleteAllEvents.bind(g_browser); | 49 g_browser.deleteAllEvents.bind(g_browser); |
| 50 | 50 |
| 51 this.dumpDataDiv_ = document.getElementById(dumpDataDivId); | 51 this.dumpDataDiv_ = document.getElementById(dumpDataDivId); |
| 52 this.loadDataDiv_ = document.getElementById(loadDataDivId); | 52 this.loadDataDiv_ = document.getElementById(loadDataDivId); |
| 53 this.capturingTextSpan_ = document.getElementById(capturingTextSpanId); | 53 this.capturingTextSpan_ = document.getElementById(capturingTextSpanId); |
| 54 this.loggingTextSpan_ = document.getElementById(loggingTextSpanId); | 54 this.loggingTextSpan_ = document.getElementById(loggingTextSpanId); |
| 55 | 55 |
| 56 document.getElementById(loadLogFileId).onclick = | 56 var loadLogFileElement = document.getElementById(loadLogFileId); |
| 57 g_browser.loadLogFile.bind(g_browser); | 57 loadLogFileElement.onchange = |
| 58 this.logFileChanged.bind(this, loadLogFileElement); |
| 58 | 59 |
| 59 this.updateEventCounts_(); | 60 this.updateEventCounts_(); |
| 60 this.waitingForUpdate_ = false; | 61 this.waitingForUpdate_ = false; |
| 61 | 62 |
| 62 g_browser.addLogObserver(this); | 63 g_browser.addLogObserver(this); |
| 63 } | 64 } |
| 64 | 65 |
| 65 inherits(DataView, DivView); | 66 inherits(DataView, DivView); |
| 66 | 67 |
| 67 /** | 68 /** |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 }; | 131 }; |
| 131 | 132 |
| 132 /** | 133 /** |
| 133 * Clears displayed text when security stripping is toggled. | 134 * Clears displayed text when security stripping is toggled. |
| 134 */ | 135 */ |
| 135 DataView.prototype.onSecurityStrippingChanged = function() { | 136 DataView.prototype.onSecurityStrippingChanged = function() { |
| 136 this.setText_(''); | 137 this.setText_(''); |
| 137 } | 138 } |
| 138 | 139 |
| 139 /** | 140 /** |
| 141 * Called when a log file is selected. |
| 142 * |
| 143 * Gets the log file from the input element and tries to read from it. |
| 144 */ |
| 145 DataView.prototype.logFileChanged = function(loadLogFileElement) { |
| 146 var logFile = loadLogFileElement.files[0]; |
| 147 if (logFile) { |
| 148 var fileReader = new FileReader(); |
| 149 |
| 150 fileReader.onload = this.onLoadLogFile.bind(this); |
| 151 fileReader.onerror = this.onLoadLogFileError.bind(this); |
| 152 |
| 153 fileReader.readAsText(logFile); |
| 154 } |
| 155 } |
| 156 |
| 157 /** |
| 158 * Displays an error message when unable to read the selected log file. |
| 159 */ |
| 160 DataView.prototype.onLoadLogFileError = function(event) { |
| 161 alert('Error ' + event.target.error.code + '. Unable to load file.'); |
| 162 } |
| 163 |
| 164 /** |
| 165 * Tries to load the contents of the log file. |
| 166 */ |
| 167 DataView.prototype.onLoadLogFile = function(event) { |
| 168 g_browser.loadedLogFile(event.target.result); |
| 169 } |
| 170 |
| 171 /** |
| 140 * If not already waiting for results from all updates, triggers all | 172 * If not already waiting for results from all updates, triggers all |
| 141 * updates and starts waiting for them to complete. | 173 * updates and starts waiting for them to complete. |
| 142 */ | 174 */ |
| 143 DataView.prototype.onExportToText_ = function() { | 175 DataView.prototype.onExportToText_ = function() { |
| 144 if (this.waitingForUpdate_) | 176 if (this.waitingForUpdate_) |
| 145 return; | 177 return; |
| 146 this.waitingForUpdate = true; | 178 this.waitingForUpdate = true; |
| 147 this.setText_('Generating...'); | 179 this.setText_('Generating...'); |
| 148 g_browser.updateAllInfo(this.onUpdateAllCompleted.bind(this)); | 180 g_browser.updateAllInfo(this.onUpdateAllCompleted.bind(this)); |
| 149 }; | 181 }; |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 * Select all text from log dump. | 500 * Select all text from log dump. |
| 469 */ | 501 */ |
| 470 DataView.prototype.selectText_ = function() { | 502 DataView.prototype.selectText_ = function() { |
| 471 var selection = window.getSelection(); | 503 var selection = window.getSelection(); |
| 472 selection.removeAllRanges(); | 504 selection.removeAllRanges(); |
| 473 | 505 |
| 474 var range = document.createRange(); | 506 var range = document.createRange(); |
| 475 range.selectNodeContents(this.textPre_); | 507 range.selectNodeContents(this.textPre_); |
| 476 selection.addRange(range); | 508 selection.addRange(range); |
| 477 }; | 509 }; |
| OLD | NEW |