mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-25 07:32:27 +01:00
Merge pull request #246 from danielyxie/dev
scp Terminal command and Active Scripts UI (hopefully) bug fixes
This commit is contained in:
commit
ae509cf50d
493
dist/engine.bundle.js
vendored
493
dist/engine.bundle.js
vendored
File diff suppressed because one or more lines are too long
585
dist/tests.bundle.js
vendored
585
dist/tests.bundle.js
vendored
File diff suppressed because one or more lines are too long
@ -26,58 +26,54 @@ let ActiveScriptsUI = {};
|
|||||||
let ActiveScriptsTasks = []; //Sequentially schedule the creation/deletion of UI elements
|
let ActiveScriptsTasks = []; //Sequentially schedule the creation/deletion of UI elements
|
||||||
|
|
||||||
function createActiveScriptsServerPanel(server) {
|
function createActiveScriptsServerPanel(server) {
|
||||||
ActiveScriptsTasks.push(function(server) {
|
let hostname = server.hostname;
|
||||||
let hostname = server.hostname;
|
|
||||||
|
|
||||||
var activeScriptsList = document.getElementById("active-scripts-list");
|
var activeScriptsList = document.getElementById("active-scripts-list");
|
||||||
|
|
||||||
let res = createAccordionElement({hdrText:hostname});
|
let res = createAccordionElement({hdrText:hostname});
|
||||||
let li = res[0];
|
let li = res[0];
|
||||||
var hdr = res[1];
|
var hdr = res[1];
|
||||||
let panel = res[2];
|
let panel = res[2];
|
||||||
|
|
||||||
if (ActiveScriptsUI[hostname] != null) {
|
if (ActiveScriptsUI[hostname] != null) {
|
||||||
console.log("WARNING: Tried to create already-existing Active Scripts Server panel. This is most likely fine. It probably means many scripts just got started up on a new server. Aborting");
|
console.log("WARNING: Tried to create already-existing Active Scripts Server panel. This is most likely fine. It probably means many scripts just got started up on a new server. Aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var panelScriptList = createElement("ul");
|
var panelScriptList = createElement("ul");
|
||||||
panel.appendChild(panelScriptList);
|
panel.appendChild(panelScriptList);
|
||||||
activeScriptsList.appendChild(li);
|
activeScriptsList.appendChild(li);
|
||||||
|
|
||||||
ActiveScriptsUI[hostname] = {
|
ActiveScriptsUI[hostname] = {
|
||||||
header: hdr,
|
header: hdr,
|
||||||
panel: panel,
|
panel: panel,
|
||||||
panelList: panelScriptList,
|
panelList: panelScriptList,
|
||||||
scripts: {}, //Holds references to li elements for each active script
|
scripts: {}, //Holds references to li elements for each active script
|
||||||
scriptHdrs: {}, //Holds references to header elements for each active script
|
scriptHdrs: {}, //Holds references to header elements for each active script
|
||||||
scriptStats: {} //Holds references to the p elements containing text for each active script
|
scriptStats: {} //Holds references to the p elements containing text for each active script
|
||||||
};
|
};
|
||||||
|
|
||||||
return li;
|
return li;
|
||||||
}.bind(null, server));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Deletes the info for a particular server (Dropdown header + Panel with all info)
|
//Deletes the info for a particular server (Dropdown header + Panel with all info)
|
||||||
//in the Active Scripts page if it exists
|
//in the Active Scripts page if it exists
|
||||||
function deleteActiveScriptsServerPanel(server) {
|
function deleteActiveScriptsServerPanel(server) {
|
||||||
ActiveScriptsTasks.push(function(server) {
|
let hostname = server.hostname;
|
||||||
let hostname = server.hostname;
|
if (ActiveScriptsUI[hostname] == null) {
|
||||||
if (ActiveScriptsUI[hostname] == null) {
|
console.log("WARNING: Tried to delete non-existent Active Scripts Server panel. Aborting");
|
||||||
console.log("WARNING: Tried to delete non-existent Active Scripts Server panel. Aborting");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//Make sure it's empty
|
//Make sure it's empty
|
||||||
if (Object.keys(ActiveScriptsUI[hostname].scripts).length > 0) {
|
if (Object.keys(ActiveScriptsUI[hostname].scripts).length > 0) {
|
||||||
console.log("WARNING: Tried to delete Active Scripts Server panel that still has scripts. Aborting");
|
console.log("WARNING: Tried to delete Active Scripts Server panel that still has scripts. Aborting");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
removeElement(ActiveScriptsUI[hostname].panel);
|
removeElement(ActiveScriptsUI[hostname].panel);
|
||||||
removeElement(ActiveScriptsUI[hostname].header);
|
removeElement(ActiveScriptsUI[hostname].header);
|
||||||
delete ActiveScriptsUI[hostname];
|
delete ActiveScriptsUI[hostname];
|
||||||
}.bind(null, server));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addActiveScriptsItem(workerscript) {
|
function addActiveScriptsItem(workerscript) {
|
||||||
@ -87,11 +83,12 @@ function addActiveScriptsItem(workerscript) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let hostname = server.hostname;
|
let hostname = server.hostname;
|
||||||
if (ActiveScriptsUI[hostname] == null) {
|
|
||||||
createActiveScriptsServerPanel(server);
|
|
||||||
}
|
|
||||||
|
|
||||||
ActiveScriptsTasks.push(function(workerscript, hostname) {
|
ActiveScriptsTasks.push(function(workerscript, hostname) {
|
||||||
|
if (ActiveScriptsUI[hostname] == null) {
|
||||||
|
createActiveScriptsServerPanel(server);
|
||||||
|
}
|
||||||
|
|
||||||
//Create the unique identifier (key) for this script
|
//Create the unique identifier (key) for this script
|
||||||
var itemNameArray = ["active", "scripts", hostname, workerscript.name];
|
var itemNameArray = ["active", "scripts", hostname, workerscript.name];
|
||||||
for (var i = 0; i < workerscript.args.length; ++i) {
|
for (var i = 0; i < workerscript.args.length; ++i) {
|
||||||
|
@ -1432,7 +1432,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
var stock = SymbolToStockMap[symbol];
|
var stock = SymbolToStockMap[symbol];
|
||||||
if (stock == null) {
|
if (stock == null) {
|
||||||
throw makeRuntimeRejectMsg(workerScript, "Invalid stock symbol passed into getStockPrice()");
|
throw makeRuntimeRejectMsg(workerScript, "Invalid stock symbol passed into getStockPosition()");
|
||||||
}
|
}
|
||||||
return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx];
|
return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx];
|
||||||
},
|
},
|
||||||
|
@ -1379,7 +1379,7 @@ let Terminal = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var scriptname = args[0];
|
var scriptname = args[0];
|
||||||
if (!scriptname.endsWith(".lit") && !isScriptFilename(scriptName) &&
|
if (!scriptname.endsWith(".lit") && !isScriptFilename(scriptname) &&
|
||||||
!scriptname.endsWith(".txt")){
|
!scriptname.endsWith(".txt")){
|
||||||
post("Error: scp only works for .script, .txt, and .lit files");
|
post("Error: scp only works for .script, .txt, and .lit files");
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user