Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const started = moment(session.started).format('D MMM HH:mm');
const completed = session.newlyCompleted.toLocaleString();
var ttc = '---';
if(session.eta){
ttc = moment().to(moment(session.eta), true);
}
var rate = '---';
if(session.velocity){
rate = Math.round((60*60*1000)/session.velocity).toLocaleString() + ' / hour';
}
var str = `^-Started: ^:${started} ^-Completed: ^:${completed} ^-Rate: ^:${rate} ^-TTC: ^:${ttc}`;
// Output
term.restoreCursor();
term.column(0).move(0, 4-numLines).eraseLine();
term(str);
term.restoreCursor();
}
function showProgressMeter(){
// The meter
var len = 70;
var left = Array(Math.round(len*session.pctComplete)).join('=');
var right = Array(1+len-Math.round(len*session.pctComplete)).join('-');
var completed = session.completed.toLocaleString();
var total = session.total.toLocaleString();
// The string
var pctStr = Math.floor(session.pctComplete * 100);
var str = `Progress [^g${left}^:^-${right}^:] ${pctStr}% [^g${completed}^: / ${total}]`;
// Output
term.restoreCursor();
term.column(0).move(0, 3-numLines).eraseLine();
term(str);
term.restoreCursor();
}
function writeLine(n, message){
// Sanitize the message
message = message.replace(/[\r\n]/g, ''); // Strip newlines
message = message.substring(0, maxLength); // Clip the length
// Write
initOnce();
term.restoreCursor();
term.column(0).move(0, n-numLines).eraseLine();
term(message);
term.restoreCursor();
}
function status(stat) {
if (showStatus) {
term.saveCursor();
term.moveTo.bgWhite.black(1, 1).eraseLine();
term(stat);
term.white.bgBlack();
term.restoreCursor();
}
}
menu.on( 'submit' , data => {
term.saveCursor() ;
term.moveTo( 1 , term.height - 1 , "Submit: %s" , data.selectedText ) ;
term.restoreCursor() ;
} ) ;
})
companyBarContent += barContentString
term.moveTo(1, playerLines + 1)
let companyLines = Math.ceil(companyBarContent.length / term.width)
for (let line = 1; line <= companyLines; line += 1) {
term.bgYellow()
term.black()
term(new Array(term.width + 1).join(" "))
term.nextLine()
}
term.moveTo(1, playerLines + 1)
term(companyBarContent)
term.restoreCursor()
}