remote_runner: Simplify `append()`
parent
bbb3046a87
commit
7d75e0ef8f
|
@ -102,27 +102,13 @@ $(() => {
|
||||||
|
|
||||||
const $console = $('#console');
|
const $console = $('#console');
|
||||||
const append = (text) => {
|
const append = (text) => {
|
||||||
const oldText = $console.text();
|
const lines = text.split('\n')
|
||||||
|
// Break long lines into multiple lines:
|
||||||
let space = '';
|
.map((line) => line.match(/.{1,100}/g))
|
||||||
for (let i = 0; i < level * 2; i++) {
|
.reduce((soFar, next) => soFar.concat(next), [])
|
||||||
space += ' ';
|
// Indent each line:
|
||||||
}
|
.map((line) => ' '.repeat(level * 2) + line);
|
||||||
|
$console.append(document.createTextNode(`${lines.join('\\n')}\\n`));
|
||||||
let splitedText = '';
|
|
||||||
_(text.split('\n')).each((line) => {
|
|
||||||
while (line.length > 0) {
|
|
||||||
const split = line.substr(0, 100);
|
|
||||||
line = line.substr(100);
|
|
||||||
if (splitedText.length > 0) splitedText += '\n';
|
|
||||||
splitedText += split;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// indent all lines with the given amount of space
|
|
||||||
const newText = _(splitedText.split('\n')).map((line) => space + line).join('\\n');
|
|
||||||
|
|
||||||
$console.text(`${oldText + newText}\\n`);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const total = runner.total;
|
const total = runner.total;
|
||||||
|
|
Loading…
Reference in New Issue