From 40713a4112fe49146ef465a5cff863c6c46f9bb9 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 23 Mar 2021 15:25:18 -0400 Subject: [PATCH 1/7] Added alt g shortcut to gang and alt b shortcut to bladeburner --- doc/source/shortcuts.rst | 2 ++ src/engine.jsx | 8 ++++- utils/helpers/keyCodes.ts | 70 ++++++++++++++++++++++++--------------- 3 files changed, 53 insertions(+), 27 deletions(-) diff --git a/doc/source/shortcuts.rst b/doc/source/shortcuts.rst index 60e22bf28..80f690f5e 100644 --- a/doc/source/shortcuts.rst +++ b/doc/source/shortcuts.rst @@ -31,6 +31,8 @@ Alt + f Switch to 'Factions' page Alt + a Switch to 'Augmentations' page Alt + u Switch to 'Tutorial' page Alt + o Switch to 'Options' page +Alt + g Switch to 'Gang' page +Alt + b Switch to 'Bladeburner' page ========== =========================================================================== Script Editor diff --git a/src/engine.jsx b/src/engine.jsx index 4dbf9910b..2d1c99134 100644 --- a/src/engine.jsx +++ b/src/engine.jsx @@ -134,7 +134,7 @@ $(document).keydown(function(e) { } catch(e) {} if (!Player.isWorking && !redPillFlag && !inMission && !cinematicTextFlag) { - if (e.keyCode == 84 && e.altKey) { + if (e.keyCode == KEY.T && e.altKey) { e.preventDefault(); Engine.loadTerminalContent(); } else if (e.keyCode === KEY.C && e.altKey) { @@ -174,6 +174,12 @@ $(document).keydown(function(e) { } else if (e.keyCode === KEY.U && e.altKey) { e.preventDefault(); Engine.loadTutorialContent(); + } else if (e.keyCode === KEY.B && e.altKey) { + e.preventDefault(); + Engine.loadBladeburnerContent(); + } else if (e.keyCode === KEY.G && e.altKey) { + e.preventDefault(); + Engine.loadGangContent(); } } diff --git a/utils/helpers/keyCodes.ts b/utils/helpers/keyCodes.ts index 6084e02be..445235ea3 100644 --- a/utils/helpers/keyCodes.ts +++ b/utils/helpers/keyCodes.ts @@ -4,30 +4,48 @@ import { IMap } from "../../src/types"; * Keyboard key codes */ export const KEY: IMap = { - A: 65, - B: 66, - C: 67, - CTRL: 17, - D: 68, - DOWNARROW: 40, - E: 69, - ENTER: 13, - ESC: 27, - F: 70, - H: 72, - J: 74, - K: 75, - L: 76, - M: 77, - N: 78, - O: 79, - P: 80, - R: 82, - S: 83, - TAB: 9, - U: 85, - UPARROW: 38, - W: 87, - "1": 49, - "2": 50, + CTRL: 17, + DOWNARROW: 40, + ENTER: 13, + ESC: 27, + TAB: 9, + UPARROW: 38, + + "0": 48, + "1": 49, + "2": 50, + "3": 51, + "4": 52, + "5": 53, + "6": 54, + "7": 55, + "8": 56, + "9": 57, + + A: 65, + B: 66, + C: 67, + D: 68, + E: 69, + F: 70, + G: 71, + H: 72, + I: 73, + J: 74, + K: 75, + L: 76, + M: 77, + N: 78, + O: 79, + P: 80, + Q: 81, + R: 82, + S: 83, + T: 84, + U: 85, + V: 86, + W: 87, + X: 88, + Y: 89, + Z: 90, }; From 42e9a368b4d9a91df7f118c1c2cbceceaa455908 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 23 Mar 2021 15:26:36 -0400 Subject: [PATCH 2/7] modified changelog --- src/Constants.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/Constants.ts b/src/Constants.ts index 90ad9bac2..76ce092d5 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -6,7 +6,7 @@ import { IMap } from "./types"; export let CONSTANTS: IMap = { - Version: "0.50.1", + Version: "0.51.0", /** Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience * and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then @@ -228,21 +228,11 @@ export let CONSTANTS: IMap = { LatestUpdate: ` - v0.50.1 - 2021-03-22 (hydroflame) + v0.51.0 - 2021-XX-XX formulas (hydroflame) ------- - Netscript - * getTaskStats works - - Source-File -1 - * Added a new Exploit - - Factions - * Augmentations offered by a Faction but already bought are in a separate list at the bottom of the page. - - Bug fixed - * Fixed a bug where completing a maxed non-repeatable BitNode would make its color on the BitVerse like level 1. Misc. - * Minor spacing in stats tables. + * New shortcut, Alt + b, brings you to bladeburner + * New shortcut, Alt + g, brings you to gang ` } From 1eddddd14f29413cfb11b4efa3eb7170bbd4bbc2 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 23 Mar 2021 16:02:34 -0400 Subject: [PATCH 3/7] Added executeCommand netscript function --- .../singularityfunctions/executeCommand.rst | 21 +++++++++++++++++++ src/Netscript/RamCostGenerator.ts | 1 + src/NetscriptFunctions.js | 18 ++++++++++------ 3 files changed, 34 insertions(+), 6 deletions(-) create mode 100644 doc/source/netscript/singularityfunctions/executeCommand.rst diff --git a/doc/source/netscript/singularityfunctions/executeCommand.rst b/doc/source/netscript/singularityfunctions/executeCommand.rst new file mode 100644 index 000000000..8b083009a --- /dev/null +++ b/doc/source/netscript/singularityfunctions/executeCommand.rst @@ -0,0 +1,21 @@ +executeCommand() Netscript Function +======================================== + +.. js:function:: executeCommand(command) + + :RAM cost: 4 GB + :param string commands: The full string of the command. + + If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function. + + This function writes the command to the terminal and executes it. This + can be used to perform manual hacks. Only one command can be sent at a time. + + Examples: + + .. code-block:: javascript + + await ns.executeCommand('connect CSEC'); + await ns.executeCommand('hack'); + await ns.executeCommand('home'); + // a manual hack will be performed and CSEC will invite you. \ No newline at end of file diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index e40c06186..da1d79c64 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -176,6 +176,7 @@ export const RamCosts: IMap = { travelToCity: () => RamCostConstants.ScriptSingularityFn1RamCost, purchaseTor: () => RamCostConstants.ScriptSingularityFn1RamCost, purchaseProgram: () => RamCostConstants.ScriptSingularityFn1RamCost, + executeCommand: () => RamCostConstants.ScriptSingularityFn1RamCost * 2, getStats: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, getCharacterInformation: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, isBusy: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index d0651cb1b..3e413e1ef 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -59,6 +59,7 @@ import { import { HacknetServer, MaxNumberHacknetServers } from "./Hacknet/HacknetServer"; import { CityName } from "./Locations/data/CityNames"; import { LocationName } from "./Locations/data/LocationNames"; +import { Terminal } from "./Terminal"; import { Message } from "./Message/Message"; import { Messages } from "./Message/MessageHelpers"; @@ -537,23 +538,17 @@ function NetscriptFunctions(workerScript) { const runAfterReset = function(cbScript=null) { //Run a script after reset - console.log(cbScript); if (cbScript && isString(cbScript)) { - console.log('here'); const home = Player.getHomeComputer(); for (const script of home.scripts) { - console.log('here 2'+script); if (script.filename === cbScript) { - console.log('here 3'); const ramUsage = script.ramUsage; const ramAvailable = home.maxRam - home.ramUsed; if (ramUsage > ramAvailable) { - console.log('here 4'); return; // Not enough RAM } const runningScriptObj = new RunningScript(script, []); // No args runningScriptObj.threads = 1; // Only 1 thread - console.log('running!'); startWorkerScript(runningScriptObj, home); } } @@ -2684,6 +2679,17 @@ function NetscriptFunctions(workerScript) { workerScript.log("purchaseProgram", `You have purchased the '${item.program}' program. The new program can be found on your home computer.`); return true; }, + executeCommand: function(command) { + updateDynamicRam("executeCommand", getRamCost("executeCommand")); + checkSingularityAccess("executeCommand", 1); + Terminal.executeCommand(command); + return new Promise(function (resolve, reject) { + (function wait(){ + if (!Terminal.hackFlag && !Terminal.analyzeFlag) return resolve(); + setTimeout(wait, 30); + })(); + }); + }, getStats: function() { updateDynamicRam("getStats", getRamCost("getStats")); checkSingularityAccess("getStats", 1); From 28584c84617d1def0b796ff71668f2fdec631150 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 23 Mar 2021 21:30:15 -0400 Subject: [PATCH 4/7] executeCommand has been removed in favor of connect and manualHack, which is what people have been asking for. --- .../netscriptsingularityfunctions.rst | 2 + .../singularityfunctions/connect.rst | 20 ++ .../singularityfunctions/executeCommand.rst | 21 -- .../singularityfunctions/manualHack.rst | 24 +++ src/Constants.ts | 4 + src/Netscript/RamCostGenerator.ts | 3 +- src/NetscriptFunctions.js | 193 +++++++++++------- src/NetscriptWorker.js | 2 +- src/Terminal.js | 28 ++- 9 files changed, 191 insertions(+), 106 deletions(-) create mode 100644 doc/source/netscript/singularityfunctions/connect.rst delete mode 100644 doc/source/netscript/singularityfunctions/executeCommand.rst create mode 100644 doc/source/netscript/singularityfunctions/manualHack.rst diff --git a/doc/source/netscript/netscriptsingularityfunctions.rst b/doc/source/netscript/netscriptsingularityfunctions.rst index 44b311269..8069cc944 100644 --- a/doc/source/netscript/netscriptsingularityfunctions.rst +++ b/doc/source/netscript/netscriptsingularityfunctions.rst @@ -24,6 +24,8 @@ level 3, then you will be able to access all of the Singularity Functions. travelToCity() purchaseTor() purchaseProgram() + connect() + manualHack() getStats() getCharacterInformation() isBusy() diff --git a/doc/source/netscript/singularityfunctions/connect.rst b/doc/source/netscript/singularityfunctions/connect.rst new file mode 100644 index 000000000..974996363 --- /dev/null +++ b/doc/source/netscript/singularityfunctions/connect.rst @@ -0,0 +1,20 @@ +connect() Netscript Function +============================ + +.. js:function:: connect(hostname) + + :RAM cost: 2 GB + :param string hostname: hostname of the server to connect. + :returns: ``true`` if the connection was a success. + + If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function. + + This function will connect you to the specified server if it's directly connected to the current server. + You can also pass in 'home' to return to your home server from anywhere. + + Examples: + + .. code-block:: javascript + + connect("joesguns"); + connect("CSEC"); diff --git a/doc/source/netscript/singularityfunctions/executeCommand.rst b/doc/source/netscript/singularityfunctions/executeCommand.rst deleted file mode 100644 index 8b083009a..000000000 --- a/doc/source/netscript/singularityfunctions/executeCommand.rst +++ /dev/null @@ -1,21 +0,0 @@ -executeCommand() Netscript Function -======================================== - -.. js:function:: executeCommand(command) - - :RAM cost: 4 GB - :param string commands: The full string of the command. - - If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function. - - This function writes the command to the terminal and executes it. This - can be used to perform manual hacks. Only one command can be sent at a time. - - Examples: - - .. code-block:: javascript - - await ns.executeCommand('connect CSEC'); - await ns.executeCommand('hack'); - await ns.executeCommand('home'); - // a manual hack will be performed and CSEC will invite you. \ No newline at end of file diff --git a/doc/source/netscript/singularityfunctions/manualHack.rst b/doc/source/netscript/singularityfunctions/manualHack.rst new file mode 100644 index 000000000..5283ed6e4 --- /dev/null +++ b/doc/source/netscript/singularityfunctions/manualHack.rst @@ -0,0 +1,24 @@ +manualHack() Netscript Function +=============================== + +.. js:function:: manualHack() + + :RAM cost: 2 GB + :returns: The amount of money stolen if the hack is successful, and zero otherwise + + If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function. + + This function will perform a manual hack on the server you are currently connected to. + This is typically required to join factions. + + Examples: + + .. code-block:: javascript + + connect("CSEC"); + manualHack(); + + .. warning:: + For NS2 users: + + This function is async. \ No newline at end of file diff --git a/src/Constants.ts b/src/Constants.ts index 76ce092d5..45d20acce 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -231,6 +231,10 @@ export let CONSTANTS: IMap = { v0.51.0 - 2021-XX-XX formulas (hydroflame) ------- + Netscript + * 'connect': a new singularity function that connects you to a server. (like the terminal command) + * 'manualHack': a new singularity function that performs a manual hack on the players current server. + Misc. * New shortcut, Alt + b, brings you to bladeburner * New shortcut, Alt + g, brings you to gang diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts index da1d79c64..6afb78180 100644 --- a/src/Netscript/RamCostGenerator.ts +++ b/src/Netscript/RamCostGenerator.ts @@ -176,7 +176,8 @@ export const RamCosts: IMap = { travelToCity: () => RamCostConstants.ScriptSingularityFn1RamCost, purchaseTor: () => RamCostConstants.ScriptSingularityFn1RamCost, purchaseProgram: () => RamCostConstants.ScriptSingularityFn1RamCost, - executeCommand: () => RamCostConstants.ScriptSingularityFn1RamCost * 2, + connect: () => RamCostConstants.ScriptSingularityFn1RamCost, + manualHack: () => RamCostConstants.ScriptSingularityFn1RamCost, getStats: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, getCharacterInformation: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, isBusy: () => RamCostConstants.ScriptSingularityFn1RamCost / 4, diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 3e413e1ef..9536bf89a 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -555,6 +555,80 @@ function NetscriptFunctions(workerScript) { } } + const hack = function(ip, manual, { threads: requestedThreads, stock } = {}) { + if (ip === undefined) { + throw makeRuntimeErrorMsg("hack", "Takes 1 argument."); + } + const threads = resolveNetscriptRequestedThreads(workerScript, "hack", requestedThreads); + const server = getServer(ip); + if (server == null) { + throw makeRuntimeErrorMsg("hack", `Invalid IP/hostname: ${ip}.`); + } + + // Calculate the hacking time + var hackingTime = calculateHackingTime(server); // This is in seconds + + // No root access or skill level too low + const canHack = netscriptCanHack(server, Player); + if (!canHack.res) { + throw makeRuntimeErrorMsg('hack', canHack.msg); + } + + workerScript.log("hack", `Executing ${ip} in ${hackingTime.toFixed(3)} seconds (t=${threads})`); + + return netscriptDelay(hackingTime * 1000, workerScript).then(function() { + if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} + var hackChance = calculateHackingChance(server); + var rand = Math.random(); + var expGainedOnSuccess = calculateHackingExpGain(server) * threads; + var expGainedOnFailure = (expGainedOnSuccess / 4); + if (rand < hackChance) { // Success! + const percentHacked = calculatePercentMoneyHacked(server); + let maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax)); + if (isNaN(maxThreadNeeded)) { + // Server has a 'max money' of 0 (probably). We'll set this to an arbitrarily large value + maxThreadNeeded = 1e6; + } + + let moneyDrained = Math.floor(server.moneyAvailable * percentHacked) * threads; + + // Over-the-top safety checks + if (moneyDrained <= 0) { + moneyDrained = 0; + expGainedOnSuccess = expGainedOnFailure; + } + if (moneyDrained > server.moneyAvailable) {moneyDrained = server.moneyAvailable;} + server.moneyAvailable -= moneyDrained; + if (server.moneyAvailable < 0) {server.moneyAvailable = 0;} + + const moneyGained = moneyDrained * BitNodeMultipliers.ScriptHackMoneyGain; + + Player.gainMoney(moneyGained); + workerScript.scriptRef.onlineMoneyMade += moneyGained; + Player.scriptProdSinceLastAug += moneyGained; + Player.recordMoneySource(moneyGained, "hacking"); + workerScript.scriptRef.recordHack(server.ip, moneyGained, threads); + Player.gainHackingExp(expGainedOnSuccess); + workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; + workerScript.log("hack", `Successfully hacked '${server.hostname}' for ${numeralWrapper.format(moneyGained, '$0.000a')} and ${numeralWrapper.format(expGainedOnSuccess, '0.000a')} exp (t=${threads})`); + server.fortify(CONSTANTS.ServerFortifyAmount * Math.min(threads, maxThreadNeeded)); + if (stock) { + influenceStockThroughServerHack(server, moneyGained); + } + if(manual) { + server.manuallyHacked = true; + } + return Promise.resolve(moneyGained); + } else { + // Player only gains 25% exp for failure? + Player.gainHackingExp(expGainedOnFailure); + workerScript.scriptRef.onlineExpGained += expGainedOnFailure; + workerScript.log("hack", `Failed to hack '${server.hostname}'. Gained ${numeralWrapper.format(expGainedOnFailure, '0.000a')} exp (t=${threads})`); + return Promise.resolve(0); + } + }); + } + return { hacknet : { numNodes : function() { @@ -671,74 +745,7 @@ function NetscriptFunctions(workerScript) { }, hack : function(ip, { threads: requestedThreads, stock } = {}){ updateDynamicRam("hack", getRamCost("hack")); - if (ip === undefined) { - throw makeRuntimeErrorMsg("hack", "Takes 1 argument."); - } - const threads = resolveNetscriptRequestedThreads(workerScript, "hack", requestedThreads); - const server = getServer(ip); - if (server == null) { - throw makeRuntimeErrorMsg("hack", `Invalid IP/hostname: ${ip}.`); - } - - // Calculate the hacking time - var hackingTime = calculateHackingTime(server); // This is in seconds - - // No root access or skill level too low - const canHack = netscriptCanHack(server, Player); - if (!canHack.res) { - throw makeRuntimeErrorMsg('hack', canHack.msg); - } - - workerScript.log("hack", `Executing ${ip} in ${hackingTime.toFixed(3)} seconds (t=${threads})`); - - return netscriptDelay(hackingTime * 1000, workerScript).then(function() { - if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} - var hackChance = calculateHackingChance(server); - var rand = Math.random(); - var expGainedOnSuccess = calculateHackingExpGain(server) * threads; - var expGainedOnFailure = (expGainedOnSuccess / 4); - if (rand < hackChance) { // Success! - const percentHacked = calculatePercentMoneyHacked(server); - let maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax)); - if (isNaN(maxThreadNeeded)) { - // Server has a 'max money' of 0 (probably). We'll set this to an arbitrarily large value - maxThreadNeeded = 1e6; - } - - let moneyDrained = Math.floor(server.moneyAvailable * percentHacked) * threads; - - // Over-the-top safety checks - if (moneyDrained <= 0) { - moneyDrained = 0; - expGainedOnSuccess = expGainedOnFailure; - } - if (moneyDrained > server.moneyAvailable) {moneyDrained = server.moneyAvailable;} - server.moneyAvailable -= moneyDrained; - if (server.moneyAvailable < 0) {server.moneyAvailable = 0;} - - const moneyGained = moneyDrained * BitNodeMultipliers.ScriptHackMoneyGain; - - Player.gainMoney(moneyGained); - workerScript.scriptRef.onlineMoneyMade += moneyGained; - Player.scriptProdSinceLastAug += moneyGained; - Player.recordMoneySource(moneyGained, "hacking"); - workerScript.scriptRef.recordHack(server.ip, moneyGained, threads); - Player.gainHackingExp(expGainedOnSuccess); - workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; - workerScript.log("hack", `Successfully hacked '${server.hostname}' for ${numeralWrapper.format(moneyGained, '$0.000a')} and ${numeralWrapper.format(expGainedOnSuccess, '0.000a')} exp (t=${threads})`); - server.fortify(CONSTANTS.ServerFortifyAmount * Math.min(threads, maxThreadNeeded)); - if (stock) { - influenceStockThroughServerHack(server, moneyGained); - } - return Promise.resolve(moneyGained); - } else { - // Player only gains 25% exp for failure? - Player.gainHackingExp(expGainedOnFailure); - workerScript.scriptRef.onlineExpGained += expGainedOnFailure; - workerScript.log("hack", `Failed to hack '${server.hostname}'. Gained ${numeralWrapper.format(expGainedOnFailure, '0.000a')} exp (t=${threads})`); - return Promise.resolve(0); - } - }); + return hack(ip, false, {threads: requestedThreads, stock: stock}); }, hackAnalyzeThreads : function(ip, hackAmount) { updateDynamicRam("hackAnalyzeThreads", getRamCost("hackAnalyzeThreads")); @@ -2679,16 +2686,46 @@ function NetscriptFunctions(workerScript) { workerScript.log("purchaseProgram", `You have purchased the '${item.program}' program. The new program can be found on your home computer.`); return true; }, - executeCommand: function(command) { - updateDynamicRam("executeCommand", getRamCost("executeCommand")); - checkSingularityAccess("executeCommand", 1); - Terminal.executeCommand(command); - return new Promise(function (resolve, reject) { - (function wait(){ - if (!Terminal.hackFlag && !Terminal.analyzeFlag) return resolve(); - setTimeout(wait, 30); - })(); - }); + connect: function(hostname) { + if (!hostname) { + throw makeRuntimeErrorMsg("connect", `Invalid hostname: '${hostname}'`); + } + + let target = getServer(hostname); + if (target == null) { + throw makeRuntimeErrorMsg("connect", `Invalid hostname: '${hostname}'`); + return; + } + + if(hostname === 'home') { + Player.getCurrentServer().isConnectedTo = false; + Player.currentServer = Player.getHomeComputer().ip; + Player.getCurrentServer().isConnectedTo = true; + Terminal.currDir = "/"; + Terminal.resetTerminalInput(true); + return true; + } + + const server = Player.getCurrentServer(); + for (let i = 0; i < server.serversOnNetwork.length; i++) { + const other = getServerOnNetwork(server, i); + if (other.ip == hostname || other.hostname == hostname) { + Player.getCurrentServer().isConnectedTo = false; + Player.currentServer = target.ip; + Player.getCurrentServer().isConnectedTo = true; + Terminal.currDir = "/"; + Terminal.resetTerminalInput(true); + return true; + } + } + + return false; + }, + manualHack: function() { + updateDynamicRam("manualHack", getRamCost("manualHack")); + checkSingularityAccess("manualHack", 1); + const server = Player.getCurrentServer(); + return hack(server.hostname, true); }, getStats: function() { updateDynamicRam("getStats", getRamCost("getStats")); diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js index f030ac93d..7b9803ab3 100644 --- a/src/NetscriptWorker.js +++ b/src/NetscriptWorker.js @@ -163,7 +163,7 @@ function startNetscript1Script(workerScript) { if (typeof entry === "function") { //Async functions need to be wrapped. See JS-Interpreter documentation if (name === "hack" || name === "grow" || name === "weaken" || name === "sleep" || - name === "prompt") { + name === "prompt" || name === "manualHack") { let tempWrapper = function() { let fnArgs = []; diff --git a/src/Terminal.js b/src/Terminal.js index 2b3ed51a6..be230aa10 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -113,6 +113,10 @@ function isNumber(str) { return !isNaN(str) && !isNaN(parseFloat(str)); } +function getTerminalInput() { + return document.getElementById("terminal-input-text-box").value; +} + // Defines key commands in terminal $(document).keydown(function(event) { // Terminal @@ -122,7 +126,7 @@ $(document).keydown(function(event) { if (event.keyCode === KEY.ENTER) { event.preventDefault(); // Prevent newline from being entered in Script Editor - const command = terminalInput.value; + const command = getTerminalInput(); const dir = Terminal.currDir; post( "[" + @@ -344,22 +348,36 @@ let Terminal = { // Excludes the trailing forward slash currDir: "/", - resetTerminalInput: function() { + resetTerminalInput: function(keepInput=false) { + let input = ""; + if(keepInput) { + input = getTerminalInput(); + } const dir = Terminal.currDir; if (FconfSettings.WRAP_INPUT) { document.getElementById("terminal-input-td").innerHTML = `
[${Player.getCurrentServer().hostname} ~${dir}]$
` + - '",v.noCloneChecked=!!e.cloneNode(!0).lastChild.defaultValue}();var xe=s.documentElement,we=/^key/,Ce=/^(?:mouse|pointer|contextmenu|drag|drop)|click/,ke=/^([^.]*)(?:\.(.+)|)/;function Ee(){return!0}function Ae(){return!1}function _e(){try{return s.activeElement}catch(e){}}function Se(e,t,n,r,i,o){var s,a;if("object"==typeof t){for(a in"string"!=typeof n&&(r=r||n,n=void 0),t)Se(e,a,n,r,t[a],o);return e}if(null==r&&null==i?(i=n,r=n=void 0):null==i&&("string"==typeof n?(i=r,r=void 0):(i=r,r=n,n=void 0)),!1===i)i=Ae;else if(!i)return e;return 1===o&&(s=i,(i=function(e){return k().off(e),s.apply(this,arguments)}).guid=s.guid||(s.guid=k.guid++)),e.each(function(){k.event.add(this,t,i,r,n)})}k.event={global:{},add:function(e,t,n,r,i){var o,s,a,l,u,c,h,d,f,p,g,m=Z.get(e);if(m)for(n.handler&&(n=(o=n).handler,i=o.selector),i&&k.find.matchesSelector(xe,i),n.guid||(n.guid=k.guid++),(l=m.events)||(l=m.events={}),(s=m.handle)||(s=m.handle=function(t){return void 0!==k&&k.event.triggered!==t.type?k.event.dispatch.apply(e,arguments):void 0}),u=(t=(t||"").match(j)||[""]).length;u--;)f=g=(a=ke.exec(t[u])||[])[1],p=(a[2]||"").split(".").sort(),f&&(h=k.event.special[f]||{},f=(i?h.delegateType:h.bindType)||f,h=k.event.special[f]||{},c=k.extend({type:f,origType:g,data:r,handler:n,guid:n.guid,selector:i,needsContext:i&&k.expr.match.needsContext.test(i),namespace:p.join(".")},o),(d=l[f])||((d=l[f]=[]).delegateCount=0,h.setup&&!1!==h.setup.call(e,r,p,s)||e.addEventListener&&e.addEventListener(f,s)),h.add&&(h.add.call(e,c),c.handler.guid||(c.handler.guid=n.guid)),i?d.splice(d.delegateCount++,0,c):d.push(c),k.event.global[f]=!0)},remove:function(e,t,n,r,i){var o,s,a,l,u,c,h,d,f,p,g,m=Z.hasData(e)&&Z.get(e);if(m&&(l=m.events)){for(u=(t=(t||"").match(j)||[""]).length;u--;)if(f=g=(a=ke.exec(t[u])||[])[1],p=(a[2]||"").split(".").sort(),f){for(h=k.event.special[f]||{},d=l[f=(r?h.delegateType:h.bindType)||f]||[],a=a[2]&&new RegExp("(^|\\.)"+p.join("\\.(?:.*\\.|)")+"(\\.|$)"),s=o=d.length;o--;)c=d[o],!i&&g!==c.origType||n&&n.guid!==c.guid||a&&!a.test(c.namespace)||r&&r!==c.selector&&("**"!==r||!c.selector)||(d.splice(o,1),c.selector&&d.delegateCount--,h.remove&&h.remove.call(e,c));s&&!d.length&&(h.teardown&&!1!==h.teardown.call(e,p,m.handle)||k.removeEvent(e,f,m.handle),delete l[f])}else for(f in l)k.event.remove(e,f+t[u],n,r,!0);k.isEmptyObject(l)&&Z.remove(e,"handle events")}},dispatch:function(e){var t,n,r,i,o,s,a=k.event.fix(e),l=new Array(arguments.length),u=(Z.get(this,"events")||{})[a.type]||[],c=k.event.special[a.type]||{};for(l[0]=a,t=1;t=1))for(;u!==this;u=u.parentNode||this)if(1===u.nodeType&&("click"!==e.type||!0!==u.disabled)){for(o=[],s={},n=0;n-1:k.find(i,this,null,[u]).length),s[i]&&o.push(r);o.length&&a.push({elem:u,handlers:o})}return u=this,l\x20\t\r\n\f]*)[^>]*)\/>/gi,De=/\s*$/g;function Be(e,t){return T(e,"table")&&T(11!==t.nodeType?t:t.firstChild,"tr")&&k(e).children("tbody")[0]||e}function Me(e){return e.type=(null!==e.getAttribute("type"))+"/"+e.type,e}function Pe(e){return"true/"===(e.type||"").slice(0,5)?e.type=e.type.slice(5):e.removeAttribute("type"),e}function Re(e,t){var n,r,i,o,s,a,l,u;if(1===t.nodeType){if(Z.hasData(e)&&(o=Z.access(e),s=Z.set(t,o),u=o.events))for(i in delete s.handle,s.events={},u)for(n=0,r=u[i].length;n1&&"string"==typeof p&&!v.checkClone&&Te.test(p))return e.each(function(i){var o=e.eq(i);g&&(t[0]=p.call(this,i,o.html())),Ie(o,t,n,r)});if(d&&(o=(i=be(t,e[0].ownerDocument,!1,e,r)).firstChild,1===i.childNodes.length&&(i=o),o||r)){for(a=(s=k.map(me(i,"script"),Me)).length;h")},clone:function(e,t,n){var r,i,o,s,a=e.cloneNode(!0),l=k.contains(e.ownerDocument,e);if(!(v.noCloneChecked||1!==e.nodeType&&11!==e.nodeType||k.isXMLDoc(e)))for(s=me(a),r=0,i=(o=me(e)).length;r0&&ve(s,!l&&me(e,"script")),a},cleanData:function(e){for(var t,n,r,i=k.event.special,o=0;void 0!==(n=e[o]);o++)if(X(n)){if(t=n[Z.expando]){if(t.events)for(r in t.events)i[r]?k.event.remove(n,r):k.removeEvent(n,r,t.handle);n[Z.expando]=void 0}n[J.expando]&&(n[J.expando]=void 0)}}}),k.fn.extend({detach:function(e){return je(this,e,!0)},remove:function(e){return je(this,e)},text:function(e){return U(this,function(e){return void 0===e?k.text(this):this.empty().each(function(){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||(this.textContent=e)})},null,e,arguments.length)},append:function(){return Ie(this,arguments,function(e){1!==this.nodeType&&11!==this.nodeType&&9!==this.nodeType||Be(this,e).appendChild(e)})},prepend:function(){return Ie(this,arguments,function(e){if(1===this.nodeType||11===this.nodeType||9===this.nodeType){var t=Be(this,e);t.insertBefore(e,t.firstChild)}})},before:function(){return Ie(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this)})},after:function(){return Ie(this,arguments,function(e){this.parentNode&&this.parentNode.insertBefore(e,this.nextSibling)})},empty:function(){for(var e,t=0;null!=(e=this[t]);t++)1===e.nodeType&&(k.cleanData(me(e,!1)),e.textContent="");return this},clone:function(e,t){return e=null!=e&&e,t=null==t?e:t,this.map(function(){return k.clone(this,e,t)})},html:function(e){return U(this,function(e){var t=this[0]||{},n=0,r=this.length;if(void 0===e&&1===t.nodeType)return t.innerHTML;if("string"==typeof e&&!De.test(e)&&!ge[(fe.exec(e)||["",""])[1].toLowerCase()]){e=k.htmlPrefilter(e);try{for(;n=0&&(l+=Math.max(0,Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-o-l-a-.5))),l}function Je(e,t,n){var r=$e(e),i=ze(e,t,r),o="border-box"===k.css(e,"boxSizing",!1,r),s=o;if(Ne.test(i)){if(!n)return i;i="auto"}return s=s&&(v.boxSizingReliable()||i===e.style[t]),("auto"===i||!parseFloat(i)&&"inline"===k.css(e,"display",!1,r))&&(i=e["offset"+t[0].toUpperCase()+t.slice(1)],s=!0),(i=parseFloat(i)||0)+Ze(e,t,n||(o?"border":"content"),s,r,i)+"px"}function et(e,t,n,r,i){return new et.prototype.init(e,t,n,r,i)}k.extend({cssHooks:{opacity:{get:function(e,t){if(t){var n=ze(e,"opacity");return""===n?"1":n}}}},cssNumber:{animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},cssProps:{},style:function(e,t,n,r){if(e&&3!==e.nodeType&&8!==e.nodeType&&e.style){var i,o,s,a=Y(t),l=Ue.test(t),u=e.style;if(l||(t=Xe(a)),s=k.cssHooks[t]||k.cssHooks[a],void 0===n)return s&&"get"in s&&void 0!==(i=s.get(e,!1,r))?i:u[t];"string"===(o=typeof n)&&(i=ie.exec(n))&&i[1]&&(n=le(e,t,i),o="number"),null!=n&&n==n&&("number"===o&&(n+=i&&i[3]||(k.cssNumber[a]?"":"px")),v.clearCloneStyle||""!==n||0!==t.indexOf("background")||(u[t]="inherit"),s&&"set"in s&&void 0===(n=s.set(e,n,r))||(l?u.setProperty(t,n):u[t]=n))}},css:function(e,t,n,r){var i,o,s,a=Y(t);return Ue.test(t)||(t=Xe(a)),(s=k.cssHooks[t]||k.cssHooks[a])&&"get"in s&&(i=s.get(e,!0,n)),void 0===i&&(i=ze(e,t,r)),"normal"===i&&t in Ke&&(i=Ke[t]),""===n||n?(o=parseFloat(i),!0===n||isFinite(o)?o||0:i):i}}),k.each(["height","width"],function(e,t){k.cssHooks[t]={get:function(e,n,r){if(n)return!Ve.test(k.css(e,"display"))||e.getClientRects().length&&e.getBoundingClientRect().width?Je(e,t,r):ae(e,Ge,function(){return Je(e,t,r)})},set:function(e,n,r){var i,o=$e(e),s="border-box"===k.css(e,"boxSizing",!1,o),a=r&&Ze(e,t,r,s,o);return s&&v.scrollboxSize()===o.position&&(a-=Math.ceil(e["offset"+t[0].toUpperCase()+t.slice(1)]-parseFloat(o[t])-Ze(e,t,"border",!1,o)-.5)),a&&(i=ie.exec(n))&&"px"!==(i[3]||"px")&&(e.style[t]=n,n=k.css(e,t)),Qe(0,n,a)}}}),k.cssHooks.marginLeft=He(v.reliableMarginLeft,function(e,t){if(t)return(parseFloat(ze(e,"marginLeft"))||e.getBoundingClientRect().left-ae(e,{marginLeft:0},function(){return e.getBoundingClientRect().left}))+"px"}),k.each({margin:"",padding:"",border:"Width"},function(e,t){k.cssHooks[e+t]={expand:function(n){for(var r=0,i={},o="string"==typeof n?n.split(" "):[n];r<4;r++)i[e+oe[r]+t]=o[r]||o[r-2]||o[0];return i}},"margin"!==e&&(k.cssHooks[e+t].set=Qe)}),k.fn.extend({css:function(e,t){return U(this,function(e,t,n){var r,i,o={},s=0;if(Array.isArray(t)){for(r=$e(e),i=t.length;s1)}}),k.Tween=et,et.prototype={constructor:et,init:function(e,t,n,r,i,o){this.elem=e,this.prop=n,this.easing=i||k.easing._default,this.options=t,this.start=this.now=this.cur(),this.end=r,this.unit=o||(k.cssNumber[n]?"":"px")},cur:function(){var e=et.propHooks[this.prop];return e&&e.get?e.get(this):et.propHooks._default.get(this)},run:function(e){var t,n=et.propHooks[this.prop];return this.options.duration?this.pos=t=k.easing[this.easing](e,this.options.duration*e,0,1,this.options.duration):this.pos=t=e,this.now=(this.end-this.start)*t+this.start,this.options.step&&this.options.step.call(this.elem,this.now,this),n&&n.set?n.set(this):et.propHooks._default.set(this),this}},et.prototype.init.prototype=et.prototype,et.propHooks={_default:{get:function(e){var t;return 1!==e.elem.nodeType||null!=e.elem[e.prop]&&null==e.elem.style[e.prop]?e.elem[e.prop]:(t=k.css(e.elem,e.prop,""))&&"auto"!==t?t:0},set:function(e){k.fx.step[e.prop]?k.fx.step[e.prop](e):1!==e.elem.nodeType||null==e.elem.style[k.cssProps[e.prop]]&&!k.cssHooks[e.prop]?e.elem[e.prop]=e.now:k.style(e.elem,e.prop,e.now+e.unit)}}},et.propHooks.scrollTop=et.propHooks.scrollLeft={set:function(e){e.elem.nodeType&&e.elem.parentNode&&(e.elem[e.prop]=e.now)}},k.easing={linear:function(e){return e},swing:function(e){return.5-Math.cos(e*Math.PI)/2},_default:"swing"},k.fx=et.prototype.init,k.fx.step={};var tt,nt,rt=/^(?:toggle|show|hide)$/,it=/queueHooks$/;function ot(){nt&&(!1===s.hidden&&n.requestAnimationFrame?n.requestAnimationFrame(ot):n.setTimeout(ot,k.fx.interval),k.fx.tick())}function st(){return n.setTimeout(function(){tt=void 0}),tt=Date.now()}function at(e,t){var n,r=0,i={height:e};for(t=t?1:0;r<4;r+=2-t)i["margin"+(n=oe[r])]=i["padding"+n]=e;return t&&(i.opacity=i.width=e),i}function lt(e,t,n){for(var r,i=(ut.tweeners[t]||[]).concat(ut.tweeners["*"]),o=0,s=i.length;o1)},removeAttr:function(e){return this.each(function(){k.removeAttr(this,e)})}}),k.extend({attr:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return void 0===e.getAttribute?k.prop(e,t,n):(1===o&&k.isXMLDoc(e)||(i=k.attrHooks[t.toLowerCase()]||(k.expr.match.bool.test(t)?ct:void 0)),void 0!==n?null===n?void k.removeAttr(e,t):i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:(e.setAttribute(t,n+""),n):i&&"get"in i&&null!==(r=i.get(e,t))?r:null==(r=k.find.attr(e,t))?void 0:r)},attrHooks:{type:{set:function(e,t){if(!v.radioValue&&"radio"===t&&T(e,"input")){var n=e.value;return e.setAttribute("type",t),n&&(e.value=n),t}}}},removeAttr:function(e,t){var n,r=0,i=t&&t.match(j);if(i&&1===e.nodeType)for(;n=i[r++];)e.removeAttribute(n)}}),ct={set:function(e,t,n){return!1===t?k.removeAttr(e,n):e.setAttribute(n,n),n}},k.each(k.expr.match.bool.source.match(/\w+/g),function(e,t){var n=ht[t]||k.find.attr;ht[t]=function(e,t,r){var i,o,s=t.toLowerCase();return r||(o=ht[s],ht[s]=i,i=null!=n(e,t,r)?s:null,ht[s]=o),i}});var dt=/^(?:input|select|textarea|button)$/i,ft=/^(?:a|area)$/i;function pt(e){return(e.match(j)||[]).join(" ")}function gt(e){return e.getAttribute&&e.getAttribute("class")||""}function mt(e){return Array.isArray(e)?e:"string"==typeof e&&e.match(j)||[]}k.fn.extend({prop:function(e,t){return U(this,k.prop,e,t,arguments.length>1)},removeProp:function(e){return this.each(function(){delete this[k.propFix[e]||e]})}}),k.extend({prop:function(e,t,n){var r,i,o=e.nodeType;if(3!==o&&8!==o&&2!==o)return 1===o&&k.isXMLDoc(e)||(t=k.propFix[t]||t,i=k.propHooks[t]),void 0!==n?i&&"set"in i&&void 0!==(r=i.set(e,n,t))?r:e[t]=n:i&&"get"in i&&null!==(r=i.get(e,t))?r:e[t]},propHooks:{tabIndex:{get:function(e){var t=k.find.attr(e,"tabindex");return t?parseInt(t,10):dt.test(e.nodeName)||ft.test(e.nodeName)&&e.href?0:-1}}},propFix:{for:"htmlFor",class:"className"}}),v.optSelected||(k.propHooks.selected={get:function(e){var t=e.parentNode;return t&&t.parentNode&&t.parentNode.selectedIndex,null},set:function(e){var t=e.parentNode;t&&(t.selectedIndex,t.parentNode&&t.parentNode.selectedIndex)}}),k.each(["tabIndex","readOnly","maxLength","cellSpacing","cellPadding","rowSpan","colSpan","useMap","frameBorder","contentEditable"],function(){k.propFix[this.toLowerCase()]=this}),k.fn.extend({addClass:function(e){var t,n,r,i,o,s,a,l=0;if(y(e))return this.each(function(t){k(this).addClass(e.call(this,t,gt(this)))});if((t=mt(e)).length)for(;n=this[l++];)if(i=gt(n),r=1===n.nodeType&&" "+pt(i)+" "){for(s=0;o=t[s++];)r.indexOf(" "+o+" ")<0&&(r+=o+" ");i!==(a=pt(r))&&n.setAttribute("class",a)}return this},removeClass:function(e){var t,n,r,i,o,s,a,l=0;if(y(e))return this.each(function(t){k(this).removeClass(e.call(this,t,gt(this)))});if(!arguments.length)return this.attr("class","");if((t=mt(e)).length)for(;n=this[l++];)if(i=gt(n),r=1===n.nodeType&&" "+pt(i)+" "){for(s=0;o=t[s++];)for(;r.indexOf(" "+o+" ")>-1;)r=r.replace(" "+o+" "," ");i!==(a=pt(r))&&n.setAttribute("class",a)}return this},toggleClass:function(e,t){var n=typeof e,r="string"===n||Array.isArray(e);return"boolean"==typeof t&&r?t?this.addClass(e):this.removeClass(e):y(e)?this.each(function(n){k(this).toggleClass(e.call(this,n,gt(this),t),t)}):this.each(function(){var t,i,o,s;if(r)for(i=0,o=k(this),s=mt(e);t=s[i++];)o.hasClass(t)?o.removeClass(t):o.addClass(t);else void 0!==e&&"boolean"!==n||((t=gt(this))&&Z.set(this,"__className__",t),this.setAttribute&&this.setAttribute("class",t||!1===e?"":Z.get(this,"__className__")||""))})},hasClass:function(e){var t,n,r=0;for(t=" "+e+" ";n=this[r++];)if(1===n.nodeType&&(" "+pt(gt(n))+" ").indexOf(t)>-1)return!0;return!1}});var vt=/\r/g;k.fn.extend({val:function(e){var t,n,r,i=this[0];return arguments.length?(r=y(e),this.each(function(n){var i;1===this.nodeType&&(null==(i=r?e.call(this,n,k(this).val()):e)?i="":"number"==typeof i?i+="":Array.isArray(i)&&(i=k.map(i,function(e){return null==e?"":e+""})),(t=k.valHooks[this.type]||k.valHooks[this.nodeName.toLowerCase()])&&"set"in t&&void 0!==t.set(this,i,"value")||(this.value=i))})):i?(t=k.valHooks[i.type]||k.valHooks[i.nodeName.toLowerCase()])&&"get"in t&&void 0!==(n=t.get(i,"value"))?n:"string"==typeof(n=i.value)?n.replace(vt,""):null==n?"":n:void 0}}),k.extend({valHooks:{option:{get:function(e){var t=k.find.attr(e,"value");return null!=t?t:pt(k.text(e))}},select:{get:function(e){var t,n,r,i=e.options,o=e.selectedIndex,s="select-one"===e.type,a=s?null:[],l=s?o+1:i.length;for(r=o<0?l:s?o:0;r-1)&&(n=!0);return n||(e.selectedIndex=-1),o}}}}),k.each(["radio","checkbox"],function(){k.valHooks[this]={set:function(e,t){if(Array.isArray(t))return e.checked=k.inArray(k(e).val(),t)>-1}},v.checkOn||(k.valHooks[this].get=function(e){return null===e.getAttribute("value")?"on":e.value})}),v.focusin="onfocusin"in n;var yt=/^(?:focusinfocus|focusoutblur)$/,bt=function(e){e.stopPropagation()};k.extend(k.event,{trigger:function(e,t,r,i){var o,a,l,u,c,h,d,f,g=[r||s],m=p.call(e,"type")?e.type:e,v=p.call(e,"namespace")?e.namespace.split("."):[];if(a=f=l=r=r||s,3!==r.nodeType&&8!==r.nodeType&&!yt.test(m+k.event.triggered)&&(m.indexOf(".")>-1&&(m=(v=m.split(".")).shift(),v.sort()),c=m.indexOf(":")<0&&"on"+m,(e=e[k.expando]?e:new k.Event(m,"object"==typeof e&&e)).isTrigger=i?2:3,e.namespace=v.join("."),e.rnamespace=e.namespace?new RegExp("(^|\\.)"+v.join("\\.(?:.*\\.|)")+"(\\.|$)"):null,e.result=void 0,e.target||(e.target=r),t=null==t?[e]:k.makeArray(t,[e]),d=k.event.special[m]||{},i||!d.trigger||!1!==d.trigger.apply(r,t))){if(!i&&!d.noBubble&&!b(r)){for(u=d.delegateType||m,yt.test(u+m)||(a=a.parentNode);a;a=a.parentNode)g.push(a),l=a;l===(r.ownerDocument||s)&&g.push(l.defaultView||l.parentWindow||n)}for(o=0;(a=g[o++])&&!e.isPropagationStopped();)f=a,e.type=o>1?u:d.bindType||m,(h=(Z.get(a,"events")||{})[e.type]&&Z.get(a,"handle"))&&h.apply(a,t),(h=c&&a[c])&&h.apply&&X(a)&&(e.result=h.apply(a,t),!1===e.result&&e.preventDefault());return e.type=m,i||e.isDefaultPrevented()||d._default&&!1!==d._default.apply(g.pop(),t)||!X(r)||c&&y(r[m])&&!b(r)&&((l=r[c])&&(r[c]=null),k.event.triggered=m,e.isPropagationStopped()&&f.addEventListener(m,bt),r[m](),e.isPropagationStopped()&&f.removeEventListener(m,bt),k.event.triggered=void 0,l&&(r[c]=l)),e.result}},simulate:function(e,t,n){var r=k.extend(new k.Event,n,{type:e,isSimulated:!0});k.event.trigger(r,null,t)}}),k.fn.extend({trigger:function(e,t){return this.each(function(){k.event.trigger(e,t,this)})},triggerHandler:function(e,t){var n=this[0];if(n)return k.event.trigger(e,t,n,!0)}}),v.focusin||k.each({focus:"focusin",blur:"focusout"},function(e,t){var n=function(e){k.event.simulate(t,e.target,k.event.fix(e))};k.event.special[t]={setup:function(){var r=this.ownerDocument||this,i=Z.access(r,t);i||r.addEventListener(e,n,!0),Z.access(r,t,(i||0)+1)},teardown:function(){var r=this.ownerDocument||this,i=Z.access(r,t)-1;i?Z.access(r,t,i):(r.removeEventListener(e,n,!0),Z.remove(r,t))}}});var xt=n.location,wt=Date.now(),Ct=/\?/;k.parseXML=function(e){var t;if(!e||"string"!=typeof e)return null;try{t=(new n.DOMParser).parseFromString(e,"text/xml")}catch(e){t=void 0}return t&&!t.getElementsByTagName("parsererror").length||k.error("Invalid XML: "+e),t};var kt=/\[\]$/,Et=/\r?\n/g,At=/^(?:submit|button|image|reset|file)$/i,_t=/^(?:input|select|textarea|keygen)/i;function St(e,t,n,r){var i;if(Array.isArray(t))k.each(t,function(t,i){n||kt.test(e)?r(e,i):St(e+"["+("object"==typeof i&&null!=i?t:"")+"]",i,n,r)});else if(n||"object"!==C(t))r(e,t);else for(i in t)St(e+"["+i+"]",t[i],n,r)}k.param=function(e,t){var n,r=[],i=function(e,t){var n=y(t)?t():t;r[r.length]=encodeURIComponent(e)+"="+encodeURIComponent(null==n?"":n)};if(Array.isArray(e)||e.jquery&&!k.isPlainObject(e))k.each(e,function(){i(this.name,this.value)});else for(n in e)St(n,e[n],t,i);return r.join("&")},k.fn.extend({serialize:function(){return k.param(this.serializeArray())},serializeArray:function(){return this.map(function(){var e=k.prop(this,"elements");return e?k.makeArray(e):this}).filter(function(){var e=this.type;return this.name&&!k(this).is(":disabled")&&_t.test(this.nodeName)&&!At.test(e)&&(this.checked||!de.test(e))}).map(function(e,t){var n=k(this).val();return null==n?null:Array.isArray(n)?k.map(n,function(e){return{name:t.name,value:e.replace(Et,"\r\n")}}):{name:t.name,value:n.replace(Et,"\r\n")}}).get()}});var Ft=/%20/g,Dt=/#.*$/,Tt=/([?&])_=[^&]*/,Lt=/^(.*?):[ \t]*([^\r\n]*)$/gm,Bt=/^(?:GET|HEAD)$/,Mt=/^\/\//,Pt={},Rt={},Ot="*/".concat("*"),It=s.createElement("a");function jt(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,o=t.toLowerCase().match(j)||[];if(y(n))for(;r=o[i++];)"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function Nt(e,t,n,r){var i={},o=e===Rt;function s(a){var l;return i[a]=!0,k.each(e[a]||[],function(e,a){var u=a(t,n,r);return"string"!=typeof u||o||i[u]?o?!(l=u):void 0:(t.dataTypes.unshift(u),s(u),!1)}),l}return s(t.dataTypes[0])||!i["*"]&&s("*")}function $t(e,t){var n,r,i=k.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&k.extend(!0,e,r),e}It.href=xt.href,k.extend({active:0,lastModified:{},etag:{},ajaxSettings:{url:xt.href,type:"GET",isLocal:/^(?:about|app|app-storage|.+-extension|file|res|widget):$/.test(xt.protocol),global:!0,processData:!0,async:!0,contentType:"application/x-www-form-urlencoded; charset=UTF-8",accepts:{"*":Ot,text:"text/plain",html:"text/html",xml:"application/xml, text/xml",json:"application/json, text/javascript"},contents:{xml:/\bxml\b/,html:/\bhtml/,json:/\bjson\b/},responseFields:{xml:"responseXML",text:"responseText",json:"responseJSON"},converters:{"* text":String,"text html":!0,"text json":JSON.parse,"text xml":k.parseXML},flatOptions:{url:!0,context:!0}},ajaxSetup:function(e,t){return t?$t($t(e,k.ajaxSettings),t):$t(k.ajaxSettings,e)},ajaxPrefilter:jt(Pt),ajaxTransport:jt(Rt),ajax:function(e,t){"object"==typeof e&&(t=e,e=void 0),t=t||{};var r,i,o,a,l,u,c,h,d,f,p=k.ajaxSetup({},t),g=p.context||p,m=p.context&&(g.nodeType||g.jquery)?k(g):k.event,v=k.Deferred(),y=k.Callbacks("once memory"),b=p.statusCode||{},x={},w={},C="canceled",E={readyState:0,getResponseHeader:function(e){var t;if(c){if(!a)for(a={};t=Lt.exec(o);)a[t[1].toLowerCase()]=t[2];t=a[e.toLowerCase()]}return null==t?null:t},getAllResponseHeaders:function(){return c?o:null},setRequestHeader:function(e,t){return null==c&&(e=w[e.toLowerCase()]=w[e.toLowerCase()]||e,x[e]=t),this},overrideMimeType:function(e){return null==c&&(p.mimeType=e),this},statusCode:function(e){var t;if(e)if(c)E.always(e[E.status]);else for(t in e)b[t]=[b[t],e[t]];return this},abort:function(e){var t=e||C;return r&&r.abort(t),A(0,t),this}};if(v.promise(E),p.url=((e||p.url||xt.href)+"").replace(Mt,xt.protocol+"//"),p.type=t.method||t.type||p.method||p.type,p.dataTypes=(p.dataType||"*").toLowerCase().match(j)||[""],null==p.crossDomain){u=s.createElement("a");try{u.href=p.url,u.href=u.href,p.crossDomain=It.protocol+"//"+It.host!=u.protocol+"//"+u.host}catch(e){p.crossDomain=!0}}if(p.data&&p.processData&&"string"!=typeof p.data&&(p.data=k.param(p.data,p.traditional)),Nt(Pt,p,t,E),c)return E;for(d in(h=k.event&&p.global)&&0==k.active++&&k.event.trigger("ajaxStart"),p.type=p.type.toUpperCase(),p.hasContent=!Bt.test(p.type),i=p.url.replace(Dt,""),p.hasContent?p.data&&p.processData&&0===(p.contentType||"").indexOf("application/x-www-form-urlencoded")&&(p.data=p.data.replace(Ft,"+")):(f=p.url.slice(i.length),p.data&&(p.processData||"string"==typeof p.data)&&(i+=(Ct.test(i)?"&":"?")+p.data,delete p.data),!1===p.cache&&(i=i.replace(Tt,"$1"),f=(Ct.test(i)?"&":"?")+"_="+wt+++f),p.url=i+f),p.ifModified&&(k.lastModified[i]&&E.setRequestHeader("If-Modified-Since",k.lastModified[i]),k.etag[i]&&E.setRequestHeader("If-None-Match",k.etag[i])),(p.data&&p.hasContent&&!1!==p.contentType||t.contentType)&&E.setRequestHeader("Content-Type",p.contentType),E.setRequestHeader("Accept",p.dataTypes[0]&&p.accepts[p.dataTypes[0]]?p.accepts[p.dataTypes[0]]+("*"!==p.dataTypes[0]?", "+Ot+"; q=0.01":""):p.accepts["*"]),p.headers)E.setRequestHeader(d,p.headers[d]);if(p.beforeSend&&(!1===p.beforeSend.call(g,E,p)||c))return E.abort();if(C="abort",y.add(p.complete),E.done(p.success),E.fail(p.error),r=Nt(Rt,p,t,E)){if(E.readyState=1,h&&m.trigger("ajaxSend",[E,p]),c)return E;p.async&&p.timeout>0&&(l=n.setTimeout(function(){E.abort("timeout")},p.timeout));try{c=!1,r.send(x,A)}catch(e){if(c)throw e;A(-1,e)}}else A(-1,"No Transport");function A(e,t,s,a){var u,d,f,x,w,C=t;c||(c=!0,l&&n.clearTimeout(l),r=void 0,o=a||"",E.readyState=e>0?4:0,u=e>=200&&e<300||304===e,s&&(x=function(e,t,n){for(var r,i,o,s,a=e.contents,l=e.dataTypes;"*"===l[0];)l.shift(),void 0===r&&(r=e.mimeType||t.getResponseHeader("Content-Type"));if(r)for(i in a)if(a[i]&&a[i].test(r)){l.unshift(i);break}if(l[0]in n)o=l[0];else{for(i in n){if(!l[0]||e.converters[i+" "+l[0]]){o=i;break}s||(s=i)}o=o||s}if(o)return o!==l[0]&&l.unshift(o),n[o]}(p,E,s)),x=function(e,t,n,r){var i,o,s,a,l,u={},c=e.dataTypes.slice();if(c[1])for(s in e.converters)u[s.toLowerCase()]=e.converters[s];for(o=c.shift();o;)if(e.responseFields[o]&&(n[e.responseFields[o]]=t),!l&&r&&e.dataFilter&&(t=e.dataFilter(t,e.dataType)),l=o,o=c.shift())if("*"===o)o=l;else if("*"!==l&&l!==o){if(!(s=u[l+" "+o]||u["* "+o]))for(i in u)if((a=i.split(" "))[1]===o&&(s=u[l+" "+a[0]]||u["* "+a[0]])){!0===s?s=u[i]:!0!==u[i]&&(o=a[0],c.unshift(a[1]));break}if(!0!==s)if(s&&e.throws)t=s(t);else try{t=s(t)}catch(e){return{state:"parsererror",error:s?e:"No conversion from "+l+" to "+o}}}return{state:"success",data:t}}(p,x,E,u),u?(p.ifModified&&((w=E.getResponseHeader("Last-Modified"))&&(k.lastModified[i]=w),(w=E.getResponseHeader("etag"))&&(k.etag[i]=w)),204===e||"HEAD"===p.type?C="nocontent":304===e?C="notmodified":(C=x.state,d=x.data,u=!(f=x.error))):(f=C,!e&&C||(C="error",e<0&&(e=0))),E.status=e,E.statusText=(t||C)+"",u?v.resolveWith(g,[d,C,E]):v.rejectWith(g,[E,C,f]),E.statusCode(b),b=void 0,h&&m.trigger(u?"ajaxSuccess":"ajaxError",[E,p,u?d:f]),y.fireWith(g,[E,C]),h&&(m.trigger("ajaxComplete",[E,p]),--k.active||k.event.trigger("ajaxStop")))}return E},getJSON:function(e,t,n){return k.get(e,t,n,"json")},getScript:function(e,t){return k.get(e,void 0,t,"script")}}),k.each(["get","post"],function(e,t){k[t]=function(e,n,r,i){return y(n)&&(i=i||r,r=n,n=void 0),k.ajax(k.extend({url:e,type:t,dataType:i,data:n,success:r},k.isPlainObject(e)&&e))}}),k._evalUrl=function(e){return k.ajax({url:e,type:"GET",dataType:"script",cache:!0,async:!1,global:!1,throws:!0})},k.fn.extend({wrapAll:function(e){var t;return this[0]&&(y(e)&&(e=e.call(this[0])),t=k(e,this[0].ownerDocument).eq(0).clone(!0),this[0].parentNode&&t.insertBefore(this[0]),t.map(function(){for(var e=this;e.firstElementChild;)e=e.firstElementChild;return e}).append(this)),this},wrapInner:function(e){return y(e)?this.each(function(t){k(this).wrapInner(e.call(this,t))}):this.each(function(){var t=k(this),n=t.contents();n.length?n.wrapAll(e):t.append(e)})},wrap:function(e){var t=y(e);return this.each(function(n){k(this).wrapAll(t?e.call(this,n):e)})},unwrap:function(e){return this.parent(e).not("body").each(function(){k(this).replaceWith(this.childNodes)}),this}}),k.expr.pseudos.hidden=function(e){return!k.expr.pseudos.visible(e)},k.expr.pseudos.visible=function(e){return!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length)},k.ajaxSettings.xhr=function(){try{return new n.XMLHttpRequest}catch(e){}};var Wt={0:200,1223:204},zt=k.ajaxSettings.xhr();v.cors=!!zt&&"withCredentials"in zt,v.ajax=zt=!!zt,k.ajaxTransport(function(e){var t,r;if(v.cors||zt&&!e.crossDomain)return{send:function(i,o){var s,a=e.xhr();if(a.open(e.type,e.url,e.async,e.username,e.password),e.xhrFields)for(s in e.xhrFields)a[s]=e.xhrFields[s];for(s in e.mimeType&&a.overrideMimeType&&a.overrideMimeType(e.mimeType),e.crossDomain||i["X-Requested-With"]||(i["X-Requested-With"]="XMLHttpRequest"),i)a.setRequestHeader(s,i[s]);t=function(e){return function(){t&&(t=r=a.onload=a.onerror=a.onabort=a.ontimeout=a.onreadystatechange=null,"abort"===e?a.abort():"error"===e?"number"!=typeof a.status?o(0,"error"):o(a.status,a.statusText):o(Wt[a.status]||a.status,a.statusText,"text"!==(a.responseType||"text")||"string"!=typeof a.responseText?{binary:a.response}:{text:a.responseText},a.getAllResponseHeaders()))}},a.onload=t(),r=a.onerror=a.ontimeout=t("error"),void 0!==a.onabort?a.onabort=r:a.onreadystatechange=function(){4===a.readyState&&n.setTimeout(function(){t&&r()})},t=t("abort");try{a.send(e.hasContent&&e.data||null)}catch(e){if(t)throw e}},abort:function(){t&&t()}}}),k.ajaxPrefilter(function(e){e.crossDomain&&(e.contents.script=!1)}),k.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/\b(?:java|ecma)script\b/},converters:{"text script":function(e){return k.globalEval(e),e}}}),k.ajaxPrefilter("script",function(e){void 0===e.cache&&(e.cache=!1),e.crossDomain&&(e.type="GET")}),k.ajaxTransport("script",function(e){var t,n;if(e.crossDomain)return{send:function(r,i){t=k("