};
})(),
};
+var hist = [];
+var currhist = 0;
document.getElementById("replform").addEventListener("submit", e => {
e.preventDefault();
let outzone = document.getElementById("replout");
let inelt = document.createElement('div');
- let instr = e.target[0].value
+ let instr = e.target[0].value;
+ hist.unshift(instr);
+ currhist = 0;
inelt.textContent += "<- " + instr + "\n";
inelt.addEventListener("click", (eclick) => {
let replin = document.getElementById('replin');
outzone.appendChild(outelt);
document.getElementById('replin').value = ""
});
+document.getElementById('replin').addEventListener("keydown", e=> {
+ if(hist.length == 0) return;
+ if(e.key == "ArrowUp") {
+ currhist = Math.min(hist.length, currhist+1);
+ document.getElementById('replin').value = hist[currhist-1];
+ }
+ if(e.key == "ArrowDown") {
+ currhist = Math.max(0, currhist-1);
+ document.getElementById('replin').value = currhist==0 ? "" : hist[currhist-1];
+ }
+});
+
if('serviceWorker' in navigator) {
console.log('registering');