mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-18 20:25:45 +01:00
Added up button history mechanic to terminal..the basics work
This commit is contained in:
parent
9fa616b61a
commit
1fa0ef339a
@ -112,7 +112,7 @@
|
|||||||
<div id="terminal-container">
|
<div id="terminal-container">
|
||||||
<table id="terminal">
|
<table id="terminal">
|
||||||
<tr id="terminal-input">
|
<tr id="terminal-input">
|
||||||
<td id="terminal-input-td">$ <input type="text" class="terminal-input"/></td>
|
<td id="terminal-input-td">$ <input type="text" id="terminal-input-text-box" class="terminal-input"/></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
@ -17,6 +17,7 @@ var hackProgressPost = function(input) {
|
|||||||
updateTerminalScroll();
|
updateTerminalScroll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Scroll to the bottom of the terminal's 'text area'
|
||||||
function updateTerminalScroll() {
|
function updateTerminalScroll() {
|
||||||
var element = document.getElementById("terminal-container");
|
var element = document.getElementById("terminal-container");
|
||||||
element.scrollTop = element.scrollHeight;
|
element.scrollTop = element.scrollHeight;
|
||||||
@ -48,6 +49,18 @@ $(document).keyup(function(event) {
|
|||||||
Engine._actionInProgress = false;
|
Engine._actionInProgress = false;
|
||||||
Terminal.finishAction(true);
|
Terminal.finishAction(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Up key to cycle through past commands
|
||||||
|
if (event.keyCode == 38) {
|
||||||
|
if (Terminal.commandHistory.length == 0) {return;}
|
||||||
|
if (Terminal.commandHistoryIndex < 0 ||
|
||||||
|
Terminal.commandHistoryIndex >= Terminal.commandHistory.length) {
|
||||||
|
Terminal.commandHistoryIndex = Terminal.commandHistory.length-1;
|
||||||
|
}
|
||||||
|
var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex];
|
||||||
|
document.getElementById("terminal-input-text-box").value = prevCommand;
|
||||||
|
--Terminal.commandHistoryIndex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -83,6 +96,9 @@ var Terminal = {
|
|||||||
hackFlag: false,
|
hackFlag: false,
|
||||||
analyzeFlag: false,
|
analyzeFlag: false,
|
||||||
|
|
||||||
|
commandHistory: [],
|
||||||
|
commandHistoryIndex: 0,
|
||||||
|
|
||||||
finishAction: function(cancelled = false) {
|
finishAction: function(cancelled = false) {
|
||||||
if (Terminal.hackFlag) {
|
if (Terminal.hackFlag) {
|
||||||
Terminal.finishHack(cancelled);
|
Terminal.finishHack(cancelled);
|
||||||
@ -181,6 +197,12 @@ var Terminal = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
executeCommand: function(command) {
|
executeCommand: function(command) {
|
||||||
|
Terminal.commandHistory.push(command);
|
||||||
|
if (Terminal.commandHistory.length > 50) {
|
||||||
|
Terminal.commandHistory.splice(0);
|
||||||
|
}
|
||||||
|
Terminal.commandHistoryIndex = Terminal.commandHistory.length - 1;
|
||||||
|
|
||||||
var commandArray = command.split(" ");
|
var commandArray = command.split(" ");
|
||||||
|
|
||||||
if (commandArray.length == 0) {
|
if (commandArray.length == 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user