Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // Maximum numer of lines to record in the debug log. | |
| 6 // Only the most recent <n> lines are displayed. | |
| 7 var MAX_DEBUG_LOG_SIZE = 1000; | |
| 8 | |
| 9 function toggleDebugLog() { | |
| 10 debugLog = document.getElementById('debug-log'); | |
| 11 toggleButton = document.getElementById('debug-log-toggle'); | |
| 12 | |
| 13 if (!debugLog.style.display || debugLog.style.display == 'none') { | |
|
Jamie
2011/06/07 18:58:32
I've used class='hidden' elsewhere to avoid changi
garykac
2011/06/07 20:44:32
Good point. However, it doesn't seem worth entangl
| |
| 14 debugLog.style.display = 'block'; | |
| 15 toggleButton.value = 'Hide Debug Log'; | |
|
Jamie
2011/06/07 18:58:32
Is this the only place we have display strings in
garykac
2011/06/07 20:44:32
Changed to simply "Debug log" so that the button i
| |
| 16 } else { | |
| 17 debugLog.style.display = 'none'; | |
| 18 toggleButton.value = 'Show Debug Log'; | |
| 19 } | |
| 20 } | |
| 21 | |
| 22 /** | |
| 23 * Add the given message to the debug log. | |
| 24 * | |
| 25 * @param {string} message The debug info to add to the log. | |
| 26 */ | |
| 27 function addToDebugLog(message) { | |
| 28 var debugLog = document.getElementById('debug-log'); | |
| 29 | |
| 30 // Remove lines from top if we've hit our max log size. | |
| 31 if (debugLog.childNodes.length == MAX_DEBUG_LOG_SIZE) { | |
| 32 debugLog.removeChild(debugLog.firstChild); | |
| 33 } | |
| 34 | |
| 35 // Add the new <p> to the end of the debug log. | |
| 36 var p = document.createElement('p'); | |
| 37 p.appendChild(document.createTextNode(message)); | |
| 38 debugLog.appendChild(p); | |
| 39 | |
| 40 // Scroll to bottom of div | |
| 41 debugLog.scrollTop = debugLog.scrollHeight; | |
| 42 } | |
| OLD | NEW |