website/js/error.js

42 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-01-20 23:22:18 +01:00
let intervalTime = 150;
let dataIndex = 0;
let stringPosition = 0;
2021-03-24 22:18:55 +01:00
let printTask;
2021-01-20 23:22:18 +01:00
2021-03-24 22:18:55 +01:00
let terminal;
let historyContainer;
let promptContainer;
2021-02-28 14:09:57 +01:00
2021-01-20 23:22:18 +01:00
function writeOut() {
2021-03-24 22:18:55 +01:00
let currentData = data[dataIndex];
let currentText = currentData["strings"];
2021-01-20 23:22:18 +01:00
promptContainer.innerText = promptContainer.innerText + currentText.charAt(stringPosition);
stringPosition++;
if(stringPosition > currentText.length){
stringPosition = 0
dataIndex++;
historyContainer.innerHTML = historyContainer.innerHTML + "$&nbsp;" + promptContainer.innerHTML + "<br><span class=\"gray\">" + currentData["output"] + "</span><br><br>";
promptContainer.innerHTML = "";
clearInterval(printTask);
// @ts-ignore
2021-01-20 23:22:18 +01:00
if(dataIndex < data.length){
// @ts-ignore
2021-01-20 23:22:18 +01:00
setTimeout(startNewTask, data[dataIndex - 1].postDelay);
}
}
}
function startNewTask() {
2021-03-24 22:18:55 +01:00
terminal = document.getElementsByClassName("terminal")[0];
historyContainer = terminal.getElementsByClassName("history")[0];
promptContainer = terminal.getElementsByClassName("prompt")[0];
2021-02-28 14:09:57 +01:00
printTask = setInterval(writeOut, intervalTime);
2021-03-24 23:50:27 +01:00
}
if(document.querySelector(".terminal-window") != null){
startNewTask();
2021-02-28 14:09:57 +01:00
}