User:Vaxonian/sandbox

Source: Wikipedia, the free encyclopedia.

<html>

[page.title]

<script> /*! terminal.js v2.0 | (c) 2014 Erik Österberg | https://github.com/eosterberg/terminaljs */

var Terminal = (function () { // PROMPT_TYPE var PROMPT_INPUT = 1, PROMPT_PASSWORD = 2, PROMPT_CONFIRM = 3

var fireCursorInterval = function (inputField, terminalObj) { var cursor = terminalObj._cursor setTimeout(function () { if (inputField.parentElement && terminalObj._shouldBlinkCursor) { cursor.style.visibility = cursor.style.visibility === 'visible' ? 'hidden' : 'visible' fireCursorInterval(inputField, terminalObj) } else { cursor.style.visibility = 'visible' } }, 500) }

var firstPrompt = true; promptInput = function (terminalObj, message, PROMPT_TYPE, callback) { var shouldDisplayInput = (PROMPT_TYPE === PROMPT_INPUT) var inputField = document.createElement('input')

inputField.style.position = 'absolute' inputField.style.zIndex = '-100' inputField.style.outline = 'none' inputField.style.border = 'none' inputField.style.opacity = '0' inputField.style.fontSize = '0.2em'

terminalObj._inputLine.innerHTML = inputStartChar terminalObj._input.style.display = 'block' terminalObj.html.appendChild(inputField) fireCursorInterval(inputField, terminalObj)

if (message.length) terminalObj.print(PROMPT_TYPE === PROMPT_CONFIRM ? message + ' (y/n)' : message)

inputField.onblur = function () { terminalObj._cursor.style.display = 'none' }

inputField.onfocus = function () { inputField.value = terminalObj._inputLine.textContent terminalObj._cursor.style.display = 'inline' }

terminalObj.html.onclick = function () { inputField.focus() }

inputField.onkeydown = function (e) { if (e.which === 37 || e.which === 39 || e.which === 38 || e.which === 40 || e.which === 9) { e.preventDefault() } else if (shouldDisplayInput && e.which !== 13) { setTimeout(function () { if(inputField.value.length == 0) inputField.value = inputStartChar; terminalObj._inputLine.innerHTML = inputField.value }, 1) } } inputField.onkeyup = function (e) { if (PROMPT_TYPE === PROMPT_CONFIRM || e.which === 13) { terminalObj._input.style.display = 'none' var inputValue = inputField.value if (shouldDisplayInput) terminalObj.print(inputValue) terminalObj.html.removeChild(inputField) if (typeof(callback) === 'function') { if (PROMPT_TYPE === PROMPT_CONFIRM) { callback(inputValue.toUpperCase()[0] === 'Y' ? true : false) } else callback(inputValue.slice(inputStartChar.length)) } } } if (firstPrompt) { firstPrompt = false setTimeout(function () { inputField.focus() }, 50) } else { inputField.focus() } }

var terminalBeep

var TerminalConstructor = function (id) { /*if (!terminalBeep) { terminalBeep = document.createElement('audio') var source = '<source src="http://www.erikosterberg.com/terminaljs/beep.' terminalBeep.innerHTML = source + 'mp3" type="audio/mpeg">' + source + 'ogg" type="audio/ogg">' terminalBeep.volume = 0.05 }*/

this.html = document.createElement('div') this.html.className = 'Terminal' if (typeof(id) === 'string') { this.html.id = id }

this._innerWindow = document.createElement('div') this._output = document.createElement('p') this._inputLine = document.createElement('span') //the span element where the users input is put this._cursor = document.createElement('span') this._input = document.createElement('p') //the full element administering the user input, including cursor

this._shouldBlinkCursor = true

this.beep = function () { terminalBeep.load() terminalBeep.play() }

this.print = function (message) { var newLine = document.createElement('div') newLine.innerHTML = message this._output.appendChild(newLine) }

this.input = function (message, callback) { promptInput(this, message, PROMPT_INPUT, callback) }

this.password = function (message, callback) { promptInput(this, message, PROMPT_PASSWORD, callback) }

this.confirm = function (message, callback) { promptInput(this, message, PROMPT_CONFIRM, callback) }

this.clear = function () { this._output.innerHTML = }

this.sleep = function (milliseconds, callback) { setTimeout(callback, milliseconds) }

this.setTextSize = function (size) { this._output.style.fontSize = size this._input.style.fontSize = size }

this.setTextColor = function (col) { this.html.style.color = col this._cursor.style.background = col }

this.setBackgroundColor = function (col) { this.html.style.background = col }

this.setWidth = function (width) { this.html.style.width = width }

this.setHeight = function (height) { this.html.style.height = height }

this.blinkingCursor = function (bool) { bool = bool.toString().toUpperCase() this._shouldBlinkCursor = (bool === 'TRUE' || bool === '1' || bool === 'YES') }

this._input.appendChild(this._inputLine) this._input.appendChild(this._cursor) this._innerWindow.appendChild(this._output) this._innerWindow.appendChild(this._input) this.html.appendChild(this._innerWindow)

this.setBackgroundColor('black') this.setTextColor('white') this.setTextSize('1em') this.setWidth('100%') this.setHeight('100%')

this.html.style.fontFamily = 'Monaco, Courier' this.html.style.margin = '0' this._innerWindow.style.padding = '10px' this._input.style.margin = '0' this._output.style.margin = '0' this._cursor.style.background = 'white' this._cursor.innerHTML = 'C' //put something in the cursor.. this._cursor.style.display = 'none' //then hide it this._input.style.display = 'none' }

return TerminalConstructor }()); </script>


<style> .Terminal { overflow-y: auto; } .Terminal > div div { white-space: pre-wrap; } body { background-color: black; text-shadow: 0 0 5px #C8C8C8; } #fuzzy-overlay { z-index:3; position: absolute; top: 0; left: 0; bottom: 0; right: 0; background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0.15) 1px, transparent 1px, transparent 2px); pointer-events: none; }

::selection { background: #0080FF; text-shadow: none; }

pre {

 margin: 0;

}

</style>

<script>

 let history = [];

let historyIndex = -1;

 window.addEventListener('resize', e => {

terminal.setHeight(window.innerHeight+"px"); });

 window.addEventListener('keyup', e => {

if(e.which === 13) setTimeout(() => document.querySelector(".Terminal").scrollTop = 999999999, 10); });

 window.addEventListener('keydown', e => {

if(historyIndex === -1 || (e.which !== 38 && e.which !== 40)) return; let dir = e.which === 38 ? 'up' : 'down'; if(dir === 'down' && historyIndex === history.length-1) return; if(dir === 'up' && historyIndex === 0) return;

historyIndex = dir === 'up' ? historyIndex-1 : historyIndex+1; document.querySelector("#mainCtn .Terminal > div > p:last-child > span").textContent = inputStartChar+history[historyIndex]; document.querySelector("#mainCtn .Terminal > input").value = inputStartChar+history[historyIndex]; });

 let terminal = new Terminal();
 mainCtn.appendChild(terminal.html);

(async function() {

let printTmp = terminal.print.bind(terminal); terminal.print = function(text) { text = (text+""); text = text.replace(/
/g, "\n"); text = text.replace(/\\n/g, "\n");

     printTmp(text);

}

terminal.setTextSize(page.font.size+"em"); terminal.setTextColor(page.font.color); terminal.setHeight(window.innerHeight+"px"); terminal.setBackgroundColor(page.background.color); console.log(page.glow, document.querySelector("#mainCtn .Terminal")); if(page.glow !== "none") document.querySelector("#mainCtn .Terminal").style.backgroundImage = `radial-gradient(${page.glow},black 120%)`;

terminal.print(welcome);

while(1) {

     await new Promise((resolve, reject) => {

terminal.input("", function (userInput) { if(history[history.length-1] !== userInput && userInput.trim()) history.push(userInput); if(history.length > 500) history.slice(-450); historyIndex = history.length;

if(userInput.trim() === "") { terminal.print(" "); resolve(); return; } if(userInput.trim() === "help") { let maxLength = Math.max(...commands.selectAll.map(c => c.getName.length)); terminal.print("Here are the available commands:\n"+commands.selectAll.map(c => ` ${c.getName.padEnd(maxLength)} ${c.description}`).join("\n")); resolve(); return; }

window.command = userInput.split(/\s+/)[0]; if(userInput.indexOf(" ") !== -1) window.input = userInput.slice(userInput.indexOf(" ")+1); else window.input = "";

// print result of command: let result = commands[command];

         terminal.print(result === undefined ? errors.commandNotFound : result.output);

resolve();

       });

}) } })();

 document.querySelector("#mainCtn .Terminal").focus();

function beepFn() {

   var snd = new Audio("data:audio/wav;base64,//uQRAAAAWMSLwUIYAAsYkXgoQwAEaYLWfkWgAI0wWs/ItAAAGDgYtAgAyN+QWaAAihwMWm4G8QQRDiMcCBcH3Cc+CDv/7xA4Tvh9Rz/y8QADBwMWgQAZG/ILNAARQ4GLTcDeIIIhxGOBAuD7hOfBB3/94gcJ3w+o5/5eIAIAAAVwWgQAVQ2ORaIQwEMAJiDg95G4nQL7mQVWI6GwRcfsZAcsKkJvxgxEjzFUgfHoSQ9Qq7KNwqHwuB13MA4a1q/DmBrHgPcmjiGoh//EwC5nGPEmS4RcfkVKOhJf+WOgoxJclFz3kgn//dBA+ya1GhurNn8zb//9NNutNuhz31f////9vt///z+IdAEAAAK4LQIAKobHItEIYCGAExBwe8jcToF9zIKrEdDYIuP2MgOWFSE34wYiR5iqQPj0JIeoVdlG4VD4XA67mAcNa1fhzA1jwHuTRxDUQ//iYBczjHiTJcIuPyKlHQkv/LHQUYkuSi57yQT//uggfZNajQ3Vmz+Zt//+mm3Wm3Q576v////+32///5/EOgAAADVghQAAAAA//uQZAU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LdGIxsY7AUABPRrgCABdDuQ5GC7DqPQCgbbJUAoRSUj+NIEig0YfyWUho1VBBBA//uQZB4ABZx5zfMakeAAAAmwAAAAF5F3P0w9GtAAACfAAAAAwLhMDmAYWMgVEG1U0FIGCBgXBXAtfMH10000EEEEEECUBYln03TTTdNBDZopopYvrTTdNa325mImNg3TTPV9q3pmY0xoO6bv3r00y+IDGid/9aaaZTGMuj9mpu9Mpio1dXrr5HERTZSmqU36A3CumzN/9Robv/Xx4v9ijkSRSNLQhAWumap82WRSBUqXStV/YcS+XVLnSS+WLDroqArFkMEsAS+eWmrUzrO0oEmE40RlMZ5+ODIkAyKAGUwZ3mVKmcamcJnMW26MRPgUw6j+LkhyHGVGYjSUUKNpuJUQoOIAyDvEyG8S5yfK6dhZc0Tx1KI/gviKL6qvvFs1+bWtaz58uUNnryq6kt5RzOCkPWlVqVX2a/EEBUdU1KrXLf40GoiiFXK///qpoiDXrOgqDR38JB0bw7SoL+ZB9o1RCkQjQ2CBYZKd/+VJxZRRZlqSkKiws0WFxUyCwsKiMy7hUVFhIaCrNQsKkTIsLivwKKigsj8XYlwt/WKi2N4d//uQRCSAAjURNIHpMZBGYiaQPSYyAAABLAAAAAAAACWAAAAApUF/Mg+0aohSIRobBAsMlO//Kk4soosy1JSFRYWaLC4qZBYWFRGZdwqKiwkNBVmoWFSJkWFxX4FFRQWR+LsS4W/rFRb/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////VEFHAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAU291bmRib3kuZGUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMjAwNGh0dHA6Ly93d3cuc291bmRib3kuZGUAAAAAAAAAACU=");  
   snd.play();

return ""; } window.beep = {}; window.beep.toString = beepFn;

function clearFn() {

   terminal.clear();

return ""; } window.clear = {}; window.clear.toString = clearFn; </script>




</html>