-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
70 lines (64 loc) · 2.94 KB
/
script.js
File metadata and controls
70 lines (64 loc) · 2.94 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
// ── Scroll reveal ──────────────────────────────────────────────────────────────
const revealObserver = new IntersectionObserver((entries, obs) => {
entries.forEach(entry => {
if (!entry.isIntersecting) return;
entry.target.classList.add('active');
obs.unobserve(entry.target);
});
}, { threshold: 0.12, rootMargin: '0px 0px -40px 0px' });
document.querySelectorAll('.reveal').forEach(el => revealObserver.observe(el));
// ── Terminal typing effect (index.html only) ──────────────────────────────────
const termLines = document.querySelectorAll('.t-anim');
if (termLines.length) {
termLines.forEach(line => {
line.style.opacity = '0';
line.style.transform = 'translateY(8px)';
line.style.transition = 'opacity 0.45s ease, transform 0.45s ease';
});
const delays = [400, 1200, 1900, 2600, 3300];
termLines.forEach((line, i) => {
setTimeout(() => {
line.style.opacity = '1';
line.style.transform = 'translateY(0)';
}, delays[i] || i * 700);
});
}
// ── Version badge — fetched from /version.json (updated each release) ────────
(async () => {
const badge = document.getElementById('version-badge');
if (!badge) return;
try {
const res = await fetch('/version.json', { cache: 'no-cache' });
if (!res.ok) return;
const { version } = await res.json();
if (version) badge.textContent = version;
} catch (_) {}
})();
// ── GitHub star count ─────────────────────────────────────────────────────────
(async () => {
const el = document.getElementById('star-count');
if (!el) return;
try {
const r = await fetch('https://api.github.com/repos/getzikra/zikra', { cache: 'no-cache' });
if (!r.ok) return;
const { stargazers_count } = await r.json();
if (typeof stargazers_count === 'number') {
el.textContent = stargazers_count >= 1000
? (stargazers_count / 1000).toFixed(1) + 'k'
: stargazers_count;
el.classList.add('loaded');
}
} catch (_) {}
})();
// ── Active nav link highlight ─────────────────────────────────────────────────
const page = window.location.pathname.split('/').pop() || 'index.html';
document.querySelectorAll('.nav-links a').forEach(a => {
const href = a.getAttribute('href');
if (
href === page ||
(page === '' && href === 'index.html') ||
(page === 'index.html' && href === 'index.html')
) {
a.classList.add('active');
}
});