Fixed Netscript interpreter memory issues by breaking promise chains in while and for loops. Improved Stock Market UI. Added a button to kill script from log display box. Added confirm() Netscript function

This commit is contained in:
danielyxie
2017-11-02 16:47:09 -05:00
parent 52967d7f9d
commit bc6f0da677
15 changed files with 753 additions and 354 deletions
+19 -1
View File
@@ -1351,7 +1351,25 @@ function NetscriptFunctions(workerScript) {
return Player.playtimeSinceLastAug;
},
confirm : function(txt) {
if (yesNoBoxOpen) {
workerScript.scriptRef.log("ERROR: confirm() failed because a pop-up dialog box is already open");
return false;
}
if (!isString(txt)) {txt = String(txt);}
var yesBtn = yesNoBoxGetYesButton(), noBtn = yesNoBoxGetNoButton();
yesBtn.innerHTML = "Yes";
noBtn.innerHTML = "No";
return new Promise(function(resolve, reject) {
yesBtn.addEventListener("click", ()=>{
yesNoBoxClose();
resolve(true);
});
noBtn.addEventListener("click", ()=>{
yesNoBoxClose();
resolve(false);
});
yesNoBoxCreate(txt);
});
},
/* Singularity Functions */