Skip to content

Commit 4bab0f3

Browse files
authored
Update script.js
1 parent 714074d commit 4bab0f3

1 file changed

Lines changed: 96 additions & 104 deletions

File tree

hackeros-games/script.js

Lines changed: 96 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -9,48 +9,48 @@ const sidebar = document.getElementById('sidebar');
99
const menuBtn = document.getElementById('menu-btn');
1010

1111
function activateSection(id) {
12-
// Hide all sections
13-
sections.forEach(s => s.classList.remove('active'));
14-
navLinks.forEach(l => l.classList.remove('active'));
15-
16-
// Show target section
17-
const target = document.getElementById(id);
18-
if (target) target.classList.add('active');
19-
20-
// Update nav
21-
const activeLink = document.querySelector(`[data-section="${id}"]`);
22-
if (activeLink) {
23-
activeLink.classList.add('active');
24-
breadcrumb.textContent = activeLink.textContent.trim();
25-
}
26-
27-
// Scroll content to top
28-
document.querySelector('.doc-body').scrollTo(0, 0);
12+
// Hide all sections
13+
sections.forEach(s => s.classList.remove('active'));
14+
navLinks.forEach(l => l.classList.remove('active'));
15+
16+
// Show target section
17+
const target = document.getElementById(id);
18+
if (target) target.classList.add('active');
19+
20+
// Update nav
21+
const activeLink = document.querySelector(`[data-section="${id}"]`);
22+
if (activeLink) {
23+
activeLink.classList.add('active');
24+
breadcrumb.textContent = activeLink.textContent.trim();
25+
}
26+
27+
// Scroll content to top
28+
document.querySelector('.doc-body').scrollTo(0, 0);
2929
}
3030

3131
// Handle nav link clicks
3232
navLinks.forEach(link => {
33-
link.addEventListener('click', e => {
34-
e.preventDefault();
35-
const section = link.dataset.section;
36-
activateSection(section);
37-
history.pushState(null, '', `#${section}`);
38-
39-
// Close sidebar on mobile
40-
if (window.innerWidth <= 900) {
41-
sidebar.classList.remove('open');
42-
}
43-
});
33+
link.addEventListener('click', e => {
34+
e.preventDefault();
35+
const section = link.dataset.section;
36+
activateSection(section);
37+
history.pushState(null, '', `#${section}`);
38+
39+
// Close sidebar on mobile
40+
if (window.innerWidth <= 900) {
41+
sidebar.classList.remove('open');
42+
}
43+
});
4444
});
4545

4646
// Handle hash on load
4747
function loadFromHash() {
48-
const hash = window.location.hash.replace('#', '');
49-
if (hash && document.getElementById(hash)) {
50-
activateSection(hash);
51-
} else {
52-
activateSection('overview');
53-
}
48+
const hash = window.location.hash.replace('#', '');
49+
if (hash && document.getElementById(hash)) {
50+
activateSection(hash);
51+
} else {
52+
activateSection('overview');
53+
}
5454
}
5555

5656
window.addEventListener('hashchange', loadFromHash);
@@ -59,53 +59,53 @@ loadFromHash();
5959
// ── Mobile menu ───────────────────────────────────────────────────────────────
6060

6161
menuBtn.addEventListener('click', () => {
62-
sidebar.classList.toggle('open');
62+
sidebar.classList.toggle('open');
6363
});
6464

6565
// Close sidebar when clicking outside on mobile
6666
document.addEventListener('click', e => {
67-
if (window.innerWidth <= 900 &&
68-
!sidebar.contains(e.target) &&
69-
e.target !== menuBtn) {
70-
sidebar.classList.remove('open');
71-
}
67+
if (window.innerWidth <= 900 &&
68+
!sidebar.contains(e.target) &&
69+
e.target !== menuBtn) {
70+
sidebar.classList.remove('open');
71+
}
7272
});
7373

7474
// ── Keyboard navigation ───────────────────────────────────────────────────────
7575

7676
const sectionIds = Array.from(sections).map(s => s.id);
7777

7878
document.addEventListener('keydown', e => {
79-
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
79+
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return;
8080

81-
const current = sectionIds.findIndex(id =>
81+
const current = sectionIds.findIndex(id =>
8282
document.getElementById(id).classList.contains('active')
83-
);
84-
85-
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
86-
e.preventDefault();
87-
const next = sectionIds[(current + 1) % sectionIds.length];
88-
activateSection(next);
89-
history.pushState(null, '', `#${next}`);
90-
}
91-
92-
if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
93-
e.preventDefault();
94-
const prev = sectionIds[(current - 1 + sectionIds.length) % sectionIds.length];
95-
activateSection(prev);
96-
history.pushState(null, '', `#${prev}`);
97-
}
83+
);
84+
85+
if (e.key === 'ArrowRight' || e.key === 'ArrowDown') {
86+
e.preventDefault();
87+
const next = sectionIds[(current + 1) % sectionIds.length];
88+
activateSection(next);
89+
history.pushState(null, '', `#${next}`);
90+
}
91+
92+
if (e.key === 'ArrowLeft' || e.key === 'ArrowUp') {
93+
e.preventDefault();
94+
const prev = sectionIds[(current - 1 + sectionIds.length) % sectionIds.length];
95+
activateSection(prev);
96+
history.pushState(null, '', `#${prev}`);
97+
}
9898
});
9999

100100
// ── Copy code blocks ──────────────────────────────────────────────────────────
101101

102102
document.querySelectorAll('.code-block').forEach(block => {
103-
const wrapper = document.createElement('div');
104-
wrapper.style.cssText = 'position:relative';
103+
const wrapper = document.createElement('div');
104+
wrapper.style.cssText = 'position:relative';
105105

106-
const btn = document.createElement('button');
107-
btn.textContent = 'COPY';
108-
btn.style.cssText = `
106+
const btn = document.createElement('button');
107+
btn.textContent = 'COPY';
108+
btn.style.cssText = `
109109
position: absolute;
110110
top: 8px;
111111
right: 8px;
@@ -118,35 +118,35 @@ document.querySelectorAll('.code-block').forEach(block => {
118118
padding: 3px 8px;
119119
cursor: pointer;
120120
transition: all 0.15s;
121-
`;
122-
123-
btn.addEventListener('mouseenter', () => {
124-
btn.style.color = '#00e855';
125-
btn.style.borderColor = '#00e855';
126-
});
127-
btn.addEventListener('mouseleave', () => {
121+
`;
122+
123+
btn.addEventListener('mouseenter', () => {
124+
btn.style.color = '#2a90ff';
125+
btn.style.borderColor = '#2a90ff';
126+
});
127+
btn.addEventListener('mouseleave', () => {
128+
btn.style.color = '#4a5e78';
129+
btn.style.borderColor = '#18253a';
130+
});
131+
132+
btn.addEventListener('click', () => {
133+
navigator.clipboard.writeText(block.textContent.trim()).then(() => {
134+
const orig = btn.textContent;
135+
btn.textContent = 'COPIED!';
136+
btn.style.color = '#2a90ff';
137+
setTimeout(() => {
138+
btn.textContent = orig;
128139
btn.style.color = '#4a5e78';
129-
btn.style.borderColor = '#18253a';
140+
}, 1800);
141+
}).catch(() => {
142+
btn.textContent = 'ERR';
143+
setTimeout(() => { btn.textContent = 'COPY'; }, 1500);
130144
});
145+
});
131146

132-
btn.addEventListener('click', () => {
133-
navigator.clipboard.writeText(block.textContent.trim()).then(() => {
134-
const orig = btn.textContent;
135-
btn.textContent = 'COPIED!';
136-
btn.style.color = '#00e855';
137-
setTimeout(() => {
138-
btn.textContent = orig;
139-
btn.style.color = '#4a5e78';
140-
}, 1800);
141-
}).catch(() => {
142-
btn.textContent = 'ERR';
143-
setTimeout(() => { btn.textContent = 'COPY'; }, 1500);
144-
});
145-
});
146-
147-
block.parentNode.insertBefore(wrapper, block);
148-
wrapper.appendChild(block);
149-
wrapper.appendChild(btn);
147+
block.parentNode.insertBefore(wrapper, block);
148+
wrapper.appendChild(block);
149+
wrapper.appendChild(btn);
150150
});
151151

152152
// ── Search ────────────────────────────────────────────────────────────────────
@@ -156,13 +156,13 @@ let searchBuf = '';
156156
let searchTimer = null;
157157

158158
document.addEventListener('keypress', e => {
159-
if (e.target.tagName === 'INPUT') return;
160-
if (e.key === '/') {
161-
e.preventDefault();
162-
// Could open a modal — for now just highlight first nav link
163-
navLinks[0] && navLinks[0].focus();
164-
return;
165-
}
159+
if (e.target.tagName === 'INPUT') return;
160+
if (e.key === '/') {
161+
e.preventDefault();
162+
// Could open a modal — for now just highlight first nav link
163+
navLinks[0] && navLinks[0].focus();
164+
return;
165+
}
166166
});
167167

168168
// ── Active link highlight on scroll (single-page feel) ───────────────────────
@@ -173,18 +173,10 @@ document.addEventListener('keypress', e => {
173173
// ── Ambient star animation on logo dot ───────────────────────────────────────
174174

175175
const dot = document.querySelector('.logo-dot');
176-
let dotHue = 120;
177176

178-
setInterval(() => {
179-
dotHue = (dotHue + 1) % 360;
180-
// Keep it in green range (100-160)
181-
const h = 100 + (dotHue % 60);
182-
dot.style.background = `hsl(${h}, 100%, 55%)`;
183-
dot.style.boxShadow = `0 0 8px hsl(${h}, 100%, 55%)`;
184-
}, 80);
185177

186178
// ── Console easter egg ────────────────────────────────────────────────────────
187179

188-
console.log('%cHACKEROS GAMES DOCS', 'color:#00e855;font-family:monospace;font-size:18px;font-weight:bold');
180+
console.log('%cHACKEROS GAMES DOCS', 'color:#2a90ff;font-family:monospace;font-size:18px;font-weight:bold');
189181
console.log('%cv0.7.0 // TAURI 2 + REACT 18 + RUST', 'color:#4a5e78;font-family:monospace;font-size:11px');
190182
console.log('%cSECURE CONNECTION ESTABLISHED', 'color:#2a90ff;font-family:monospace;font-size:10px');

0 commit comments

Comments
 (0)