2018-07-05 20:12:20 +02:00
|
|
|
import {killWorkerScript} from "../src/NetscriptWorker";
|
2018-07-08 05:19:19 +02:00
|
|
|
import {clearEventListeners} from "./uiHelpers/clearEventListeners";
|
2018-07-05 20:12:20 +02:00
|
|
|
import {arrayToString} from "./helpers/arrayToString";
|
2017-06-17 20:19:37 +02:00
|
|
|
|
|
|
|
$(document).keydown(function(event) {
|
|
|
|
if (logBoxOpened && event.keyCode == 27) {
|
|
|
|
logBoxClose();
|
|
|
|
}
|
|
|
|
});
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-06-15 03:19:52 +02:00
|
|
|
function logBoxInit() {
|
|
|
|
var closeButton = document.getElementById("log-box-close");
|
|
|
|
logBoxClose();
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-06-15 03:19:52 +02:00
|
|
|
//Close Dialog box
|
|
|
|
closeButton.addEventListener("click", function() {
|
|
|
|
logBoxClose();
|
|
|
|
return false;
|
|
|
|
});
|
2017-11-02 22:47:09 +01:00
|
|
|
document.getElementById("log-box-text-header").style.display = "inline-block";
|
2017-06-15 03:19:52 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
document.addEventListener("DOMContentLoaded", logBoxInit, false);
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function logBoxClose() {
|
2017-06-15 03:19:52 +02:00
|
|
|
logBoxOpened = false;
|
|
|
|
var logBox = document.getElementById("log-box-container");
|
|
|
|
logBox.style.display = "none";
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function logBoxOpen() {
|
2017-06-15 03:19:52 +02:00
|
|
|
logBoxOpened = true;
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2017-06-15 03:19:52 +02:00
|
|
|
var logBox = document.getElementById("log-box-container");
|
|
|
|
logBox.style.display = "block";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var logBoxOpened = false;
|
|
|
|
var logBoxCurrentScript = null;
|
2017-08-30 19:44:29 +02:00
|
|
|
function logBoxCreate(script) {
|
2017-06-15 03:19:52 +02:00
|
|
|
logBoxCurrentScript = script;
|
2017-11-02 22:47:09 +01:00
|
|
|
var killScriptBtn = clearEventListeners("log-box-kill-script");
|
|
|
|
killScriptBtn.addEventListener("click", ()=>{
|
|
|
|
killWorkerScript(script, script.server);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
document.getElementById('log-box-kill-script').style.display = "inline-block";
|
2017-06-15 03:19:52 +02:00
|
|
|
logBoxOpen();
|
2017-09-19 20:38:03 +02:00
|
|
|
document.getElementById("log-box-text-header").innerHTML =
|
2018-07-05 20:12:20 +02:00
|
|
|
logBoxCurrentScript.filename + " " + arrayToString(logBoxCurrentScript.args) + ":<br><br>";
|
2017-11-02 22:47:09 +01:00
|
|
|
logBoxCurrentScript.logUpd = true;
|
2017-06-15 03:19:52 +02:00
|
|
|
logBoxUpdateText();
|
|
|
|
}
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
function logBoxUpdateText() {
|
2017-06-15 03:19:52 +02:00
|
|
|
var txt = document.getElementById("log-box-text");
|
2017-11-02 22:47:09 +01:00
|
|
|
if (logBoxCurrentScript && logBoxOpened && txt && logBoxCurrentScript.logUpd) {
|
2017-09-19 20:38:03 +02:00
|
|
|
txt.innerHTML = "";
|
2017-06-15 03:19:52 +02:00
|
|
|
for (var i = 0; i < logBoxCurrentScript.logs.length; ++i) {
|
|
|
|
txt.innerHTML += logBoxCurrentScript.logs[i];
|
|
|
|
txt.innerHTML += "<br>";
|
|
|
|
}
|
2017-11-02 22:47:09 +01:00
|
|
|
logBoxCurrentScript.logUpd = false;
|
2017-06-15 03:19:52 +02:00
|
|
|
}
|
2017-08-30 19:44:29 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export {logBoxCreate, logBoxUpdateText, logBoxOpened, logBoxCurrentScript};
|