Initial commit

This commit is contained in:
l_samenv
2020-12-04 09:05:06 +01:00
parent 172042e731
commit 9e1d3b4e07
54 changed files with 47695 additions and 0 deletions

View File

@ -0,0 +1,67 @@
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
// % CONSOLE
var commandHistory = []; // Stores commands executed by console.
var histIndex = -1; // Selected element of 'commandHistory'. (-1 = "")
function createContentConsole(s) {
// Creates input-textfield and texarea showing console-history.
var commandline = document.createElement('input');
commandline.setAttribute("type", "text");
commandline.setAttribute("class", "row commandline");
commandline.onkeydown = function (e) {
//console.log(histIndex);
if (e.which === 38 || e.key == "ArrowUp") {
if (histIndex + 1 < commandHistory.length) {
histIndex++;
this.value = commandHistory[histIndex];
}
var input = this;
window.setTimeout(
function () {
input.setSelectionRange(input.value.length,
input.value.length);
}, 0, input);
}
if (e.which === 40 || e.key == "ArrowDown") {
if (histIndex >= 0) {
histIndex--;
if (histIndex > -1) {
this.value = commandHistory[histIndex];
} else {
this.value = "";
}
}
}
};
commandline.setAttribute("autocomplete", "on");
var wrapper = document.createElement('form');
wrapper.setAttribute("class", "commandline-wrapper");
wrapper.onsubmit = function (e) {
e.preventDefault();
histIndex = -1;
// Request for command.
reqJSON(s, "http://" + hostPort + "/sendcommand?command="
+ commandline.value + "&id=" + clientID, successHandler,
errorHandler);
commandline.value = "";
};
wrapper.setAttribute("method", 'GET');
wrapper.appendChild(commandline);
var history = document.createElement('div');
history.setAttribute("class", "history");
var content = document.createElement('div');
content.setAttribute("class", "content-console");
content.appendChild(wrapper);
content.appendChild(history);
return content;
}