-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
231 lines (200 loc) · 8.51 KB
/
Copy pathscript.js
File metadata and controls
231 lines (200 loc) · 8.51 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
// Restart sequence for the interactive feature
const restartCode = ['r', 'e', 's', 't', 'a', 'r', 't'];
// Track user's position in the restart sequence
let restartCodePosition = 0;
// Initialize the typed animation for the strike-through text
document.addEventListener('DOMContentLoaded', function() {
// Only initialize if Typed.js is loaded and user doesn't prefer reduced motion
if (typeof Typed !== 'undefined' && !window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
const typed = new Typed('#strike', {
strings: [
'restart',
'reboot',
'shutdown',
'power cycle',
'turn off and on',
'reset',
'power down'
],
typeSpeed: 80,
backSpeed: 60,
smartBackspace: false,
loop: true,
shuffle: false,
backDelay: 2000,
startDelay: 3000,
});
// Force the start of cursor animation while the startDelay is ticking
if (typed.cursor != null) {
typed.cursor.classList.add('typed-cursor--blink');
}
}
// Set up focus management for any internal links
const links = document.querySelectorAll('a[href^="#"]');
for (const link of links) {
link.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({ behavior: 'smooth' });
target.focus();
}
});
}
});
// Easter egg: typing "restart" activates a special animation
function activateRestartMode() {
// Change the background to a computer restart screen effect
document.body.style.backgroundImage = 'linear-gradient(45deg, #000 25%, transparent 25%), linear-gradient(-45deg, #000 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #000 75%), linear-gradient(-45deg, transparent 75%, #000 75%)';
document.body.style.backgroundSize = '20px 20px';
document.body.style.backgroundColor = '#111';
document.body.style.backgroundPosition = '0 0, 0 10px, 10px -10px, -10px 0px';
const elements = [
document.getElementById('wholesite'),
...document.getElementsByTagName('p'),
...document.getElementsByTagName('ul'),
...document.getElementsByTagName('h1'),
...document.getElementsByTagName('h2'),
];
for (const ele of elements) {
if (ele != null) {
ele.style.cssText = 'color: #00ff00 !important; text-shadow: 0 0 10px #00ff00;';
}
}
// Style the typing text to match the green theme
const strikeElement = document.getElementById('strike');
if (strikeElement) {
strikeElement.style.cssText = 'color: #00ff00 !important; text-shadow: 0 0 10px #00ff00;';
}
// Style the footer
document.getElementsByTagName('footer')[0].style.cssText =
'background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.9) 45%) !important; color: #00ff00 !important;';
// Style the example cards with a retro computer look
const cards = document.getElementsByClassName('example');
for (const card of cards) {
card.style.cssText =
'background: #000 !important; border: 2px solid #00ff00 !important; box-shadow: 0 0 20px #00ff00 !important;';
}
// Style the subtitle
const subtitle = document.getElementsByClassName('subtitle')[0];
if (subtitle) {
subtitle.style.cssText = 'color: #00ff00 !important; opacity: 80%;';
}
// Style the important notice to fit the theme
const notice = document.getElementsByClassName('important-notice')[0];
if (notice) {
notice.style.cssText = 'background: #000 !important; border: 2px solid #00ff00 !important; color: #00ff00 !important; box-shadow: 0 0 20px #00ff00 !important;';
}
// Style the notice card container
const noticeCard = document.getElementsByClassName('important-notice-card')[0];
if (noticeCard) {
noticeCard.style.cssText = 'background: #000 !important; box-shadow: 0 0 30px #00ff00 !important;';
}
// Style the notice title
const noticeTitle = document.getElementsByClassName('notice-title')[0];
if (noticeTitle) {
noticeTitle.style.cssText = 'color: #00ff00 !important;';
}
}
// Add keydown event listener for the easter egg
document.addEventListener('keydown', (e) => {
// Get the value of the required key from the restart code
const requiredKey = restartCode[restartCodePosition];
// Compare the key with the required key
if (e.key.toLowerCase() === requiredKey) {
// Move to the next key in the sequence
restartCodePosition += 1;
// If the last key is reached, activate restart mode
if (restartCodePosition === restartCode.length) {
activateRestartMode();
restartCodePosition = 0;
} else if (restartCodePosition === 3) {
// Preload any restart animation at 3rd character
const preload = document.getElementById('preloadimg');
if (preload != null) {
preload.classList.add('now');
}
}
} else {
// Reset the position if wrong key is pressed
restartCodePosition = 0;
}
});
// Add smooth scrolling for better UX (respecting motion preferences)
document.addEventListener('DOMContentLoaded', function() {
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
// Smooth scroll for any internal links
const links = document.querySelectorAll('a[href^="#"]');
for (const link of links) {
link.addEventListener('click', function(e) {
e.preventDefault();
const target = document.querySelector(this.getAttribute('href'));
if (target) {
target.scrollIntoView({
behavior: prefersReducedMotion ? 'auto' : 'smooth'
});
// Set focus for accessibility
target.focus();
}
});
}
});
// Add a subtle animation to system messages when they come into view (respecting motion preferences)
document.addEventListener('DOMContentLoaded', function() {
const prefersReducedMotion = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (prefersReducedMotion) {
// For users who prefer reduced motion, just make elements visible immediately
const systemMessages = document.querySelectorAll('.system-message');
systemMessages.forEach(function(message) {
message.style.opacity = '1';
});
return;
}
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver(function(entries) {
entries.forEach(function(entry) {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
}, observerOptions);
// Observe all system messages
const systemMessages = document.querySelectorAll('.system-message');
systemMessages.forEach(function(message) {
message.style.opacity = '0';
message.style.transform = 'translateY(20px)';
message.style.transition = 'opacity 0.6s ease, transform 0.6s ease';
observer.observe(message);
});
});
// Add a fun counter that shows how long it's been since the page "restarted" (loaded)
document.addEventListener('DOMContentLoaded', function() {
const startTime = Date.now();
function updateUptime() {
const now = Date.now();
const uptime = now - startTime;
const seconds = Math.floor(uptime / 1000);
const minutes = Math.floor(seconds / 60);
const hours = Math.floor(minutes / 60);
let uptimeText;
if (hours > 0) {
uptimeText = `${hours}h ${minutes % 60}m ${seconds % 60}s`;
} else if (minutes > 0) {
uptimeText = `${minutes}m ${seconds % 60}s`;
} else {
uptimeText = `${seconds}s`;
}
// Update any uptime display elements if they exist
const uptimeElements = document.querySelectorAll('.uptime');
uptimeElements.forEach(function(element) {
element.textContent = uptimeText;
});
}
// Update every second
setInterval(updateUptime, 1000);
updateUptime();
});