Debug output viewer tweaks
- Decrease font size - Do a better job of pinning to bottom - Disable submit button when clearing output - Filter ANSI color codes from slow lines
This commit is contained in:
parent
eb1cecf404
commit
e3947e7b45
|
@ -55,7 +55,7 @@
|
||||||
margin-top: 38px;
|
margin-top: 38px;
|
||||||
padding: 10px 9px;
|
padding: 10px 9px;
|
||||||
font-family: Monaco, Consolas, Inconsolata, monospace;
|
font-family: Monaco, Consolas, Inconsolata, monospace;
|
||||||
font-size: 9pt;
|
font-size: 8pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
#errors {
|
#errors {
|
||||||
|
|
|
@ -3,8 +3,18 @@
|
||||||
var interval = 1000;
|
var interval = 1000;
|
||||||
var intervalID;
|
var intervalID;
|
||||||
var stopping = false;
|
var stopping = false;
|
||||||
|
var scrolling = false;
|
||||||
|
var autoscroll = true;
|
||||||
|
|
||||||
function start() {
|
function start() {
|
||||||
|
// If scrolled to the bottom of the page, stay there
|
||||||
|
document.body.onscroll = function (event) {
|
||||||
|
if (!scrolling) {
|
||||||
|
autoscroll = atPageBottom();
|
||||||
|
}
|
||||||
|
scrolling = false;
|
||||||
|
};
|
||||||
|
|
||||||
updateErrors().then(function () {
|
updateErrors().then(function () {
|
||||||
if (stopping) return;
|
if (stopping) return;
|
||||||
|
|
||||||
|
@ -31,13 +41,9 @@ function updateErrors() {
|
||||||
var errors = Zotero.getErrors(true);
|
var errors = Zotero.getErrors(true);
|
||||||
var errorStr = errors.length ? errors.join('\n\n') + '\n\n' : '';
|
var errorStr = errors.length ? errors.join('\n\n') + '\n\n' : '';
|
||||||
|
|
||||||
var scroll = atPageBottom();
|
|
||||||
|
|
||||||
document.getElementById('errors').textContent = errorStr + sysInfo;
|
document.getElementById('errors').textContent = errorStr + sysInfo;
|
||||||
|
|
||||||
// TODO: This doesn't seem to work for some reason -- when errors are logged, it doesn't stay
|
if (autoscroll) {
|
||||||
// at the bottom
|
|
||||||
if (scroll) {
|
|
||||||
scrollToPageBottom();
|
scrollToPageBottom();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -50,15 +56,12 @@ function addInitialOutput() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function addLine(line) {
|
function addLine(line) {
|
||||||
var scroll = atPageBottom()
|
|
||||||
|
|
||||||
var p = document.createElement('p');
|
var p = document.createElement('p');
|
||||||
p.textContent = line;
|
p.textContent = line;
|
||||||
var output = document.getElementById('output');
|
var output = document.getElementById('output');
|
||||||
output.appendChild(p);
|
output.appendChild(p);
|
||||||
|
|
||||||
// If scrolled to the bottom of the page, stay there
|
if (autoscroll) {
|
||||||
if (scroll) {
|
|
||||||
scrollToPageBottom();
|
scrollToPageBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,6 +74,8 @@ function atPageBottom() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function scrollToPageBottom() {
|
function scrollToPageBottom() {
|
||||||
|
// Set a flag when auto-scrolling to differentiate from manual scrolls
|
||||||
|
scrolling = true;
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,6 +185,7 @@ function clearSubmitStatus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearOutput(button) {
|
function clearOutput(button) {
|
||||||
|
document.getElementById('submit-button').setAttribute('disabled', '');
|
||||||
button.setAttribute('disabled', '');
|
button.setAttribute('disabled', '');
|
||||||
document.getElementById('output').textContent = '';
|
document.getElementById('output').textContent = '';
|
||||||
clearSubmitStatus();
|
clearSubmitStatus();
|
||||||
|
|
|
@ -151,6 +151,13 @@ Zotero.Debug = new function () {
|
||||||
}
|
}
|
||||||
// Console window
|
// Console window
|
||||||
if (_consoleViewer) {
|
if (_consoleViewer) {
|
||||||
|
// Remove ANSI color codes. We could replace this with HTML, but it's probably
|
||||||
|
// unnecessarily distracting/alarming to show the red in the viewer. Devs who care
|
||||||
|
// about times should just use a terminal.
|
||||||
|
if (slowPrefix) {
|
||||||
|
output = output.replace(slowPrefix, '').replace(slowSuffix, '');
|
||||||
|
}
|
||||||
|
|
||||||
// If there's a listener, pass line immediately
|
// If there's a listener, pass line immediately
|
||||||
if (_consoleViewerListener) {
|
if (_consoleViewerListener) {
|
||||||
_consoleViewerListener(output);
|
_consoleViewerListener(output);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user