-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
119 lines (95 loc) · 3.43 KB
/
Copy pathscript.js
File metadata and controls
119 lines (95 loc) · 3.43 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
/* script.js — Developer portfolio shared scripts */
/* ── Helpers ────────────────────────────────────────────────── */
function delay(ms) {
return new Promise(r => setTimeout(r, ms));
}
function typewriter(el, text, speed) {
speed = speed || 45;
return new Promise(function (resolve) {
var i = 0;
function tick() {
if (i < text.length) {
el.textContent += text[i++];
setTimeout(tick, speed);
} else {
resolve();
}
}
tick();
});
}
/* ── Terminal Animation (index.html only) ───────────────────── */
async function startTerminal() {
var body = document.querySelector('.terminal-body');
if (!body) return;
var PROMPT = 'vlad@portfolio:~$ ';
async function addCommandLine(cmd) {
var line = document.createElement('div');
line.className = 'terminal-line';
var p = document.createElement('span');
p.className = 'terminal-prompt';
p.textContent = PROMPT;
var c = document.createElement('span');
c.className = 'terminal-cmd';
line.append(p, c);
body.appendChild(line);
await typewriter(c, cmd, 60);
await delay(180);
}
async function addOutputLine(text, extraClass) {
var out = document.createElement('div');
out.className = 'terminal-output' + (extraClass ? ' ' + extraClass : '');
body.appendChild(out);
await typewriter(out, text, 20);
await delay(120);
}
async function addCursorLine() {
var line = document.createElement('div');
line.className = 'terminal-line';
var p = document.createElement('span');
p.className = 'terminal-prompt';
p.textContent = PROMPT;
var cur = document.createElement('span');
cur.className = 'terminal-cursor';
line.append(p, cur);
body.appendChild(line);
}
await delay(350);
await addCommandLine('whoami');
await addOutputLine('Vlad Petrosyan', 'green');
await delay(280);
await addCommandLine('cat role.txt');
await addOutputLine('student | engineer | robotics developer');
await delay(280);
await addCursorLine();
}
/* ── VS Code Status Bar ─────────────────────────────────────── */
function initStatusBar() {
var bar = document.querySelector('.vscode-statusbar');
if (!bar) return;
var clockEl = bar.querySelector('.statusbar-clock');
if (!clockEl) return;
function tick() {
var now = new Date();
clockEl.textContent = now.toLocaleTimeString('en-US', { hour12: false });
}
tick();
setInterval(tick, 1000);
}
/* ── Age Calculator ─────────────────────────────────────────── */
function updateAge() {
var el = document.getElementById('vlad-age');
if (!el) return;
var bday = new Date('2010-01-22');
var now = new Date();
var age = now.getFullYear() - bday.getFullYear();
var m = now.getMonth() - bday.getMonth();
if (m < 0 || (m === 0 && now.getDate() < bday.getDate())) age--;
el.textContent = age;
}
/* ── Init ───────────────────────────────────────────────────── */
document.addEventListener('DOMContentLoaded', function () {
startTerminal();
initStatusBar();
updateAge();
});