-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
234 lines (213 loc) · 8.94 KB
/
index.html
File metadata and controls
234 lines (213 loc) · 8.94 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Terminal</title>
<style>
body {
background-color: #1e1e1e;
color: #00ff00;
font-family: 'Courier New', monospace;
margin: 0;
padding: 0;
overflow: hidden;
}
#terminal {
width: 100%;
height: 100vh;
overflow: hidden;
display: flex;
flex-direction: column;
font-size: 16px;
padding: 10px;
box-sizing: border-box;
}
#output {
flex-grow: 1;
overflow-y: scroll;
padding: 10px;
}
#input-container {
display: flex;
}
#input {
flex-grow: 1;
border: none;
background-color: transparent;
color: #00ff00;
outline: none;
}
</style>
</head>
<body>
<div id="terminal">
<div id="output">guest@term.com:$ ~<br><br>
<pre>
$$$$$$$$\ $$\ $$\
\__$$ __| \__| $$ |
$$ | $$$$$$\ $$$$$$\ $$$$$$\$$$$\ $$\ $$$$$$$\ $$$$$$\ $$ |
$$ |$$ __$$\ $$ __$$\ $$ _$$ _$$\ $$ |$$ __$$\ \____$$\ $$ |
$$ |$$$$$$$$ |$$ | \__|$$ / $$ / $$ |$$ |$$ | $$ | $$$$$$$ |$$ |
$$ |$$ ____|$$ | $$ | $$ | $$ |$$ |$$ | $$ |$$ __$$ |$$ |
$$ |\$$$$$$$\ $$ | $$ | $$ | $$ |$$ |$$ | $$ |\$$$$$$$ |$$ |
\__| \_______|\__| \__| \__| \__|\__|\__| \__| \_______|\__|
Type 'help' to see list of available commands.
</pre>
</div>
<div id="input-container">
<span>$ </span>
<input id="input" type="text" autofocus>
</div>
</div>
<script>
const terminal = document.getElementById('terminal');
const output = document.getElementById('output');
const input = document.getElementById('input');
input.addEventListener('keydown', function (event) {
if (event.key === 'Enter') {
processCommand(input.value);
input.value = '';
}
});
async function processCommand(command) {
output.innerHTML += `<div>guest@term.com:$ ~ $ ${command}</div>`;
const response = await getCommandResponse(command);
if (response) {
output.innerHTML += `<div>${response}</div>`;
} else {
output.innerHTML += `<div>Command not found: ${command}</div>`;
}
terminal.scrollTop = terminal.scrollHeight;
}
async function getCommandResponse(command) {
switch (command.toLowerCase()) {
case 'help':
return 'Available commands: help, date, time, joke, calc, weather, dog, funnywebsite';
case 'date':
return new Date().toDateString();
case 'time':
return new Date().toTimeString();
case 'joke':
return await fetchJoke();
case 'calc':
return 'To use the calculator, enter an expression like "calc 2 + 2"';
case 'weather':
return 'To use the weather command, enter a location like "weather New York"';
case 'dog':
return await fetchDog();
case 'funnywebsite':
redirectToFunnyWebsite();
return 'Redirecting to a random funny website...';
default:
if (command.toLowerCase().startsWith('calc ')) {
return calculate(command.substring(5));
} else if (command.toLowerCase().startsWith('weather ')) {
const location = command.substring(8);
return await fetchWeather(location);
}
return null;
}
}
async function fetchJoke() {
try {
const response = await fetch('https://v2.jokeapi.dev/joke/Any');
const data = await response.json();
if (data.type === 'twopart') {
return `${data.setup} ${data.delivery}`;
} else {
return data.joke;
}
} catch (error) {
console.error('Error fetching joke:', error);
return 'Failed to fetch a joke. Please try again later.';
}
}
async function fetchWeather(location) {
try {
const apiKey = 'put api key here';
const response = await fetch(`https://api.openweathermap.org/data/2.5/weather?q=${location}&appid=${apiKey}`);
const data = await response.json();
if (data.cod === '404') {
return 'Location not found';
}
const temperature = Math.round(data.main.temp - 273.15); // Convert Kelvin to Celsius
const description = data.weather[0].description;
return `Weather in ${location}: ${temperature}°C, ${description}`;
} catch (error) {
console.error('Error fetching weather:', error);
return 'Failed to fetch weather information. Please try again later.';
}
}
async function fetchDog() {
try {
const response = await fetch('https://dog.ceo/api/breeds/image/random');
const data = await response.json();
return `<img src="${data.message}" alt="Random Dog">`;
} catch (error) {
console.error('Error fetching dog image:', error);
return 'Failed to fetch a random dog image. Please try again later.';
}
}
function calculate(expression) {
try {
return eval(expression);
} catch (error) {
return 'Error in calculation';
}
}
function redirectToFunnyWebsite() {
// Define a list of funny websites
const funnyWebsites = [
'https://111111111111111111111111111111111111111111111111111111111111.com/',
'https://zombo.com/',
'https://pointerpointer.com/',
'https://eelslap.com/',
'https://isitchristmas.com/',
'https://theuselessweb.site/ducksarethebest.com/',
'https://thatsthefinger.com/',
'https://weirdorconfusing.com/',
'https://www.somethingmorestore.com/',
'https://cant-not-tweet-this.com/',
'https://procatinator.com/',
'https://thequietplaceproject.xyz/thequietplace',
'https://cat-bounce.com/',
'https://z0r.de/',
'https://www.internetlivestats.com/',
'http://godhatesshrimp.com/',
'http://www.stealthboats.com/',
'http://www.staggeringbeauty.com/',
'https://wutdafuk.com/',
'https://wwwwwwwww.jodi.org/betalab/rain/digi3.html',
'http://endless.horse/',
'https://corgiorgy.com/',
'https://howsecureismypassword.net/',
'http://ninjaflex.com/',
'https://www.thisiswhyimbroke.com/',
'https://www.electricboogiewoogie.com/',
'http://corndog.io/',
'https://www.fallingfalling.com/',
'https://anasomnia.com/',
'https://burymewithmymoney.com/',
'https://papertoilet.com/',
'https://theuselessweb.com/',
'https://trypap.com/',
'https://quickdraw.withgoogle.com/',
'http://www.essaytyper.com/',
'https://hooooooooo.com/',
'https://www.hasthelargehadroncolliderdestroyedtheworldyet.com/',
'http://www.everydayim.com/',
'https://www.omfgdogs.com/',
'http://randomcolour.com/',
'https://crossdivisions.com/',
'http://www.patience-is-a-virtue.org/',
'https://www.sometimesredsometimesblue.com/',
'https://hackertyper.com/',
];
// Redirect to a random funny website
const randomIndex = Math.floor(Math.random() * funnyWebsites.length);
window.location.href = funnyWebsites[randomIndex];
}
</script>
</body>
</html>