Scaffold: Improve perceived translation speed
When translators do a lot of logging. https://github.com/zotero/translators/pull/3022#issuecomment-1517291971
This commit is contained in:
parent
fb2d35c765
commit
c07eccb468
1 changed files with 10 additions and 4 deletions
|
@ -1170,13 +1170,19 @@ var Scaffold = new function () {
|
||||||
string = fix2028(Zotero.Utilities.varDump(string));
|
string = fix2028(Zotero.Utilities.varDump(string));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output.value) output.value += "\n";
|
// Put off actually building the log message and appending it to the console until the next animation frame
|
||||||
output.value += Zotero.Utilities.lpad(date.getHours(), '0', 2)
|
// so as not to slow down translation with repeated layout recalculations triggered by appending text
|
||||||
|
// and accessing scrollHeight
|
||||||
|
// requestAnimationFrame() callbacks are guaranteed to be called in the order they were set
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
if (output.value) output.value += "\n";
|
||||||
|
output.value += Zotero.Utilities.lpad(date.getHours(), '0', 2)
|
||||||
+ ":" + Zotero.Utilities.lpad(date.getMinutes(), '0', 2)
|
+ ":" + Zotero.Utilities.lpad(date.getMinutes(), '0', 2)
|
||||||
+ ":" + Zotero.Utilities.lpad(date.getSeconds(), '0', 2)
|
+ ":" + Zotero.Utilities.lpad(date.getSeconds(), '0', 2)
|
||||||
+ " " + string.replace(/\n/g, "\n ");
|
+ " " + string.replace(/\n/g, "\n ");
|
||||||
// move to end
|
// move to end
|
||||||
output.scrollTop = output.scrollHeight;
|
output.scrollTop = output.scrollHeight;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue