-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
65 lines (62 loc) · 2.79 KB
/
index.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
62
63
64
65
var inputVal = "";
var blueMode = false;
var sleepTime = 10;
function createPast(val, slp, green=false) {
const newId = `el-${Math.floor(Math.random() * 1000000000)}`;
const elem = document.createElement('div');
elem.id = newId;
elem.className = `balloon${green ? " green" : blueMode ? " blue" : ""}`;
elem.innerHTML = val;
const target = document.querySelector('.balloon:last-child');
target.parentNode.insertBefore(elem, target);
setTimeout(function() {
document.querySelector(`#${newId}`).className = `balloon${green ? " green" : blueMode ? " blue" : ""} hidden`;
setTimeout(function() {
document.querySelector(`#${newId}`).remove();
}, 500);
}, slp * 1000);
}
document.onkeydown = function (e) {
e = e || window.event;
var inp = e.key;
if (inp.length == 1) {
inputVal += inp;
} else {
if (inp == "Backspace") {
inputVal = inputVal.slice(0, -1);
} else if (inp == "Enter") {
if (inputVal == "!color") {
blueMode = blueMode ? false : true;
} else if (inputVal == "!help") {
createPast("Type '!help' to show this screen.", 10, true);
createPast("Type '!color' to switch between colors.", 10, true);
createPast("Type '!window' to toggle window borders and moving.", 10, true);
createPast("Type '!greenScreen' to activate green screen mode.", 10, true);
createPast("Type '!sleepTime x' to change sleep time to x seconds.", 10, true);
createPast("Type '!quit' to close the program", 10, true);
} else if (inputVal == "!greenScreen") {
document.querySelector('.content').classList.toggle("content-green-screen");
} else if (inputVal.includes("!sleepTime")) {
sleepTime = parseInt(inputVal.split(" ")[1]);
} else if (inputVal == "!window") {
document.querySelector('.content').classList.toggle("draggable");
} else if (inputVal == "!quit") {
window.electronAPI.quitApplication();
} else {
createPast(inputVal, sleepTime);
}
inputVal = "";
}
}
if (inputVal == "") {
document.querySelector('.balloon:last-child').classList = `balloon${blueMode ? " blue" : ""} hidden2`;
} else {
document.querySelector('.balloon:last-child').classList = `balloon${blueMode ? " blue" : ""}`;
}
document.querySelector('.balloon:last-child').innerHTML = inputVal.replaceAll(" ", " ") + `<span id="carrot${blueMode ? "-blue" : ""}"></span>`;
};
setTimeout(function() {
createPast("Welcome to ScreenTypr by YGZ!", 4.5);
createPast("Type '!help' to get help", 4.7);
createPast("Enjoy!", 4.9);
}, 500);