-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
420 lines (366 loc) · 16 KB
/
Copy pathscript.js
File metadata and controls
420 lines (366 loc) · 16 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
document.addEventListener("DOMContentLoaded", () => {
// === WEB3 PHYSICAL ELEMENTS ===
function createBlockchainNodes() {
const container = document.body;
for (let i = 0; i < 12; i++) {
const node = document.createElement("div");
node.className = "blockchain-node";
node.style.left = Math.random() * 100 + "%";
node.style.top = Math.random() * 100 + "%";
node.style.animationDelay = Math.random() * 6 + "s";
node.style.animationDuration = 4 + Math.random() * 3 + "s";
container.appendChild(node);
}
}
function createFloatingSymbols() {
const symbols = ["◆", "⬡", "◇"];
const container = document.body;
for (let i = 0; i < 8; i++) {
const symbol = document.createElement("div");
symbol.className = "floating-symbol";
symbol.textContent = symbols[Math.floor(Math.random() * symbols.length)];
symbol.style.left = Math.random() * 100 + "%";
symbol.style.top = Math.random() * 100 + "%";
symbol.style.animationDelay = Math.random() * 8 + "s";
symbol.style.color = Math.random() > 0.5 ? "#627eea" : "#00f5ff";
container.appendChild(symbol);
}
}
function createHexagonGrid() {
const grid = document.getElementById("hexagon-grid");
const hexSize = 60;
for (let x = 0; x < window.innerWidth; x += hexSize) {
for (let y = 0; y < window.innerHeight; y += hexSize) {
const hex = document.createElement("div");
hex.className = "hexagon";
hex.style.width = hexSize + "px";
hex.style.height = hexSize + "px";
hex.style.left = x + "px";
hex.style.top = y + "px";
hex.style.animationDelay = Math.random() * 4 + "s";
grid.appendChild(hex);
}
}
}
function createParticles() {
const container = document.body;
setInterval(() => {
if (Math.random() > 0.7) {
const particle = document.createElement("div");
particle.className = "particle";
particle.style.left = Math.random() * window.innerWidth + "px";
particle.style.bottom = "-10px";
particle.style.setProperty("--tx", (Math.random() - 0.5) * 200 + "px");
particle.style.animationDuration = 5 + Math.random() * 5 + "s";
container.appendChild(particle);
setTimeout(() => particle.remove(), 10000);
}
}, 200);
}
function createConnectingLines() {
const svg = document.querySelector("svg");
setInterval(() => {
if (Math.random() > 0.8) {
const x1 = Math.random() * window.innerWidth;
const y1 = Math.random() * window.innerHeight;
const x2 = x1 + (Math.random() - 0.5) * 300;
const y2 = y1 + (Math.random() - 0.5) * 300;
const line = document.createElementNS("http://www.w3.org/2000/svg", "line");
line.setAttribute("x1", x1);
line.setAttribute("y1", y1);
line.setAttribute("x2", x2);
line.setAttribute("y2", y2);
line.setAttribute("class", "tech-line");
svg.appendChild(line);
setTimeout(() => line.remove(), 4000);
}
}, 300);
}
createBlockchainNodes();
createFloatingSymbols();
createHexagonGrid();
createParticles();
createConnectingLines();
const resumeModal = document.getElementById("resume-modal");
const resumeConfirmBtn = document.getElementById("resume-confirm-btn");
const resumeCancelBtn = document.getElementById("resume-cancel-btn");
const resumeDownloadBtn = document.getElementById("resume-download-btn");
const funnyMessages = [
"> Initializing resume download sequence...<br>> Are you SURE you want to see how awesome I am?<br>> This might change your hiring decisions! 😎",
"> WARNING: Resume contains extreme awesomeness!<br>> Side effects may include: Instant Hiring<br>> Proceed at your own risk! ⚡",
"> ALERT: You are about to download excellence!<br>> This file is too powerful for average recruiters<br>> Are you ready? 🚀",
"> Resume.pdf is loading...<br>> Calibrating awesome-o-meter...<br>> Buckle up! 🎯"
];
function openResumeModal() {
resumeModal.classList.add("active");
const randomMsg = funnyMessages[Math.floor(Math.random() * funnyMessages.length)];
document.getElementById("resume-message").innerHTML = randomMsg;
}
function closeResumeModal() {
resumeModal.classList.remove("active");
}
function downloadResume() {
closeResumeModal();
const link = document.createElement("a");
link.href = "resume.pdf";
link.download = "Apurve_Karanwal_Resume.pdf";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
resumeDownloadBtn.addEventListener("click", (e) => {
e.preventDefault();
openResumeModal();
});
resumeConfirmBtn.addEventListener("click", downloadResume);
resumeCancelBtn.addEventListener("click", closeResumeModal);
resumeModal.addEventListener("click", (e) => {
if (e.target === resumeModal) {
closeResumeModal();
}
});
const textToType =
"> **[STATUS: ONLINE]** Backend & DevOps-Focused Engineer. Building reliable APIs, job systems, and production-minded software.";
const typeWriterElement = document.getElementById("hero-typewriter");
function startTypewriter() {
if (typeWriterElement) {
typeWriterElement.textContent = "";
let i = 0;
function typeWriter() {
if (i < textToType.length) {
typeWriterElement.textContent += textToType.charAt(i);
i++;
setTimeout(typeWriter, 35);
}
}
typeWriter();
}
}
const preloader = document.getElementById("preloader");
const progressBar = document.getElementById("progress-bar");
const loaderText = document.getElementById("loader-text");
const loaderSubtext = document.getElementById("loader-subtext");
let width = 0;
const interval = setInterval(() => {
width += Math.floor(Math.random() * 5) + 1;
if (width > 30 && width < 50) {
loaderSubtext.innerText = "> LOADING_ASSETS...";
}
if (width > 50 && width < 80) {
loaderSubtext.innerText = "> ESTABLISHING_LINK...";
}
if (width > 80) {
loaderSubtext.innerText = "> DECODING_DATA...";
}
if (width >= 100) {
width = 100;
clearInterval(interval);
loaderText.innerText = "ACCESS GRANTED";
loaderSubtext.innerText = "> WELCOME_USER";
progressBar.style.backgroundColor = "var(--color-accent-secondary)";
setTimeout(() => {
preloader.classList.add("fade-out");
document.body.style.overflow = "";
setTimeout(startTypewriter, 500);
}, 800);
}
progressBar.style.width = width + "%";
}, 30);
function updateClock() {
const now = new Date();
const timeElement = document.getElementById("live-time");
const dateElement = document.getElementById("live-date");
if (timeElement) {
timeElement.textContent = now.toLocaleTimeString("en-US", {
hour12: false,
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
});
}
if (dateElement) {
dateElement.textContent = now.toLocaleDateString("en-US", {
year: "numeric",
month: "short",
day: "2-digit"
});
}
}
updateClock();
setInterval(updateClock, 1000);
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("fade-in");
entry.target.style.opacity = 1;
observer.unobserve(entry.target);
}
});
},
{
threshold: 0.1
}
);
document.querySelectorAll(".animated-section").forEach((section) => {
observer.observe(section);
});
});
document.addEventListener("DOMContentLoaded", () => {
// Custom Cursor - Instant 1:1 Response & Smooth Hardware-Accelerated Trail
const customCursor = document.getElementById("custom-cursor");
const cursorTrail = document.getElementById("cursor-trail");
if (customCursor && cursorTrail) {
let mouseX = window.innerWidth / 2;
let mouseY = window.innerHeight / 2;
let trailX = mouseX, trailY = mouseY;
document.addEventListener("mousemove", (e) => {
mouseX = e.clientX;
mouseY = e.clientY;
// Instant 1:1 lockstep position for main dot (0ms input lag)
customCursor.style.transform = `translate3d(${mouseX - 4}px, ${mouseY - 4}px, 0)`;
}, { passive: true });
function updateCursorTrail() {
// High-precision smooth trail lerp (0.45 for rapid response)
trailX += (mouseX - trailX) * 0.45;
trailY += (mouseY - trailY) * 0.45;
cursorTrail.style.transform = `translate3d(${trailX - 16}px, ${trailY - 16}px, 0)`;
requestAnimationFrame(updateCursorTrail);
}
requestAnimationFrame(updateCursorTrail);
// High-performance event delegation for hover states
document.body.addEventListener("mouseover", (e) => {
if (e.target.closest("a, button, input, textarea, select, .project-card, .pixel-btn-3d, .pixel-block-3d")) {
document.body.classList.add("cursor-hover");
}
}, { passive: true });
document.body.addEventListener("mouseout", (e) => {
if (e.target.closest("a, button, input, textarea, select, .project-card, .pixel-btn-3d, .pixel-block-3d")) {
document.body.classList.remove("cursor-hover");
}
}, { passive: true });
}
// --- PHASE 3: ULTIMATE INTERACTIVE FEATURES ---
// 1. Spiderweb Canvas
const swCanvas = document.getElementById("spiderweb-canvas");
if (swCanvas) {
const sctx = swCanvas.getContext("2d");
let particles = [];
const numParticles = 60;
const connectionDistance = 120;
const mouseConnectionDistance = 180;
function resizeSw() {
swCanvas.width = window.innerWidth;
swCanvas.height = window.innerHeight;
}
window.addEventListener("resize", resizeSw);
resizeSw();
class Particle {
constructor() {
this.x = Math.random() * swCanvas.width;
this.y = Math.random() * swCanvas.height;
this.vx = (Math.random() - 0.5) * 1.5;
this.vy = (Math.random() - 0.5) * 1.5;
}
update() {
this.x += this.vx;
this.y += this.vy;
if (this.x < 0 || this.x > swCanvas.width) this.vx *= -1;
if (this.y < 0 || this.y > swCanvas.height) this.vy *= -1;
}
draw() {
sctx.beginPath();
sctx.arc(this.x, this.y, 1.5, 0, Math.PI * 2);
sctx.fillStyle = "rgba(0, 245, 255, 0.5)";
sctx.fill();
}
}
for (let i = 0; i < numParticles; i++) particles.push(new Particle());
function drawSpiderweb() {
sctx.clearRect(0, 0, swCanvas.width, swCanvas.height);
for (let i = 0; i < particles.length; i++) {
particles[i].update();
particles[i].draw();
// Check mouse
const dxm = mouseX - particles[i].x;
const dym = mouseY - particles[i].y;
const distm = Math.sqrt(dxm*dxm + dym*dym);
if (distm < mouseConnectionDistance) {
sctx.beginPath();
sctx.moveTo(particles[i].x, particles[i].y);
sctx.lineTo(mouseX, mouseY);
sctx.strokeStyle = `rgba(252, 211, 77, ${1 - distm/mouseConnectionDistance})`;
sctx.lineWidth = 1.5;
sctx.stroke();
}
// Check other particles
for (let j = i + 1; j < particles.length; j++) {
const dx = particles[i].x - particles[j].x;
const dy = particles[i].y - particles[j].y;
const dist = Math.sqrt(dx*dx + dy*dy);
if (dist < connectionDistance) {
sctx.beginPath();
sctx.moveTo(particles[i].x, particles[i].y);
sctx.lineTo(particles[j].x, particles[j].y);
sctx.strokeStyle = `rgba(0, 245, 255, ${0.4 * (1 - dist/connectionDistance)})`;
sctx.lineWidth = 0.5;
sctx.stroke();
}
}
}
requestAnimationFrame(drawSpiderweb);
}
drawSpiderweb();
}
// 1. Cyber Skull Centerpiece
const skull = document.getElementById("cyber-skull");
if (skull) {
let skullRotX = 0;
let skullRotY = 0;
document.addEventListener('mousemove', (event) => {
const x = (event.clientX / window.innerWidth - 0.5) * 2;
const y = (event.clientY / window.innerHeight - 0.5) * 2;
skullRotX = -y * 25;
skullRotY = x * 25;
});
function animateSkull() {
requestAnimationFrame(animateSkull);
skull.style.transform = `rotateX(${skullRotX}deg) rotateY(${skullRotY}deg)`;
}
animateSkull();
}
// Fetch Live GitHub Telemetry Metrics
async function fetchLiveGitHubStats() {
const reposEl = document.getElementById("gh-stat-repos");
const mergedPrsEl = document.getElementById("gh-stat-merged-prs");
const openPrsEl = document.getElementById("gh-stat-open-prs");
const openIssuesEl = document.getElementById("gh-stat-open-issues");
try {
const [userRes, mergedRes, openPrRes, openIssueRes] = await Promise.all([
fetch("https://api.github.com/users/ApurveKaranwal"),
fetch("https://api.github.com/search/issues?q=author:ApurveKaranwal+type:pr+is:merged"),
fetch("https://api.github.com/search/issues?q=author:ApurveKaranwal+type:pr+is:open"),
fetch("https://api.github.com/search/issues?q=author:ApurveKaranwal+type:issue+is:open")
]);
if (userRes.ok) {
const userData = await userRes.json();
if (reposEl && userData.public_repos !== undefined) reposEl.textContent = userData.public_repos;
}
if (mergedRes.ok) {
const mergedData = await mergedRes.json();
if (mergedPrsEl && mergedData.total_count !== undefined) mergedPrsEl.textContent = mergedData.total_count;
}
if (openPrRes.ok) {
const openPrData = await openPrRes.json();
if (openPrsEl && openPrData.total_count !== undefined) openPrsEl.textContent = openPrData.total_count;
}
if (openIssueRes.ok) {
const openIssueData = await openIssueRes.json();
if (openIssuesEl && openIssueData.total_count !== undefined) openIssuesEl.textContent = openIssueData.total_count;
}
} catch (e) {
console.log("GitHub API live telemetry fallback active.", e);
}
}
fetchLiveGitHubStats();
});