-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
61 lines (53 loc) · 2.54 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
document.addEventListener('DOMContentLoaded', function () {
const output = document.getElementById('output');
const input = document.getElementById('input');
output.innerHTML += "Welcome to the Splashtop Business Terminal. A terminal where you can find functional resources and utilities.\nThis website is intended specifically for the Splashtop Business app on ChromeOS, say `help` for a list of commands. \n\n";
output.innerHTML += '<span style="font-weight: bold; color: red;">[COMMANDS ARE IN TESTING STAGE. BUGS WILL OCCUR]</span>\n\n';
input.addEventListener('keydown', function (event) {
if (event.key === 'Enter') {
event.preventDefault();
processCommand(input.value);
input.value = '';
}
});
function processCommand(command) {
output.innerHTML += `<span class="prompt">> </span>${command}\n\n`;
switch (command.toLowerCase()) {
case 'help':
output.innerHTML += 'help_commands[DEV_NOTE: Some commands are in testing, bugs may occur.]: \ncalculator;\nsnake;\nproxy;\nyoutube\ninfo;\nsetup;\n\n';
break;
case 'calculator':
output.innerHTML += 'We are redirecting you to the calculator app, please wait.\n\n';
storeAndRedirect("./display.html", "calculator");
break;
case 'snake':
output.innerHTML += 'We are redirecting you to the snake_game app, please wait.\n\n';
storeAndRedirect("./display.html", "snake");
break;
case 'proxy':
output.innerHTML += 'We are attempting to redirect you to a proxy_app, please wait.\n[DEV_NOTE: Websites accessed via proxy may not function as intended, relocate back to the terminal using the back button at the top of the page.]\n\n';
storeAndRedirect("./display.html", "proxy");
break;
case 'youtube':
output.innerHTML += "Attempting to redirect you to YOUTUBE. \n[DEV_NOTE: YouTube is a WORK IN PROGRESS, as videos are very buggy on Splashtops Server. (They don't load properly)]\n\n";
break;
default:
output.innerHTML += '<span style="font-weight: bold; color: red;">Invalid command. Type "help" to see available commands.</span>\n\n';
break;
}
output.scrollTop = output.scrollHeight;
}
input.focus();
});
function storeAndRedirect(url, command) {
localStorage.setItem('redirectUrl', url);
localStorage.setItem('command', command);
window.location.href = url;
}
function showTime() {
document.getElementById('currentTime').innerHTML = new Date().toUTCString();
}
showTime();
setInterval(function () {
showTime();
}, 1000);