-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
539 lines (443 loc) · 13.7 KB
/
Copy pathscript.js
File metadata and controls
539 lines (443 loc) · 13.7 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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
const typingText = document.getElementById("typing-text");
const body = document.body;
const symbolCanvas = document.getElementById("symbol-canvas");
const phrases = [
"shipping backend tools with real-world purpose",
"building bots, internal services and automations",
"focused on security-aware engineering",
"comfortable with Python, Go, C#, Rust, Docker and CI/CD"
];
const themeStorageKey = "schrodinger71-theme";
const symbolSet = ["$", "{ }", "</>", "01", "#", "!", "<>", "0x", "[ ]", ">>"];
const terminalResponses = {
help: [
"available commands:",
"about",
"stack",
"contact",
"github",
"hack",
"status",
"clear",
"date"
],
about: [
"schrodinger71",
"backend / security / devops / automation",
"focus: practical tools, bots, internal services, infra workflows"
],
stack: [
"python, go, c#, c++, docker, linux, postgresql, sqlite, github actions"
],
contact: [
"telegram: @schrodinger714",
"github: github.com/Schrodinger71",
"discord: schrodinger71"
],
github: ["opening github profile..."],
status: ["terminal theme active", "portfolio status: online"]
};
let phraseIndex = 0;
let charIndex = 0;
let isDeleting = false;
function typePhrase() {
if (!typingText) {
return;
}
const current = phrases[phraseIndex];
if (isDeleting) {
charIndex -= 1;
} else {
charIndex += 1;
}
typingText.textContent = current.slice(0, charIndex);
if (!isDeleting && charIndex === current.length) {
isDeleting = true;
setTimeout(typePhrase, 1600);
return;
}
if (isDeleting && charIndex === 0) {
isDeleting = false;
phraseIndex = (phraseIndex + 1) % phrases.length;
}
setTimeout(typePhrase, isDeleting ? 38 : 64);
}
function initThemeToggle() {
const button = document.getElementById("theme-toggle");
if (!button) {
return;
}
const applyTheme = (mode) => {
const isDemonic = mode === "demonic";
body.classList.toggle("theme-demonic", isDemonic);
button.setAttribute("aria-pressed", String(isDemonic));
};
const saved = localStorage.getItem(themeStorageKey);
applyTheme(saved === "demonic" ? "demonic" : "default");
button.addEventListener("click", () => {
const nextMode = body.classList.contains("theme-demonic") ? "default" : "demonic";
localStorage.setItem(themeStorageKey, nextMode);
applyTheme(nextMode);
});
}
function initSymbolBackground() {
if (!symbolCanvas) {
return;
}
const context = symbolCanvas.getContext("2d");
if (!context) {
return;
}
const particles = [];
const mobile = window.innerWidth <= 768;
const particleCount = mobile ? 26 : 58;
const resize = () => {
symbolCanvas.width = window.innerWidth;
symbolCanvas.height = window.innerHeight;
};
class SymbolParticle {
constructor() {
this.reset();
}
reset() {
this.x = Math.random() * symbolCanvas.width;
this.y = Math.random() * symbolCanvas.height;
this.speedY = Math.random() * 0.6 + 0.18;
this.speedX = (Math.random() - 0.5) * 0.45;
this.size = Math.random() * 16 + 14;
this.opacity = Math.random() * 0.35 + 0.22;
this.glow = Math.random() * 14 + 10;
this.symbol = symbolSet[Math.floor(Math.random() * symbolSet.length)];
}
update() {
this.x += this.speedX;
this.y += this.speedY;
if (this.y > symbolCanvas.height + 30 || this.x < -60 || this.x > symbolCanvas.width + 60) {
this.reset();
this.y = -20;
}
}
draw() {
context.globalAlpha = this.opacity;
context.font = `${this.size}px Cascadia Code, Consolas, monospace`;
context.fillStyle = body.classList.contains("theme-demonic") ? "#ff8a72" : "#98ffd0";
context.shadowBlur = this.glow;
context.shadowColor = body.classList.contains("theme-demonic")
? "rgba(255, 90, 70, 0.75)"
: "rgba(111, 247, 176, 0.65)";
context.fillText(this.symbol, this.x, this.y);
context.shadowBlur = 0;
}
}
const animate = () => {
context.clearRect(0, 0, symbolCanvas.width, symbolCanvas.height);
particles.forEach((particle) => {
particle.update();
particle.draw();
});
requestAnimationFrame(animate);
};
resize();
for (let index = 0; index < particleCount; index += 1) {
particles.push(new SymbolParticle());
}
window.addEventListener("resize", resize);
animate();
}
function initReveal() {
const nodes = document.querySelectorAll("[data-reveal]");
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add("visible");
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.16 }
);
nodes.forEach((node) => observer.observe(node));
}
function initNav() {
const toggle = document.getElementById("nav-toggle");
const nav = document.getElementById("site-nav");
if (!toggle || !nav) {
return;
}
toggle.addEventListener("click", () => {
const isOpen = nav.classList.toggle("open");
toggle.setAttribute("aria-expanded", String(isOpen));
});
nav.querySelectorAll("a").forEach((link) => {
link.addEventListener("click", () => {
nav.classList.remove("open");
toggle.setAttribute("aria-expanded", "false");
});
});
}
function initScrollProgress() {
const bar = document.getElementById("scroll-progress");
if (!bar) {
return;
}
const update = () => {
const scrollable = document.documentElement.scrollHeight - window.innerHeight;
const progress = scrollable > 0 ? (window.scrollY / scrollable) * 100 : 0;
bar.style.width = `${progress}%`;
};
window.addEventListener("scroll", update, { passive: true });
window.addEventListener("resize", update);
update();
}
function initScrollSpy() {
const links = Array.from(document.querySelectorAll(".nav a"));
if (!links.length) {
return;
}
const sections = links
.map((link) => document.querySelector(link.getAttribute("href")))
.filter(Boolean);
if (!sections.length) {
return;
}
const observer = new IntersectionObserver(
(entries) => {
entries.forEach((entry) => {
if (!entry.isIntersecting) {
return;
}
links.forEach((link) => {
link.classList.toggle("active", link.getAttribute("href") === `#${entry.target.id}`);
});
});
},
{ rootMargin: "-40% 0px -50% 0px" }
);
sections.forEach((section) => observer.observe(section));
}
function initCursorGlow() {
const glow = document.getElementById("cursor-glow");
const prefersReducedMotion = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
const isFinePointer = window.matchMedia("(pointer: fine)").matches;
if (!glow || prefersReducedMotion || !isFinePointer) {
return;
}
window.addEventListener("pointermove", (event) => {
glow.style.transform = `translate(${event.clientX}px, ${event.clientY}px)`;
glow.style.opacity = "1";
});
window.addEventListener("pointerleave", () => {
glow.style.opacity = "0";
});
}
function initTerminal() {
const toggle = document.getElementById("terminal-toggle");
const windowEl = document.getElementById("terminal-window");
const close = document.getElementById("terminal-close");
const input = document.getElementById("terminal-input");
const output = document.getElementById("terminal-output");
if (!toggle || !windowEl || !close || !input || !output) {
return;
}
let introPlayed = false;
const print = (line, className = "") => {
const row = document.createElement("div");
row.className = "terminal-line";
if (className) {
row.classList.add(className);
}
row.textContent = line;
output.appendChild(row);
output.scrollTop = output.scrollHeight;
};
const printTyped = async (line, className = "", speed = 28) => {
const row = document.createElement("div");
row.className = "terminal-line";
if (className) {
row.classList.add(className);
}
output.appendChild(row);
output.scrollTop = output.scrollHeight;
for (const char of line) {
row.textContent += char;
output.scrollTop = output.scrollHeight;
await delay(speed);
}
};
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const setOpen = (open) => {
windowEl.classList.toggle("open", open);
windowEl.setAttribute("aria-hidden", String(!open));
if (open) {
setTimeout(() => input.focus(), 50);
}
};
const playIntro = async () => {
if (introPlayed) {
return;
}
introPlayed = true;
output.innerHTML = "";
setOpen(true);
await delay(260);
await printTyped("schrodinger71 terminal v2.1", "is-accent", 34);
await delay(420);
await printTyped("boot sequence started...", "", 26);
await delay(500);
await printTyped("loading profile://lucifer", "", 24);
await delay(420);
await printTyped("establishing encrypted channel ... ok", "", 22);
await delay(650);
await printTyped("root@schrodinger-box:$ nmap --top-ports 5 portfolio.local", "", 18);
await delay(520);
for (const line of ["22/tcp open ssh", "80/tcp open http", "443/tcp open https"]) {
await printTyped(line, "", 20);
await delay(340);
}
await delay(480);
await printTyped("root@schrodinger-box:$ exploit --demo --safe-mode", "", 18);
await delay(700);
const progressLine = document.createElement("div");
progressLine.className = "terminal-line is-accent";
output.appendChild(progressLine);
for (let step = 0; step <= 10; step += 1) {
const filled = "#".repeat(step);
const empty = ".".repeat(10 - step);
progressLine.textContent = `payload injected [${filled}${empty}] ${step * 10}%`;
output.scrollTop = output.scrollHeight;
await delay(step === 0 ? 420 : 280);
}
await delay(520);
await printTyped("access granted: visual theatrics only", "", 24);
await delay(420);
await printTyped("type `help` to continue", "", 24);
};
toggle.addEventListener("click", () => {
const shouldOpen = !windowEl.classList.contains("open");
setOpen(shouldOpen);
if (shouldOpen && !introPlayed) {
playIntro();
}
});
close.addEventListener("click", () => setOpen(false));
input.addEventListener("keydown", (event) => {
if (event.key !== "Enter") {
return;
}
const value = input.value.trim();
print(`root@schrodinger-box:$ ${value}`);
if (!value) {
input.value = "";
return;
}
const command = value.toLowerCase();
if (command === "clear") {
output.innerHTML = "";
input.value = "";
return;
}
if (command === "date") {
print(new Date().toLocaleString());
input.value = "";
return;
}
if (command === "github") {
terminalResponses.github.forEach(print);
window.open("https://github.com/Schrodinger71", "_blank", "noopener");
input.value = "";
return;
}
if (command === "hack") {
[
"scanning attack surface...",
"bypassing firewall... demo only",
"root shell denied by design",
"style points awarded"
].forEach((line, index) => print(line, index === 2 ? "is-accent" : ""));
input.value = "";
return;
}
const response = terminalResponses[command];
if (response) {
response.forEach(print);
} else {
print(`command not found: ${command}`);
}
input.value = "";
});
window.addEventListener("load", () => {
setTimeout(() => {
playIntro();
}, 1200);
});
}
function initDiscordCopy() {
const button = document.getElementById("copy-discord");
if (!button) {
return;
}
button.addEventListener("click", async () => {
try {
await navigator.clipboard.writeText("schrodinger71");
const original = button.textContent;
button.textContent = "Discord copied: schrodinger71";
setTimeout(() => {
button.textContent = original;
}, 1800);
} catch {
button.textContent = "Не удалось скопировать Discord";
}
});
}
async function loadGithubStats() {
const followers = document.getElementById("metric-followers");
const repos = document.getElementById("metric-repos");
const stars = document.getElementById("metric-stars");
const status = document.getElementById("metric-status");
if (!followers || !repos || !stars || !status) {
return;
}
try {
const [userResponse, reposResponse] = await Promise.all([
fetch("https://api.github.com/users/Schrodinger71"),
fetch("https://api.github.com/users/Schrodinger71/repos?per_page=100")
]);
const user = await userResponse.json();
const reposData = await reposResponse.json();
const totalStars = Array.isArray(reposData)
? reposData.reduce((sum, repo) => sum + (repo.stargazers_count || 0), 0)
: 0;
followers.textContent = String(user.followers ?? "--");
repos.textContent = String(user.public_repos ?? "--");
stars.textContent = String(totalStars);
status.textContent = "synced";
const portrait = document.getElementById("hero-portrait");
if (portrait && user.avatar_url) {
portrait.src = user.avatar_url;
}
} catch {
followers.textContent = "--";
repos.textContent = "--";
stars.textContent = "--";
status.textContent = "offline";
}
}
document.addEventListener("DOMContentLoaded", () => {
const year = document.getElementById("year");
if (year) {
year.textContent = String(new Date().getFullYear());
}
initThemeToggle();
initSymbolBackground();
typePhrase();
initReveal();
initNav();
initScrollProgress();
initScrollSpy();
initCursorGlow();
initTerminal();
initDiscordCopy();
loadGithubStats();
});
// push :3