-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
427 lines (376 loc) · 28.2 KB
/
Copy pathscript.js
File metadata and controls
427 lines (376 loc) · 28.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
(function () {
'use strict';
/* ── v2 beta gate ──
Flip this single line to true to show the "v2 beta" pill in the footer
(it links to /v2, the playable homepage). Nothing else needs changing. */
var V2_BETA_VISIBLE = true;
if (V2_BETA_VISIBLE) {
var betaLink = document.getElementById('v2-beta-link');
var betaDot = document.getElementById('v2-beta-dot');
if (betaLink) betaLink.hidden = false;
if (betaDot) betaDot.hidden = false;
}
/* ── Tabs ── */
var tabBtns = document.querySelectorAll('.tab-btn');
tabBtns.forEach(function (btn) {
btn.addEventListener('click', function () {
tabBtns.forEach(function (b) {
b.classList.remove('active');
b.setAttribute('aria-selected', 'false');
});
btn.classList.add('active');
btn.setAttribute('aria-selected', 'true');
document.querySelectorAll('.panel').forEach(function (p) {
p.classList.remove('active');
});
var panel = document.getElementById('panel-' + btn.dataset.tab);
if (panel) panel.classList.add('active');
});
});
/* ── Current time (Asia/Dubai) ── */
var timeEl = document.getElementById('current-time');
function updateCurrentTime() {
if (!timeEl) return;
var now = new Date();
timeEl.textContent = new Intl.DateTimeFormat('en-GB', {
hour: '2-digit',
minute: '2-digit',
hour12: false,
timeZone: 'Asia/Dubai',
}).format(now);
timeEl.setAttribute('datetime', now.toISOString());
}
updateCurrentTime();
var msToNextMinute = 60000 - (Date.now() % 60000);
setTimeout(function () {
updateCurrentTime();
setInterval(updateCurrentTime, 60000);
}, msToNextMinute);
/* ── Greeting message ── */
var greetingEl = document.getElementById('greeting-message');
if (greetingEl) {
var hour = new Date().getHours();
var greeting;
if (hour < 5) greeting = 'Up late';
else if (hour < 12) greeting = 'Good morning';
else if (hour < 18) greeting = 'Good afternoon';
else greeting = 'Good evening';
greetingEl.textContent = greeting;
}
/* ── Social hover/tap usernames ── */
var usernameEl = document.getElementById('social-username');
if (usernameEl) {
document.querySelectorAll('.social-link[data-username]').forEach(function (link) {
link.addEventListener('mouseenter', function () {
usernameEl.textContent = link.dataset.username;
});
link.addEventListener('mouseleave', function () {
usernameEl.innerHTML = ' ';
});
link.addEventListener('focus', function () {
usernameEl.textContent = link.dataset.username;
});
link.addEventListener('blur', function () {
usernameEl.innerHTML = ' ';
});
link.addEventListener('touchstart', function () {
usernameEl.textContent = link.dataset.username;
});
});
}
/* ── Modals ── */
document.querySelectorAll('.modal').forEach(function (modal) {
modal.addEventListener('click', function (e) {
if (e.target === modal) modal.classList.remove('active');
});
});
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape') {
document.querySelectorAll('.modal.active').forEach(function (m) {
m.classList.remove('active');
});
}
});
var friendsModal = document.getElementById('friends-modal');
var friendsBtn = document.getElementById('friends-btn');
if (friendsBtn && friendsModal) {
friendsBtn.addEventListener('click', function () {
friendsModal.classList.add('active');
});
}
/* ── Time modal ── */
var timeModal = document.getElementById('time-modal');
var timeBtn = document.getElementById('time-btn');
var timeClockEl = document.getElementById('time-modal-clock');
var timeUtcEl = document.getElementById('time-modal-utc');
var timeDescEl = document.getElementById('time-desc');
function utcOffsetHours(tz) {
var parts = new Intl.DateTimeFormat('en-US', {
timeZone: tz,
timeZoneName: 'shortOffset',
}).formatToParts(new Date());
var name = '';
parts.forEach(function (p) {
if (p.type === 'timeZoneName') name = p.value;
});
var m = name.match(/GMT([+-])(\d{1,2})(?::(\d{2}))?/);
if (!m) return 0;
var h = parseInt(m[2], 10) + (m[3] ? parseInt(m[3], 10) / 60 : 0);
return m[1] === '-' ? -h : h;
}
function formatOffset(hours) {
var sign = hours < 0 ? '-' : '+';
var abs = Math.abs(hours);
var whole = Math.floor(abs);
var mins = Math.round((abs - whole) * 60);
return 'UTC' + sign + whole + (mins ? ':' + String(mins).padStart(2, '0') : '');
}
function formatHours(hours) {
var abs = Math.abs(hours);
var rounded = Math.round(abs * 100) / 100;
return rounded + (rounded === 1 ? ' hour' : ' hours');
}
function updateTimeModal() {
if (!timeModal.classList.contains('active')) {
clearInterval(timeTicker);
timeTicker = null;
return;
}
timeClockEl.textContent = new Intl.DateTimeFormat('en-GB', {
hour: '2-digit',
minute: '2-digit',
second: '2-digit',
hour12: false,
timeZone: 'Asia/Dubai',
}).format(new Date());
}
var timeTicker = null;
if (timeBtn && timeModal) {
timeBtn.addEventListener('click', function () {
var myOffset = utcOffsetHours('Asia/Dubai');
var yourTz = Intl.DateTimeFormat().resolvedOptions().timeZone;
var yourOffset = utcOffsetHours(yourTz);
var diff = yourOffset - myOffset;
timeUtcEl.textContent = formatOffset(myOffset);
var hour = new Date().getHours();
var greeting;
if (hour < 5) greeting = 'Up late';
else if (hour < 12) greeting = 'Good morning';
else if (hour < 18) greeting = 'Good afternoon';
else greeting = 'Good evening';
var comparison;
if (diff === 0) {
comparison = 'which is the same as mine';
} else {
comparison =
'which is <span class="accent">' + formatHours(diff) + '</span> ' +
(diff > 0 ? 'ahead of' : 'behind') + ' my timezone';
}
timeDescEl.innerHTML =
greeting + ', your timezone is <span class="accent">' +
formatOffset(yourOffset) + '</span>, ' + comparison +
'. The above time is the current time in Dubai, United Arab Emirates, where I live.';
timeModal.classList.add('active');
updateTimeModal();
if (!timeTicker) timeTicker = setInterval(updateTimeModal, 1000);
});
}
/* ── Tech stack ── */
var track = document.getElementById('tech-strip');
if (track) {
var icons = {
docker: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13.983 11.078h2.119a.186.186 0 0 0 .186-.185V9.006a.186.186 0 0 0-.186-.186h-2.119a.185.185 0 0 0-.185.185v1.888c0 .102.083.185.185.185m-2.954-5.43h2.118a.186.186 0 0 0 .186-.186V3.574a.186.186 0 0 0-.186-.185h-2.118a.185.185 0 0 0-.185.185v1.888c0 .102.082.185.185.185m0 2.716h2.118a.187.187 0 0 0 .186-.186V6.29a.186.186 0 0 0-.186-.185h-2.118a.185.185 0 0 0-.185.185v1.887c0 .102.082.185.185.186m-2.93 0h2.12a.186.186 0 0 0 .184-.186V6.29a.185.185 0 0 0-.185-.185H8.1a.185.185 0 0 0-.185.185v1.887c0 .102.083.185.185.186m-2.964 0h2.119a.186.186 0 0 0 .185-.186V6.29a.185.185 0 0 0-.185-.185H5.136a.186.186 0 0 0-.186.185v1.887c0 .102.084.185.186.186m5.893 2.715h2.118a.186.186 0 0 0 .186-.185V9.006a.186.186 0 0 0-.186-.186h-2.118a.185.185 0 0 0-.185.185v1.888c0 .102.082.185.185.185m-2.93 0h2.12a.185.185 0 0 0 .184-.185V9.006a.185.185 0 0 0-.184-.186h-2.12a.185.185 0 0 0-.184.185v1.888c0 .102.083.185.185.185m-2.964 0h2.119a.185.185 0 0 0 .185-.185V9.006a.185.185 0 0 0-.184-.186h-2.12a.186.186 0 0 0-.186.186v1.887c0 .102.084.185.186.185m-2.92 0h2.12a.185.185 0 0 0 .184-.185V9.006a.185.185 0 0 0-.184-.186h-2.12a.185.185 0 0 0-.184.185v1.888c0 .102.082.185.185.185M23.763 9.89c-.065-.051-.672-.51-1.954-.51-.338.001-.676.03-1.01.087-.248-1.7-1.653-2.53-1.716-2.566l-.344-.199-.226.327c-.284.438-.49.922-.612 1.43-.23.97-.09 1.882.403 2.661-.595.332-1.55.413-1.744.42H.751a.751.751 0 0 0-.75.748 11.376 11.376 0 0 0 .692 4.062c.545 1.428 1.355 2.48 2.41 3.124 1.18.723 3.1 1.137 5.275 1.137.983.003 1.963-.086 2.93-.266a12.248 12.248 0 0 0 3.823-1.389c.98-.567 1.86-1.288 2.61-2.136 1.252-1.418 1.998-2.997 2.553-4.4h.221c1.372 0 2.215-.549 2.68-1.009.309-.293.55-.65.707-1.046l.098-.288Z"/></svg>',
sqlite: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M21.678.521c-1.032-.92-2.28-.55-3.513.544a8.71 8.71 0 0 0-.547.535c-2.109 2.237-4.066 6.38-4.674 9.544.237.48.422 1.093.544 1.561a13.044 13.044 0 0 1 .164.703s-.019-.071-.096-.296l-.05-.146a1.689 1.689 0 0 0-.033-.08c-.138-.32-.518-.995-.686-1.289-.143.423-.27.818-.376 1.176.484.884.778 2.4.778 2.4s-.025-.099-.147-.442c-.107-.303-.644-1.244-.772-1.464-.217.804-.304 1.346-.226 1.478.152.256.296.698.422 1.186.286 1.1.485 2.44.485 2.44l.017.224a22.41 22.41 0 0 0 .056 2.748c.095 1.146.273 2.13.5 2.657l.155-.084c-.334-1.038-.47-2.399-.41-3.967.09-2.398.642-5.29 1.661-8.304 1.723-4.55 4.113-8.201 6.3-9.945-1.993 1.8-4.692 7.63-5.5 9.788-.904 2.416-1.545 4.684-1.931 6.857.666-2.037 2.821-2.912 2.821-2.912s1.057-1.304 2.292-3.166c-.74.169-1.955.458-2.362.629-.6.251-.762.337-.762.337s1.945-1.184 3.613-1.72C21.695 7.9 24.195 2.767 21.678.521m-18.573.543A1.842 1.842 0 0 0 1.27 2.9v16.608a1.84 1.84 0 0 0 1.835 1.834h9.418a22.953 22.953 0 0 1-.052-2.707c-.006-.062-.011-.141-.016-.2a27.01 27.01 0 0 0-.473-2.378c-.121-.47-.275-.898-.369-1.057-.116-.197-.098-.31-.097-.432 0-.12.015-.245.037-.386a9.98 9.98 0 0 1 .234-1.045l.217-.028c-.017-.035-.014-.065-.031-.097l-.041-.381a32.8 32.8 0 0 1 .382-1.194l.2-.019c-.008-.016-.01-.038-.018-.053l-.043-.316c.63-3.28 2.587-7.443 4.8-9.791.066-.069.133-.128.198-.194Z"/></svg>',
arch: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M11.39.605C10.376 3.092 9.764 4.72 8.635 7.132c.693.734 1.543 1.589 2.923 2.554-1.484-.61-2.496-1.224-3.252-1.86C6.86 10.842 4.596 15.138 0 23.395c3.612-2.085 6.412-3.37 9.021-3.862a6.61 6.61 0 0 1-.171-1.547l.003-.115c.058-2.315 1.261-4.095 2.687-3.973 1.426.12 2.534 2.096 2.478 4.409a6.52 6.52 0 0 1-.146 1.243c2.58.505 5.352 1.787 8.914 3.844-.702-1.293-1.33-2.459-1.929-3.57-.943-.73-1.926-1.682-3.933-2.713 1.38.359 2.367.772 3.137 1.234-6.09-11.334-6.582-12.84-8.67-17.74zM22.898 21.36v-.623h-.234v-.084h.562v.084h-.234v.623h.331v-.707h.142l.167.5.034.107a2.26 2.26 0 0 1 .038-.114l.17-.493H24v.707h-.091v-.593l-.206.593h-.084l-.205-.602v.602h-.091"/></svg>',
js: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M0 0h24v24H0V0zm22.034 18.276c-.175-1.095-.888-2.015-3.003-2.873-.736-.345-1.554-.585-1.797-1.14-.091-.33-.105-.51-.046-.705.15-.646.915-.84 1.515-.66.39.12.75.42.976.9 1.034-.676 1.034-.676 1.755-1.125-.27-.42-.404-.601-.586-.78-.63-.705-1.469-1.065-2.834-1.034l-.705.089c-.676.165-1.32.525-1.71 1.005-1.14 1.291-.811 3.541.569 4.471 1.365 1.02 3.361 1.244 3.616 2.205.24 1.17-.87 1.545-1.966 1.41-.811-.18-1.26-.586-1.755-1.336l-1.83 1.051c.21.48.45.689.81 1.109 1.74 1.756 6.09 1.666 6.871-1.004.029-.09.24-.705.074-1.65l.046.067zm-8.983-7.245h-2.248c0 1.938-.009 3.864-.009 5.805 0 1.232.063 2.363-.138 2.711-.33.689-1.18.601-1.566.48-.396-.196-.597-.466-.83-.855-.063-.105-.11-.196-.127-.196l-1.825 1.125c.305.63.75 1.172 1.324 1.517.855.51 2.004.675 3.207.405.783-.226 1.458-.691 1.811-1.411.51-.93.402-2.07.397-3.346.012-2.054 0-4.109 0-6.179l.004-.056z"/></svg>',
ts: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M1.125 0C.502 0 0 .502 0 1.125v21.75C0 23.498.502 24 1.125 24h21.75c.623 0 1.125-.502 1.125-1.125V1.125C24 .502 23.498 0 22.875 0zm17.363 9.75c.612 0 1.154.037 1.627.111a6.38 6.38 0 0 1 1.306.34v2.458a3.95 3.95 0 0 0-.643-.361 5.093 5.093 0 0 0-.717-.26 5.453 5.453 0 0 0-1.426-.2c-.3 0-.573.028-.819.086a2.1 2.1 0 0 0-.623.242c-.17.104-.3.229-.393.374a.888.888 0 0 0-.14.49c0 .196.053.373.156.529.104.156.252.304.443.444s.423.276.696.41c.273.135.582.274.926.416.47.197.892.407 1.266.628.374.222.695.473.963.753.268.279.472.598.614.957.142.359.214.776.214 1.253 0 .657-.125 1.21-.373 1.656a3.033 3.033 0 0 1-1.012 1.085 4.38 4.38 0 0 1-1.487.596c-.566.12-1.163.18-1.79.18a9.916 9.916 0 0 1-1.84-.164 5.544 5.544 0 0 1-1.512-.493v-2.63a5.033 5.033 0 0 0 3.237 1.2c.333 0 .624-.03.872-.09.249-.06.456-.144.623-.25.166-.108.29-.234.373-.38a1.023 1.023 0 0 0-.074-1.089 2.12 2.12 0 0 0-.537-.5 5.597 5.597 0 0 0-.807-.444 27.72 27.72 0 0 0-1.007-.436c-.918-.383-1.602-.852-2.053-1.405-.45-.553-.676-1.222-.676-2.005 0-.614.123-1.141.369-1.582.246-.441.58-.804 1.004-1.089a4.494 4.494 0 0 1 1.47-.629 7.536 7.536 0 0 1 1.77-.201zm-15.113.188h9.563v2.166H9.506v9.646H6.789v-9.646H3.375z"/></svg>',
go: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M1.811 10.231c-.047 0-.058-.023-.035-.059l.246-.315c.023-.035.081-.058.128-.058h4.172c.047 0 .058.035.035.07l-.199.303c-.023.036-.082.07-.117.07zM.047 11.306c-.047 0-.059-.023-.035-.058l.245-.316c.023-.035.082-.058.129-.058h5.328c.047 0 .07.035.058.07l-.093.28c-.012.047-.058.07-.105.07zm2.828 1.075c-.047 0-.059-.035-.035-.07l.163-.292c.023-.035.07-.07.117-.07h2.337c.047 0 .07.035.07.082l-.023.28c0 .047-.047.082-.082.082zm12.129-2.36c-.736.187-1.239.327-1.963.514-.176.046-.187.058-.34-.117-.174-.199-.303-.327-.548-.444-.737-.362-1.45-.257-2.115.175-.795.514-1.204 1.274-1.192 2.22.011.935.654 1.706 1.577 1.835.795.105 1.46-.175 1.987-.77.105-.13.198-.27.315-.434H10.47c-.245 0-.304-.152-.222-.35.152-.362.432-.97.596-1.274a.315.315 0 0 1 .292-.187h4.253c-.023.316-.023.631-.07.947a4.983 4.983 0 0 1-.958 2.29c-.841 1.11-1.94 1.8-3.33 1.986-1.145.152-2.209-.07-3.143-.77-.865-.655-1.356-1.52-1.484-2.595-.152-1.274.222-2.419.993-3.424.83-1.086 1.928-1.776 3.272-2.02 1.098-.2 2.15-.07 3.096.571.62.41 1.063.97 1.356 1.648.07.105.023.164-.117.2m3.868 6.461c-1.064-.024-2.034-.328-2.852-1.029a3.665 3.665 0 0 1-1.262-2.255c-.21-1.32.152-2.489.947-3.529.853-1.122 1.881-1.706 3.272-1.95 1.192-.21 2.314-.095 3.33.595.923.63 1.496 1.484 1.648 2.605.198 1.578-.257 2.863-1.344 3.962-.771.783-1.718 1.273-2.805 1.495-.315.06-.63.07-.934.106zm2.78-4.72c-.011-.153-.011-.27-.034-.387-.21-1.157-1.274-1.81-2.384-1.554-1.087.245-1.788.935-2.045 2.033-.21.912.234 1.835 1.075 2.21.643.28 1.285.244 1.905-.07.923-.48 1.425-1.228 1.484-2.233z"/></svg>',
git: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M13.09 23.549a1.54 1.54 0 0 1-2.18 0L.451 13.089a1.54 1.54 0 0 1 0-2.179l7.191-7.19 2.733 2.733a1.85 1.85 0 0 0 .964 2.326v6.66a1.849 1.849 0 1 0 1.54 0V8.957l2.508 2.508a1.85 1.85 0 1 0 1.09-1.09l-2.634-2.634a1.85 1.85 0 0 0-2.378-2.377L8.73 2.63 10.91.451a1.54 1.54 0 0 1 2.179 0l10.459 10.46a1.54 1.54 0 0 1 0 2.179z"/></svg>',
linux: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12.504 0c-.155 0-.315.008-.48.021-4.226.333-3.105 4.807-3.17 6.298-.076 1.092-.3 1.953-1.05 3.02-.885 1.051-2.127 2.75-2.716 4.521-.278.832-.41 1.684-.287 2.489a.424.424 0 0 0-.11.135c-.26.268-.45.6-.663.839-.199.199-.485.267-.797.4-.313.136-.658.269-.864.68-.09.189-.136.394-.132.602 0 .199.027.4.055.536.058.399.116.728.04.97-.249.68-.28 1.145-.106 1.484.174.334.535.47.94.601.81.2 1.91.135 2.774.6.926.466 1.866.67 2.616.47.526-.116.97-.464 1.208-.946.587-.003 1.23-.269 2.26-.334.699-.058 1.574.267 2.577.2.025.134.063.198.114.333l.003.003c.391.778 1.113 1.132 1.884 1.071.771-.06 1.592-.536 2.257-1.306.631-.765 1.683-1.084 2.378-1.503.348-.199.629-.469.649-.853.023-.4-.2-.811-.714-1.376v-.097l-.003-.003c-.17-.2-.25-.535-.338-.926-.085-.401-.182-.786-.492-1.046h-.003c-.059-.054-.123-.067-.188-.135a.357.357 0 0 0-.19-.064c.431-1.278.264-2.55-.173-3.694-.533-1.41-1.465-2.638-2.175-3.483-.796-1.005-1.576-1.957-1.56-3.368.026-2.152.236-6.133-3.544-6.139zm.529 3.405h.013c.213 0 .396.062.584.198.19.135.33.332.438.533.105.259.158.459.166.724 0-.02.006-.04.006-.06v.105a.086.086 0 0 1-.004-.021l-.004-.024a1.807 1.807 0 0 1-.14.698.953.953 0 0 1-.213.335.71.71 0 0 0-.088-.042c-.104-.045-.198-.064-.284-.133a1.312 1.312 0 0 0-.22-.066c.05-.06.146-.133.183-.198.053-.128.082-.264.088-.402v-.02a1.21 1.21 0 0 0-.061-.4c-.045-.134-.101-.2-.183-.333-.084-.066-.167-.132-.267-.132h-.016c-.093 0-.176.03-.262.132a.8.8 0 0 0-.205.334 1.18 1.18 0 0 0-.09.4v.019c.002.089.008.179.02.267-.193-.067-.438-.135-.607-.202a1.635 1.635 0 0 1-.018-.2v-.02a1.772 1.772 0 0 1 .15-.768c.082-.22.232-.406.43-.533a.985.985 0 0 1 .594-.2zm-2.962.059h.036c.142 0 .27.048.399.135.146.129.264.288.344.465.09.199.14.4.153.667v.004c.007.134.006.2-.002.266v.08c-.03.007-.056.018-.083.024-.152.055-.274.135-.393.2.012-.09.013-.18.003-.267v-.015c-.012-.133-.04-.2-.082-.333a.613.613 0 0 0-.166-.267.248.248 0 0 0-.183-.064h-.021c-.071.006-.13.04-.186.132a.552.552 0 0 0-.12.27.944.944 0 0 0-.023.33v.015c.012.135.037.2.08.334.046.134.098.2.166.268.01.009.02.018.034.024-.07.057-.117.07-.176.136a.304.304 0 0 1-.131.068 2.62 2.62 0 0 1-.275-.402 1.772 1.772 0 0 1-.155-.667 1.759 1.759 0 0 1 .08-.668 1.43 1.43 0 0 1 .283-.535c.128-.133.26-.2.418-.2zm1.37 1.706c.332 0 .733.065 1.216.399.293.2.523.269 1.052.468h.003c.255.136.405.266.478.399v-.131a.571.571 0 0 1 .016.47c-.123.31-.516.643-1.063.842v.002c-.268.135-.501.333-.775.465-.276.135-.588.292-1.012.267a1.139 1.139 0 0 1-.448-.067 3.566 3.566 0 0 1-.322-.198c-.195-.135-.363-.332-.612-.465v-.005h-.005c-.4-.246-.616-.512-.686-.71-.07-.268-.005-.47.193-.6.224-.135.38-.271.483-.336.104-.074.143-.102.176-.131h.002v-.003c.169-.202.436-.47.839-.601.139-.036.294-.065.466-.065zm2.8 2.142c.358 1.417 1.196 3.475 1.735 4.473.286.534.855 1.659 1.102 3.024.156-.005.33.018.513.064.646-1.671-.546-3.467-1.089-3.966-.22-.2-.232-.335-.123-.335.59.534 1.365 1.572 1.646 2.757.13.535.16 1.104.021 1.67.067.028.135.06.205.067 1.032.534 1.413.938 1.23 1.537v-.043c-.06-.003-.12 0-.18 0h-.016c.151-.467-.182-.825-1.065-1.224-.915-.4-1.646-.336-1.77.465-.008.043-.013.066-.018.135-.068.023-.139.053-.209.064-.43.268-.662.669-.793 1.187-.13.533-.17 1.156-.205 1.869v.003c-.02.334-.17.838-.319 1.35-1.5 1.072-3.58 1.538-5.348.334a2.645 2.645 0 0 0-.402-.533 1.45 1.45 0 0 0-.275-.333c.182 0 .338-.03.465-.067a.615.615 0 0 0 .314-.334c.108-.267 0-.697-.345-1.163-.345-.467-.931-.995-1.788-1.521-.63-.4-.986-.87-1.15-1.396-.165-.534-.143-1.085-.015-1.645.245-1.07.873-2.11 1.274-2.763.107-.065.037.135-.408.974-.396.751-1.14 2.497-.122 3.854a8.123 8.123 0 0 1 .647-2.876c.564-1.278 1.743-3.504 1.836-5.268.048.036.217.135.289.202.218.133.38.333.59.465.21.201.477.335.876.335.039.003.075.006.11.006.412 0 .73-.134.997-.268.29-.134.52-.334.74-.4h.005c.467-.135.835-.402 1.044-.7zm2.185 8.958c.037.6.343 1.245.882 1.377.588.134 1.434-.333 1.791-.765l.211-.01c.315-.007.577.01.847.268l.003.003c.208.199.305.53.391.876.085.4.154.78.409 1.066.486.527.645.906.636 1.14l.003-.007v.018l-.003-.012c-.015.262-.185.396-.498.595-.63.401-1.746.712-2.457 1.57-.618.737-1.37 1.14-2.036 1.191-.664.053-1.237-.2-1.574-.898l-.005-.003c-.21-.4-.12-1.025.056-1.69.176-.668.428-1.344.463-1.897.037-.714.076-1.335.195-1.814.12-.465.308-.797.641-.984l.045-.022zm-10.814.049h.01c.053 0 .105.005.157.014.376.055.706.333 1.023.752l.91 1.664.003.003c.243.533.754 1.064 1.189 1.637.434.598.77 1.131.729 1.57v.006c-.057.744-.48 1.148-1.125 1.294-.645.135-1.52.002-2.395-.464-.968-.536-2.118-.469-2.857-.602-.369-.066-.61-.2-.723-.4-.11-.2-.113-.602.123-1.23v-.004l.002-.003c.117-.334.03-.752-.027-1.118-.055-.401-.083-.71.043-.94.16-.334.396-.4.69-.533.294-.135.64-.202.915-.47h.002v-.002c.256-.268.445-.601.668-.838.19-.201.38-.336.663-.336zm7.159-9.074c-.435.201-.945.535-1.488.535-.542 0-.97-.267-1.28-.466-.154-.134-.28-.268-.373-.335-.164-.134-.144-.333-.074-.333.109.016.129.134.199.2.096.066.215.2.36.333.292.2.68.467 1.167.467.485 0 1.053-.267 1.398-.466.195-.135.445-.334.648-.467.156-.136.149-.267.279-.267.128.016.034.134-.147.332a8.097 8.097 0 0 1-.69.468zm-1.082-1.583V5.64c-.006-.02.013-.042.029-.05.074-.043.18-.027.26.004.063 0 .16.067.15.135-.006.049-.085.066-.135.066-.055 0-.092-.043-.141-.068-.052-.018-.146-.008-.163-.065zm-.551 0c-.02.058-.113.049-.166.066-.047.025-.086.068-.14.068-.05 0-.13-.02-.136-.068-.01-.066.088-.133.15-.133.08-.031.184-.047.259-.005.019.009.036.03.03.05v.02h.003z"/></svg>',
};
function iconWrap(id, label) {
return '<div class="icon-wrap" title="' + label + '">' + (icons[id] || '') + '</div>';
}
var dot = '<span class="tech-dot">·</span>';
var parts = [];
parts.push(iconWrap('docker', 'Docker'));
parts.push(iconWrap('sqlite', 'SQLite'));
parts.push(iconWrap('arch', 'Arch Linux'));
parts.push(dot);
parts.push(iconWrap('js', 'JavaScript'));
parts.push(iconWrap('ts', 'TypeScript'));
parts.push(iconWrap('go', 'Go'));
parts.push(dot);
parts.push(iconWrap('git', 'Git'));
parts.push(iconWrap('linux', 'Linux'));
track.innerHTML = parts.join('');
}
/* ── Theme toggle ── */
var toggle = document.getElementById('theme-toggle');
if (toggle) {
var icon = toggle.querySelector('svg');
function setTheme(light) {
document.body.classList.toggle('light', light);
var sun = '<path d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 1 1-8 0 4 4 0 0 1 8 0z"/>';
var moon = '<path d="M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"/>';
icon.innerHTML = light ? moon : sun;
try { localStorage.setItem('theme', light ? 'light' : 'dark'); } catch (_) {}
}
toggle.addEventListener('click', function () {
setTheme(!document.body.classList.contains('light'));
});
try {
if (localStorage.getItem('theme') === 'light') setTheme(true);
} catch (_) {}
}
/* ── GitHub activity graph ── */
var ghSection = document.getElementById('github-activity');
var ghMobileQuery = window.matchMedia('(max-width: 700px)');
var ghLastData = null;
function renderActivity(data) {
if (!data || !data.contributions) {
if (ghSection) ghSection.innerHTML = '<p class="loading">No contribution data.</p>';
return;
}
ghLastData = data;
var isMobile = ghMobileQuery.matches;
var contribs = data.contributions;
var headerLabel;
if (isMobile) {
var cutoff = new Date();
cutoff.setDate(cutoff.getDate() - 29);
contribs = contribs.filter(function (c) {
return new Date(c.date) >= cutoff;
});
var monthTotal = contribs.reduce(function (sum, c) {
return sum + (c.count || 0);
}, 0);
headerLabel = monthTotal + ' contributions in the last month';
} else {
headerLabel = escapeHtml(data.total.lastYear) + ' contributions in the last year';
}
var weeks = [];
var currentWeek = [];
contribs.forEach(function (c, i) {
var d = new Date(c.date);
var dayOfWeek = d.getDay();
if (dayOfWeek === 0 && currentWeek.length > 0) {
weeks.push(currentWeek);
currentWeek = [];
}
currentWeek.push(c);
});
if (currentWeek.length > 0) weeks.push(currentWeek);
var tableHtml = '<div class="gh-activity' + (isMobile ? ' gh-activity--compact' : '') + '"><div class="gh-activity-header">';
tableHtml += '<span>' + headerLabel + '</span>';
tableHtml += '</div><div class="gh-activity-grid">';
var days = ['', 'Mon', '', 'Wed', '', 'Fri', ''];
for (var row = 0; row < 7; row++) {
tableHtml += '<div class="gh-row">';
tableHtml += '<span class="gh-day-label">' + days[row] + '</span>';
for (var col = 0; col < weeks.length; col++) {
var dayData = weeks[col][row] || { level: 0, count: 0, date: '' };
var level = dayData.level || 0;
tableHtml += '<span class="gh-cell gh-lvl-' + level + '"';
if (dayData.count > 0) {
tableHtml += ' title="' + dayData.count + ' contributions on ' + dayData.date + '"';
}
tableHtml += '></span>';
}
tableHtml += '</div>';
}
tableHtml += '</div>';
tableHtml += '<div class="gh-months">';
var monthLabels = [];
weeks.forEach(function (week, idx) {
var firstDay = week[0];
if (firstDay) {
var date = new Date(firstDay.date);
var month = date.getMonth();
var prevMonth = idx > 0 ? new Date(weeks[idx - 1][0].date).getMonth() : -1;
if (month !== prevMonth) {
var names = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
monthLabels.push('<span class="gh-month-label">' + names[month] + '</span>');
} else {
monthLabels.push('<span class="gh-month-label"></span>');
}
}
});
tableHtml += monthLabels.join('');
tableHtml += '</div>';
tableHtml += '<div class="gh-legend">';
tableHtml += '<span>Less</span>';
for (var l = 0; l <= 4; l++) {
tableHtml += '<span class="gh-cell gh-lvl-' + l + '"></span>';
}
tableHtml += '<span>More</span>';
tableHtml += '</div></div>';
if (ghSection) ghSection.innerHTML = tableHtml;
}
if (ghSection) {
var ghCache = null;
try {
ghCache = JSON.parse(sessionStorage.getItem('gh_contrib'));
} catch (_) {}
if (ghCache) {
renderActivity(ghCache);
} else {
fetch('https://github-contributions-api.jogruber.de/v4/joddabodscripts?y=last')
.then(function (res) {
if (!res.ok) throw new Error('API returned ' + res.status);
return res.json();
})
.then(function (data) {
try { sessionStorage.setItem('gh_contrib', JSON.stringify(data)); } catch (_) {}
renderActivity(data);
})
.catch(function (err) {
ghSection.innerHTML = '<p class="loading">Failed to load activity: ' + err.message + '</p>';
});
}
var handleGhBreakpointChange = function () {
if (ghLastData) renderActivity(ghLastData);
};
if (ghMobileQuery.addEventListener) {
ghMobileQuery.addEventListener('change', handleGhBreakpointChange);
} else if (ghMobileQuery.addListener) {
ghMobileQuery.addListener(handleGhBreakpointChange);
}
}
/* ── Projects ── */
var list = document.getElementById('projects-list');
var projects = [
{ name: 'confession', repo: 'https://github.com/JoddabodScripts/confession', site: null },
{ name: 'Wordle-nerimity', repo: 'https://github.com/JoddabodScripts/Wordle-nerimity', site: 'https://nerimity.com/bot/1750805898999283712?perms=2' },
{ name: 'nerimity-minecraft-bot', repo: 'https://github.com/JoddabodScripts/nerimity-minecraft-bot', site: null },
{ name: 'Welcome-nerimity', repo: 'https://github.com/JoddabodScripts/Welcome-nerimity', site: 'https://nerimity.com/bot/1779106890270289920?perms=1' },
{ name: 'pollmaster-bot', repo: 'https://github.com/JoddabodScripts/pollmaster-bot', site: 'https://nerimity.com/bot/1780259110466531328?perms=1' },
{ name: 'quote-bot-nerimity', repo: 'https://github.com/JoddabodScripts/quote-bot-nerimity', site: 'https://nerimity.com/bot/1764179666803007488?perms=2' },
{ name: 'Neri-cat-bot', repo: 'https://github.com/JoddabodScripts/Neri-cat-bot', site: 'https://nerimity.com/bot/1769948866624536576?perms=2' },
{ name: 'Gun-bot-nerimity', repo: 'https://github.com/JoddabodScripts/Gun-bot-nerimity', site: 'https://nerimity.com/bot/1766352888835252224?perms=2' },
{ name: 'neri-go', repo: 'https://github.com/JoddabodScripts/neri-go/', site: 'https://github.com/JoddabodScripts/neri-go/' },
{ name: 'neritest', repo: 'https://github.com/JoddabodScripts/neritest/', site: 'https://github.com/JoddabodScripts/neritest/' },
{ name: 'joddabodscripts.github.io', repo: 'https://github.com/JoddabodScripts/joddabodscripts.github.io/', site: 'joddabodscripts.github.io/' },
];
function renderProjects() {
var html = '';
projects.forEach(function (p) {
html += '<div class="project-row">';
html += '<a href="' + p.repo + '" target="_blank" class="name">' + escapeHtml(p.name) + '</a>';
if (p.site) {
html += '<a href="' + p.site + '" target="_blank" class="site-link">Website</a>';
} else {
html += '<span class="site-link site-link--na">N/A</span>';
}
html += '</div>';
});
list.innerHTML = html;
}
if (list) renderProjects();
/* ── Helpers ── */
function escapeHtml(str) {
var div = document.createElement('div');
div.appendChild(document.createTextNode(str));
return div.innerHTML;
}
})();