-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.js
132 lines (119 loc) · 3.92 KB
/
main.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
let myDemoTerminal;
function schoolPride() {
var end = Date.now() + 2 * 1000;
// go Buckeyes!
var colors = ['#bb0000', '#ffffff'];
(function frame() {
confetti({
particleCount: 2,
angle: 60,
spread: 55,
origin: { x: 0 },
colors: colors,
});
confetti({
particleCount: 2,
angle: 120,
spread: 55,
origin: { x: 1 },
colors: colors,
});
if (Date.now() < end) {
requestAnimationFrame(frame);
}
})();
}
function fireWorks() {
var duration = 2 * 1000;
var animationEnd = Date.now() + duration;
var defaults = { startVelocity: 30, spread: 360, ticks: 60, zIndex: 0 };
function randomInRange(min, max) {
return Math.random() * (max - min) + min;
}
var interval = setInterval(function () {
var timeLeft = animationEnd - Date.now();
if (timeLeft <= 0) {
return clearInterval(interval);
}
var particleCount = 50 * (timeLeft / duration);
// since particles fall down, start a bit higher than random
confetti({ ...defaults, particleCount, origin: { x: randomInRange(0.1, 0.3), y: Math.random() - 0.2 } });
confetti({ ...defaults, particleCount, origin: { x: randomInRange(0.7, 0.9), y: Math.random() - 0.2 } });
}, 250);
}
$(document).ready(function () {
// let myDemoTerminal2;
let commands = [
{
command: 'hello',
description: 'Says hello',
action: async (terminal, args) => terminal.write('\r\nHello! ' + args.join(' ')),
},
{
command: 'theme',
description: 'Change the website theme',
subCommands: [
{
command: 'set',
description: 'Set the website theme to light or dark',
action: async (terminal, args) => {
let theme = args[0];
if (theme === 'light') {
document.body.setAttribute('data-bs-theme', 'light');
myDemoTerminal.setTheme('light');
} else {
document.body.setAttribute('data-bs-theme', 'dark');
myDemoTerminal.setTheme('dark');
}
terminal.write('\r\nsetting theme to ' + args[0]);
},
},
{
command: 'list',
description: 'List all available themes',
action: async (terminal, args) => {
let list = ['light', 'dark'];
list.forEach((theme) => {
terminal.write('\r\n' + theme);
});
},
},
],
},
{
command: 'poppers',
description: 'Poppers/School Pride animation',
action: async (terminal, args) => {
schoolPride();
terminal.write('\r\nGo Buckeyes!');
},
},
{
command: 'fireworks',
description: 'Fireworks animation',
action: async (terminal, args) => {
fireWorks();
terminal.write('\r\nFireworks!');
},
},
];
myDemoTerminal = new termo({
commands: commands,
title: 'bterm v1.0.02',
fontFamily: 'Sono',
theme: 'dark',
prompt: 'bterm@localhost:$',
});
myDemoTerminal.create();
$('#fireup').click(function (e) {
myDemoTerminal.show();
});
// if c is pressed, hide the terminal
$(document).keypress(function (e) {
if (e.which === 99) {
e.preventDefault();
myDemoTerminal.show();
}
});
hljs.highlightAll();
});