mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 21:53:50 +01:00
commit
4b9b3f9002
@ -56,6 +56,12 @@
|
||||
display: flex;
|
||||
}
|
||||
|
||||
#terminal-input-td textarea {
|
||||
overflow: hidden;
|
||||
resize:none;
|
||||
height:auto;
|
||||
}
|
||||
|
||||
#terminal-input-header {
|
||||
white-space: pre;
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ v0.40.2 - 8/27/2018
|
||||
* There are now, on average, more Synthoid communities in a city
|
||||
* If automation is enabled (the feature in Bladeburner console), then switching to another action such as working for a company will now disable the automation
|
||||
* Stock Market Changes:
|
||||
*Added a watchlist filter feature to the UI that allows you to specify which stocks to show
|
||||
*Added the Four Sigma (4S) Market Data feed, which provides volatility and price forecast information about stocks
|
||||
*Added the 4S Market Data TIX API, which lets you access the aforementioned data through Netscript
|
||||
* Added a watchlist filter feature to the UI that allows you to specify which stocks to show
|
||||
* Added the Four Sigma (4S) Market Data feed, which provides volatility and price forecast information about stocks
|
||||
* Added the 4S Market Data TIX API, which lets you access the aforementioned data through Netscript
|
||||
* There is now a setting for enabling/disabling the popup that appears when you are hospitalized
|
||||
* Bug Fix: Stock market should now be correctly initialized in BitNode-8 (by Kline-)
|
||||
* Bug Fix: bladeburner.getCurrentAction() should now properly an 'Idle' object rather than null (by Kline-)
|
||||
|
@ -412,3 +412,18 @@ Then it could be removed using::
|
||||
$ unalias "r"
|
||||
|
||||
It is not necessary to differentiate between global and non-global aliases when using 'unalias'
|
||||
|
||||
wget
|
||||
^^^^
|
||||
|
||||
$ wget [url] [target file]
|
||||
|
||||
Retrieves data from a url and downloads it to a file on the current server.
|
||||
The data can only be downloaded to a script (.script, .ns, .js) or a text file
|
||||
(.txt). If the target file already exists, it will be overwritten by this command.
|
||||
|
||||
Note that will not be possible to download data from many websites because they
|
||||
do not allow cross-origin origin sharing (CORS). This includes websites such
|
||||
as gist and pastebin. One notable site it will work on is rawgithub. Example::
|
||||
|
||||
$ wget https://raw.githubusercontent.com/danielyxie/bitburner/master/README.md game_readme.txt
|
||||
|
@ -101,7 +101,7 @@ let NetscriptFunctions =
|
||||
"getActionMaxLevel|getActionCurrentLevel|getActionAutolevel|" +
|
||||
"setActionAutolevel|setActionLevel|" +
|
||||
"getRank|getSkillPoints|getSkillLevel|getSkillUpgradeCost|" +
|
||||
"upgradeSkill|getTeamSize|" +
|
||||
"upgradeSkill|getTeamSize|getCity|" +
|
||||
"setTeamSize|getCityEstimatedPopulation|getCityEstimatedCommunities|" +
|
||||
"getCityChaos|switchCity|getStamina|joinBladeburnerFaction|getBonusTime";
|
||||
|
||||
|
5
package-lock.json
generated
5
package-lock.json
generated
@ -608,6 +608,11 @@
|
||||
"postcss-value-parser": "3.3.0"
|
||||
}
|
||||
},
|
||||
"autosize": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/autosize/-/autosize-4.0.2.tgz",
|
||||
"integrity": "sha512-jnSyH2d+qdfPGpWlcuhGiHmqBJ6g3X+8T+iRwFrHPLVcdoGJE/x6Qicm6aDHfTsbgZKxyV8UU/YB2p4cjKDRRA=="
|
||||
},
|
||||
"aws-sign2": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.6.0.tgz",
|
||||
|
@ -11,6 +11,7 @@
|
||||
"ajv": "^5.1.5",
|
||||
"ajv-keywords": "^2.0.0",
|
||||
"async": "^2.6.1",
|
||||
"autosize": "^4.0.2",
|
||||
"bluebird": "^3.5.1",
|
||||
"brace": "^0.11.1",
|
||||
"decimal.js": "7.2.3",
|
||||
|
@ -511,6 +511,8 @@ let CONSTANTS = {
|
||||
* Updated documentation to reflect the fact that Netscript port handles (getPortHandle()) only works in NetscriptJS (2.0), NOT Netscript 1.0<br>
|
||||
* Added tryWrite() Netscript function<br>
|
||||
* When working (for a company/faction), experience is gained immediately/continuously rather than all at once when the work is finished<br>
|
||||
* Added a setting in .fconf for enabling line-wrap in the Terminal input<br>
|
||||
* Added 'wget' Terminal command<br>
|
||||
* Improved the introductory tutorial`
|
||||
}
|
||||
|
||||
|
11
src/Fconf.js
11
src/Fconf.js
@ -1,8 +1,9 @@
|
||||
import {parse, Node} from "../utils/acorn";
|
||||
|
||||
var FconfSettings = {
|
||||
ENABLE_BASH_HOTKEYS: false,
|
||||
ENABLE_TIMESTAMPS: false,
|
||||
ENABLE_BASH_HOTKEYS: false,
|
||||
ENABLE_TIMESTAMPS: false,
|
||||
WRAP_INPUT: false,
|
||||
}
|
||||
|
||||
var FconfComments = {
|
||||
@ -15,6 +16,11 @@ var FconfComments = {
|
||||
"http://bitburner.readthedocs.io/en/latest/shortcuts.html",
|
||||
ENABLE_TIMESTAMPS: "Terminal commands and log entries will be timestamped. The timestamp\n" +
|
||||
"will have the format: M/D h:m",
|
||||
WRAP_INPUT: "Wrap Terminal Input. If this is enabled, then when a Terminal command is\n" +
|
||||
"too long and overflows, then it will wrap to the next line instead of\n" +
|
||||
"side-scrolling\n\n" +
|
||||
"Note that after you enable/disable this, you'll have to run a command\n" +
|
||||
"before its effect takes place.",
|
||||
}
|
||||
|
||||
//Parse Fconf settings from the config text
|
||||
@ -74,6 +80,7 @@ function parseFconfSetting(setting, value) {
|
||||
switch(setting) {
|
||||
case "ENABLE_BASH_HOTKEYS":
|
||||
case "ENABLE_TIMESTAMPS":
|
||||
case "WRAP_INPUT":
|
||||
var value = value.toLowerCase();
|
||||
if (value === "1" || value === "true" || value === "y") {
|
||||
value = true;
|
||||
|
@ -32,7 +32,8 @@ export const TerminalHelpText: string =
|
||||
"tail [script] [args...] Displays dynamic logs for the specified script<br>" +
|
||||
"theme [preset] | bg txt hlgt Change the color scheme of the UI<br>" +
|
||||
"top Displays all running scripts and their RAM usage<br>" +
|
||||
'unalias "[alias name]" Deletes the specified alias<br>';
|
||||
'unalias "[alias name]" Deletes the specified alias<br>' +
|
||||
'wget [url] [target file] Retrieves code/text from a web server<br>';
|
||||
|
||||
interface IMap<T> {
|
||||
[key: string]: T;
|
||||
@ -214,5 +215,11 @@ export const HelpTexts: IMap<string> = {
|
||||
"Then it could be removed using:<br><br>" +
|
||||
'unalias "r"<br><br>' +
|
||||
"It is not necessary to differentiate between global and non-global aliases when using 'unalias'",
|
||||
|
||||
wget: "wget [url] [target file]<br>" +
|
||||
"Retrieves data from a URL and downloads it to a file on the current server. The data can only " +
|
||||
"be downloaded to a script (.script, .ns, .js) or a text file (.txt). If the file already exists, " +
|
||||
"it will be overwritten by this command.<br><br>" +
|
||||
"Note that it will not be possible to download data from many websites because they do not allow " +
|
||||
"cross-origin resource sharing (CORS). Example:<br><br>" +
|
||||
"wget https://raw.githubusercontent.com/danielyxie/bitburner/master/README.md game_readme.txt",
|
||||
};
|
||||
|
@ -451,7 +451,7 @@ function loadImportedGame(saveObj, saveString) {
|
||||
|
||||
var popupId = "import-game-restart-game-notice";
|
||||
var txt = createElement("p", {
|
||||
innerText:"Imported game! I would suggest saving the game and then reloading the page " +
|
||||
innerText:"Imported game! You need to SAVE the game and then RELOAD the page " +
|
||||
"to make sure everything runs smoothly"
|
||||
});
|
||||
var gotitBtn = createElement("a", {
|
||||
|
155
src/Terminal.js
155
src/Terminal.js
@ -50,6 +50,7 @@ import {yesNoBoxCreate,
|
||||
import {post, hackProgressBarPost,
|
||||
hackProgressPost} from "./ui/postToTerminal";
|
||||
|
||||
import autosize from 'autosize';
|
||||
import * as JSZip from 'jszip';
|
||||
import * as FileSaver from 'file-saver';
|
||||
|
||||
@ -66,8 +67,8 @@ $(document).keydown(function(event) {
|
||||
|
||||
if (event.keyCode === KEY.ENTER) {
|
||||
event.preventDefault(); //Prevent newline from being entered in Script Editor
|
||||
var command = $('input[class=terminal-input]').val();
|
||||
post(
|
||||
var command = terminalInput.value;
|
||||
post(
|
||||
"<span class='prompt'>[" +
|
||||
(FconfSettings.ENABLE_TIMESTAMPS ? getTimestamp() + " " : "") +
|
||||
Player.getCurrentServer().hostname +
|
||||
@ -524,9 +525,18 @@ let Terminal = {
|
||||
commandHistoryIndex: 0,
|
||||
|
||||
resetTerminalInput: function() {
|
||||
document.getElementById("terminal-input-td").innerHTML =
|
||||
"<div id='terminal-input-header' class='prompt'>[" + Player.getCurrentServer().hostname + " ~]" + "$ </div>" +
|
||||
'<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1"/>';
|
||||
if (FconfSettings.WRAP_INPUT) {
|
||||
document.getElementById("terminal-input-td").innerHTML =
|
||||
"<div id='terminal-input-header' class='prompt'>[" + Player.getCurrentServer().hostname + " ~]" + "$ </div>" +
|
||||
'<textarea type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1"/>';
|
||||
|
||||
//Auto re-size the line element as it wraps
|
||||
autosize(document.getElementById("terminal-input-text-box"));
|
||||
} else {
|
||||
document.getElementById("terminal-input-td").innerHTML =
|
||||
"<div id='terminal-input-header' class='prompt'>[" + Player.getCurrentServer().hostname + " ~]" + "$ </div>" +
|
||||
'<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1"/>';
|
||||
}
|
||||
var hdr = document.getElementById("terminal-input-header");
|
||||
hdr.style.display = "inline";
|
||||
},
|
||||
@ -762,7 +772,56 @@ let Terminal = {
|
||||
$('input[class=terminal-input]').prop('disabled', false);
|
||||
},
|
||||
|
||||
executeCommand: function(command) {
|
||||
writeToScriptFile : function(server, fn, code) {
|
||||
var ret = {success: false, overwritten: false};
|
||||
if (!isScriptFilename(fn) || !(server instanceof Server)) { return ret; }
|
||||
|
||||
//Check if the script already exists, and overwrite it if it does
|
||||
for (let i = 0; i < server.scripts.length; ++i) {
|
||||
if (fn === server.scripts[i].filename) {
|
||||
let script = server.scripts[i];
|
||||
script.code = code;
|
||||
script.updateRamUsage();
|
||||
script.module = "";
|
||||
ret.overwritten = true;
|
||||
ret.success = true;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
//Otherwise, create a new script
|
||||
var newScript = new Script();
|
||||
newScript.filename = fn;
|
||||
newScript.code = code;
|
||||
newScript.updateRamUsage();
|
||||
newScript.server = server.ip;
|
||||
server.scripts.push(newScript);
|
||||
ret.success = true;
|
||||
return ret;
|
||||
},
|
||||
|
||||
writeToTextFile : function(server, fn, txt) {
|
||||
var ret = {success: false, overwritten: false};
|
||||
if (!fn.endsWith("txt") || !(server instanceof Server)) { return ret; }
|
||||
|
||||
//Check if the text file already exists, and overwrite if it does
|
||||
for (let i = 0; i < server.textFiles.length; ++i) {
|
||||
if (server.textFiles[i].fn === fn) {
|
||||
ret.overwritten = true;
|
||||
server.textFiles[i].text = txt;
|
||||
ret.success = true;
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
//Otherwise create a new text file
|
||||
var newFile = new TextFile(fn, txt);
|
||||
server.textFiles.push(newFile);
|
||||
ret.success = true;
|
||||
return ret;
|
||||
},
|
||||
|
||||
executeCommand : function(command) {
|
||||
command = command.trim();
|
||||
//Replace all extra whitespace in command with a single space
|
||||
command = command.replace(/\s\s+/g, ' ');
|
||||
@ -1384,8 +1443,7 @@ let Terminal = {
|
||||
}
|
||||
}
|
||||
destServer.messages.push(scriptname);
|
||||
post(scriptname + " copied over to " + destServer.hostname);
|
||||
return;
|
||||
return post(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
|
||||
//Scp for txt files
|
||||
@ -1401,18 +1459,15 @@ let Terminal = {
|
||||
|
||||
if (!found) {return post("Error: no such file exists!");}
|
||||
|
||||
for (var i = 0; i < destServer.textFiles.length; ++i) {
|
||||
if (destServer.textFiles[i].fn === scriptname) {
|
||||
//Overwrite
|
||||
destServer.textFiles[i].text = txtFile.text;
|
||||
post("WARNING: " + scriptname + " already exists on " + destServer.hostname +
|
||||
"and will be overwriten");
|
||||
return post(scriptname + " copied over to " + destServer.hostname);
|
||||
}
|
||||
let tRes = Terminal.writeToTextFile(destServer, txtFile.fn, txtFile.text);
|
||||
if (!tRes.success) {
|
||||
return post("Error: scp failed");
|
||||
}
|
||||
var newFile = new TextFile(txtFile.fn, txtFile.text);
|
||||
destServer.textFiles.push(newFile);
|
||||
return post(scriptname + " copied over to " + destServer.hostname);
|
||||
if (tRes.overwritten) {
|
||||
post(`WARNING: ${scriptname} already exists on ${destServer.hostname} and will be overwriten`);
|
||||
return post(`${scriptname} overwritten on ${destServer.hostname}`);
|
||||
}
|
||||
return post(`${scriptname} copied over to ${destServer.hostname}`);
|
||||
}
|
||||
|
||||
//Get the current script
|
||||
@ -1428,27 +1483,16 @@ let Terminal = {
|
||||
return;
|
||||
}
|
||||
|
||||
//Overwrite script if it exists
|
||||
for (var i = 0; i < destServer.scripts.length; ++i) {
|
||||
if (scriptname == destServer.scripts[i].filename) {
|
||||
post("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and will be overwritten");
|
||||
var oldScript = destServer.scripts[i];
|
||||
oldScript.code = sourceScript.code;
|
||||
oldScript.ramUsage = sourceScript.ramUsage;
|
||||
oldScript.module = "";
|
||||
post(scriptname + " overwriten on " + destServer.hostname);
|
||||
return;
|
||||
}
|
||||
let sRes = Terminal.writeToScriptFile(destServer, scriptname, sourceScript.code);
|
||||
if (!sRes.success) {
|
||||
return post(`Error: scp failed`);
|
||||
}
|
||||
|
||||
var newScript = new Script();
|
||||
newScript.filename = scriptname;
|
||||
newScript.code = sourceScript.code;
|
||||
newScript.ramUsage = sourceScript.ramUsage;
|
||||
newScript.destServer = ip;
|
||||
destServer.scripts.push(newScript);
|
||||
post(scriptname + " copied over to " + destServer.hostname);
|
||||
break;
|
||||
if (sRes.overwritten) {
|
||||
post(`WARNING: ${scriptname} already exists on ${destServer.hostname} and will be overwritten`);
|
||||
return post(`${scriptname} overwritten on ${destServer.hostname}`);
|
||||
}
|
||||
post(`${scriptname} copied over to ${destServer.hostname}`);
|
||||
break;
|
||||
case "sudov":
|
||||
if (commandArray.length != 1) {
|
||||
post("Incorrect number of arguments. Usage: sudov"); return;
|
||||
@ -1571,6 +1615,38 @@ let Terminal = {
|
||||
post("No such alias exists");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "wget":
|
||||
if (commandArray.length !== 2) {
|
||||
return post("Incorrect usage of wget command. Usage: wget [url] [target file]");
|
||||
}
|
||||
var args = commandArray[1].split(" ");
|
||||
if (args.length !== 2) {
|
||||
return post("Incorrect usage of wget command. Usage: wget [url] [target file]");
|
||||
}
|
||||
|
||||
let url = args[0];
|
||||
let target = args[1];
|
||||
if (!isScriptFilename(target) && !target.endsWith(".txt")) {
|
||||
return post(`wget failed: Invalid target file. Target file must be script or text file`);
|
||||
}
|
||||
$.get(url, function(data) {
|
||||
let res;
|
||||
if (isScriptFilename(target)) {
|
||||
res = Terminal.writeToScriptFile(s, target, data);
|
||||
} else {
|
||||
res = Terminal.writeToTextFile(s, target, data);
|
||||
}
|
||||
if (!res.success) {
|
||||
return post("wget failed");
|
||||
}
|
||||
if (res.overwritten) {
|
||||
return post(`wget successfully retrieved content and overwrote ${target}`);
|
||||
}
|
||||
return post(`wget successfully retrieved content to new file ${target}`);
|
||||
}, 'text').fail(function(e) {
|
||||
return post("wget failed: " + JSON.stringify(e));
|
||||
})
|
||||
break;
|
||||
default:
|
||||
post("Command not found");
|
||||
@ -2048,6 +2124,7 @@ let Terminal = {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
post("ERROR: No such script");
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { getElementById } from "../../utils/uiHelpers/getElementById";
|
||||
import { getElementById } from "../../utils/uiHelpers/getElementById";
|
||||
|
||||
/**
|
||||
* Adds some output to the terminal.
|
||||
|
Loading…
Reference in New Issue
Block a user