-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
437 lines (383 loc) · 15.2 KB
/
script.js
File metadata and controls
437 lines (383 loc) · 15.2 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
let hasUserInteracted = false;
function initMedia() {
console.log("initMedia called");
const backgroundMusic = document.getElementById('background-music');
backgroundMusic.src = `assets/background_music${Math.floor(Math.random() * 3)}.mp3`;
if (!backgroundMusic) {
console.error("Media elements not found");
return;
}
backgroundMusic.volume = 0.3;
}
document.addEventListener('DOMContentLoaded', () => {
const startScreen = document.getElementById('start-screen');
const startText = document.getElementById('start-text');
const profileName = document.getElementById('profile-name');
const profileBio = document.getElementById('profile-bio');
const visitorCount = document.getElementById('visitor-count');
const backgroundMusic = document.getElementById('background-music');
const resultsButton = document.getElementById('results-theme');
const volumeIcon = document.getElementById('volume-icon');
const volumeSlider = document.getElementById('volume-slider');
const glitchOverlay = document.querySelector('.glitch-overlay');
const profileBlock = document.getElementById('profile-block');
const skillsBlock = document.getElementById('skills-block');
const pythonBar = document.getElementById('python-bar');
const javaBar = document.getElementById('java-bar');
const cssBar = document.getElementById('css3-bar');
const htmlBar = document.getElementById('html5-bar');
const javascriptBar = document.getElementById('javascript-bar');
const nodejsBar = document.getElementById('nodejs-bar');
const typescriptBar = document.getElementById('typescript-bar');
const csharpBar = document.getElementById('csharp-bar');
const resultsHint = document.getElementById('results-hint');
const profilePicture = document.querySelector('.profile-picture');
const profileContainer = document.querySelector('.profile-container');
const startMessages = ["click to view", "click to stalk", "click just because", "click to come inside", "click to visualize", "click to unlock", "click to feast", "click to open the door", "click to gently open the door", "click to sprint", "click to jump", "click to say apple"];
const startMessage = startMessages[Math.floor(Math.random() * startMessages.length)];
let startTextContent = '';
let startIndex = 0;
let startCursorVisible = true;
function typeWriterStart() {
if (startIndex < startMessage.length) {
startTextContent = startMessage.slice(0, startIndex + 1);
startIndex++;
}
startText.textContent = startTextContent + (startCursorVisible ? '|' : ' ');
setTimeout(typeWriterStart, 100);
}
setInterval(() => {
startCursorVisible = !startCursorVisible;
startText.textContent = startTextContent + (startCursorVisible ? '|' : ' ');
}, 500);
function initializeVisitorCounter() {
totalVisitors = Math.floor(Math.random() * 900000) + 100000;
visitorCount.textContent = totalVisitors.toLocaleString();
}
initializeVisitorCounter();
setInterval(initializeVisitorCounter, 10);
startScreen.addEventListener('click', () => {
startScreen.classList.add('hidden');
backgroundMusic.muted = false;
backgroundMusic.play().catch(err => {
console.error("Failed to play music after start screen click:", err);
});
profileBlock.classList.remove('hidden');
gsap.fromTo(profileBlock,
{ opacity: 0, y: -50 },
{ opacity: 1, y: 0, duration: 1, ease: 'power2.out', onComplete: () => {
profileBlock.classList.add('profile-appear');
profileContainer.classList.add('orbit');
}}
);
typeWriterName();
typeWriterBio();
});
startScreen.addEventListener('touchstart', (e) => {
e.preventDefault();
startScreen.classList.add('hidden');
backgroundMusic.muted = false;
backgroundMusic.play().catch(err => {
console.error("Failed to play music after start screen touch:", err);
});
profileBlock.classList.remove('hidden');
gsap.fromTo(profileBlock,
{ opacity: 0, y: -50 },
{ opacity: 1, y: 0, duration: 1, ease: 'power2.out', onComplete: () => {
profileBlock.classList.add('profile-appear');
profileContainer.classList.add('orbit');
}}
);
typeWriterName();
typeWriterBio();
});
const names = [
"Playfull_Dev",
"Digital PXL",
"DP_Playfull",
"DP_Playfull_Dev",
"jake"
];
let name = names[Math.floor(Math.random() * names.length)];
let nameText = '';
let nameIndex = 0;
let isNameDeleting = false;
let nameCursorVisible = true;
function typeWriterName() {
if (!isNameDeleting && nameIndex < name.length) {
nameText = name.slice(0, nameIndex + 1);
nameIndex++;
} else if (isNameDeleting && nameIndex > 0) {
nameText = name.slice(0, nameIndex - 1);
nameIndex--;
} else if (nameIndex === name.length) {
isNameDeleting = true;
setTimeout(typeWriterName, 2000);
return;
} else if (nameIndex === 0) {
isNameDeleting = false;
name = names[Math.floor(Math.random() * names.length)];
}
profileName.textContent = nameText + (nameCursorVisible ? '|' : ' ');
if (Math.random() < 0.1) {
profileName.classList.add('glitch');
setTimeout(() => profileName.classList.remove('glitch'), 200);
}
setTimeout(typeWriterName, isNameDeleting ? 50 : Math.floor(Math.random() * 101) + 30);
}
setInterval(() => {
nameCursorVisible = !nameCursorVisible;
profileName.textContent = nameText + (nameCursorVisible ? '|' : ' ');
}, 500);
const bioMessages = [
"creature on the internet",
"i don't have a brother",
"creator of some stupid stuff",
"owner of Digital PXL",
"403 forbidden",
"never underestimate yourself",
"owner of Fairmont Studio",
"mechanical keyboards",
"contacting the mothership",
"i hate scripts",
"admin@digitalpxl.org",
"hi there"
];
let bioText = '';
let bioIndex = 0;
let bioMessageIndex = Math.floor(Math.random() * bioMessages.length);
let isBioDeleting = false;
let bioCursorVisible = true;
function typeWriterBio() {
if (!isBioDeleting && bioIndex < bioMessages[bioMessageIndex].length) {
bioText = bioMessages[bioMessageIndex].slice(0, bioIndex + 1);
bioIndex++;
} else if (isBioDeleting && bioIndex > 0) {
bioText = bioMessages[bioMessageIndex].slice(0, bioIndex - 1);
bioIndex--;
} else if (bioIndex === bioMessages[bioMessageIndex].length) {
isBioDeleting = true;
setTimeout(typeWriterBio, 2000);
return;
} else if (bioIndex === 0 && isBioDeleting) {
isBioDeleting = false;
bioMessageIndex = Math.floor(Math.random() * bioMessages.length);
}
profileBio.textContent = bioText + (bioCursorVisible ? '|' : ' ');
if (Math.random() < 0.1) {
profileBio.classList.add('glitch');
setTimeout(() => profileBio.classList.remove('glitch'), 200);
}
setTimeout(typeWriterBio, isNameDeleting ? 20 : Math.floor(Math.random() * 101) + 30);
}
setInterval(() => {
bioCursorVisible = !bioCursorVisible;
profileBio.textContent = bioText + (bioCursorVisible ? '|' : ' ');
}, 500);
let currentAudio = backgroundMusic;
let isMuted = false;
volumeIcon.addEventListener('click', () => {
isMuted = !isMuted;
currentAudio.muted = isMuted;
volumeIcon.innerHTML = isMuted
? `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"></path>`
: `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"></path>`;
});
volumeIcon.addEventListener('touchstart', (e) => {
e.preventDefault();
isMuted = !isMuted;
currentAudio.muted = isMuted;
volumeIcon.innerHTML = isMuted
? `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"></path><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2"></path>`
: `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"></path>`;
});
volumeSlider.addEventListener('input', () => {
currentAudio.volume = volumeSlider.value;
isMuted = false;
currentAudio.muted = false;
volumeIcon.innerHTML = `<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.536 8.464a5 5 0 010 7.072m2.828-9.9a9 9 0 010 12.728M5.586 15H4a1 1 0 01-1-1v-4a1 1 0 011-1h1.586l4.707-4.707C10.923 3.663 12 4.109 12 5v14c0 .891-1.077 1.337-1.707.707L5.586 15z"></path>`;
});
function handleTilt(e, element) {
const rect = element.getBoundingClientRect();
const centerX = rect.left + rect.width / 2;
const centerY = rect.top + rect.height / 2;
let clientX, clientY;
if (e.type === 'touchmove') {
clientX = e.touches[0].clientX;
clientY = e.touches[0].clientY;
} else {
clientX = e.clientX;
clientY = e.clientY;
}
const mouseX = clientX - centerX;
const mouseY = clientY - centerY;
const maxTilt = 15;
const tiltX = (mouseY / rect.height) * maxTilt;
const tiltY = -(mouseX / rect.width) * maxTilt;
gsap.to(element, {
rotationX: tiltX,
rotationY: tiltY,
duration: 0.3,
ease: 'power2.out',
transformPerspective: 1000
});
}
profileBlock.addEventListener('mousemove', (e) => handleTilt(e, profileBlock));
profileBlock.addEventListener('touchmove', (e) => {
e.preventDefault();
handleTilt(e, profileBlock);
});
skillsBlock.addEventListener('mousemove', (e) => handleTilt(e, skillsBlock));
skillsBlock.addEventListener('touchmove', (e) => {
e.preventDefault();
handleTilt(e, skillsBlock);
});
profileBlock.addEventListener('mouseleave', () => {
gsap.to(profileBlock, {
rotationX: 0,
rotationY: 0,
duration: 0.5,
ease: 'power2.out'
});
});
profileBlock.addEventListener('touchend', () => {
gsap.to(profileBlock, {
rotationX: 0,
rotationY: 0,
duration: 0.5,
ease: 'power2.out'
});
});
skillsBlock.addEventListener('mouseleave', () => {
gsap.to(skillsBlock, {
rotationX: 0,
rotationY: 0,
duration: 0.5,
ease: 'power2.out'
});
});
skillsBlock.addEventListener('touchend', () => {
gsap.to(skillsBlock, {
rotationX: 0,
rotationY: 0,
duration: 0.5,
ease: 'power2.out'
});
});
profilePicture.addEventListener('click', () => {
profileContainer.classList.remove('fast-orbit');
profileContainer.classList.remove('orbit');
void profileContainer.offsetWidth;
profileContainer.classList.add('fast-orbit');
setTimeout(() => {
profileContainer.classList.remove('fast-orbit');
void profileContainer.offsetWidth;
profileContainer.classList.add('orbit');
}, 500);
});
profilePicture.addEventListener('touchstart', (e) => {
e.preventDefault();
profileContainer.classList.remove('fast-orbit');
profileContainer.classList.remove('orbit');
void profileContainer.offsetWidth;
profileContainer.classList.add('fast-orbit');
setTimeout(() => {
profileContainer.classList.remove('fast-orbit');
void profileContainer.offsetWidth;
profileContainer.classList.add('orbit');
}, 500);
});
let isShowingSkills = false;
resultsButton.addEventListener('click', () => {
if (!isShowingSkills) {
gsap.to(profileBlock, {
x: -100,
opacity: 0,
duration: 0.5,
ease: 'power2.in',
onComplete: () => {
profileBlock.classList.add('hidden');
skillsBlock.classList.remove('hidden');
gsap.fromTo(skillsBlock,
{ x: 100, opacity: 0 },
{ x: 0, opacity: 1, duration: 0.5, ease: 'power2.out' }
);
gsap.to(pythonBar, { width: '95%', duration: 2, ease: 'power2.out' });
gsap.to(javaBar, { width: '35%', duration: 2, ease: 'power2.out' });
gsap.to(cssBar, { width: '70%', duration: 2, ease: 'power2.out' });
gsap.to(htmlBar, { width: '65%', duration: 2, ease: 'power2.out' });
gsap.to(javascriptBar, { width: '75%', duration: 2, ease: 'power2.out' });
gsap.to(nodejsBar, { width: '70%', duration: 2, ease: 'power2.out' });
gsap.to(typescriptBar, { width: '75%', duration: 2, ease: 'power2.out' });
gsap.to(csharpBar, { width: '100%', duration: 2, ease: 'power2.out' });
}
});
resultsHint.classList.remove('hidden');
isShowingSkills = true;
} else {
gsap.to(skillsBlock, {
x: 100,
opacity: 0,
duration: 0.5,
ease: 'power2.in',
onComplete: () => {
skillsBlock.classList.add('hidden');
profileBlock.classList.remove('hidden');
gsap.fromTo(profileBlock,
{ x: -100, opacity: 0 },
{ x: 0, opacity: 1, duration: 0.5, ease: 'power2.out' }
);
}
});
resultsHint.classList.add('hidden');
isShowingSkills = false;
}
});
resultsButton.addEventListener('touchstart', (e) => {
e.preventDefault();
if (!isShowingSkills) {
gsap.to(profileBlock, {
x: -100,
opacity: 0,
duration: 0.5,
ease: 'power2.in',
onComplete: () => {
profileBlock.classList.add('hidden');
skillsBlock.classList.remove('hidden');
gsap.fromTo(skillsBlock,
{ x: 100, opacity: 0 },
{ x: 0, opacity: 1, duration: 0.5, ease: 'power2.out' }
);
gsap.to(pythonBar, { width: '95%', duration: 2, ease: 'power2.out' });
gsap.to(javaBar, { width: '35%', duration: 2, ease: 'power2.out' });
gsap.to(cssBar, { width: '70%', duration: 2, ease: 'power2.out' });
gsap.to(htmlBar, { width: '65%', duration: 2, ease: 'power2.out' });
gsap.to(javascriptBar, { width: '75%', duration: 2, ease: 'power2.out' });
gsap.to(nodejsBar, { width: '70%', duration: 2, ease: 'power2.out' });
gsap.to(typescriptBar, { width: '75%', duration: 2, ease: 'power2.out' });
gsap.to(csharpBar, { width: '100%', duration: 2, ease: 'power2.out' });
}
});
resultsHint.classList.remove('hidden');
isShowingSkills = true;
} else {
gsap.to(skillsBlock, {
x: 100,
opacity: 0,
duration: 0.5,
ease: 'power2.in',
onComplete: () => {
skillsBlock.classList.add('hidden');
profileBlock.classList.remove('hidden');
gsap.fromTo(profileBlock,
{ x: -100, opacity: 0 },
{ x: 0, opacity: 1, duration: 0.5, ease: 'power2.out' }
);
}
});
resultsHint.classList.add('hidden');
isShowingSkills = false;
}
});
typeWriterStart();
});