Skip to content

Commit 0e86196

Browse files
refactor: split common.js into modular files (music, settings, breadcrumb, sounds)
1 parent 065679b commit 0e86196

5 files changed

Lines changed: 428 additions & 464 deletions

File tree

public/js/breadcrumb.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// breadcrumb.js — Auto-inject navigation breadcrumb on mission pages
2+
const PAGE_NAMES = {
3+
'phishing': 'Phishing Detective',
4+
'social': 'Social Engineering',
5+
'smishing': 'Smishing Simulator',
6+
'ai': 'AI Crime Lab',
7+
'malware': 'Malware Escape',
8+
'password': 'Password Lab',
9+
'darkweb': 'Dark Web Market',
10+
'daily': 'Daily Challenge',
11+
'incident': 'Incident Response',
12+
'creator': 'Mission Creator',
13+
'wiki': 'Cyber-Wiki',
14+
'login': 'Login',
15+
'index': 'Hub',
16+
'hub': 'Hub'
17+
};
18+
19+
function injectBreadcrumb() {
20+
if (document.getElementById('breadcrumb')) return;
21+
22+
const path = window.location.pathname.split('/').pop().replace('.html', '') || 'index';
23+
if (['hub', 'index', 'login', ''].includes(path)) return;
24+
25+
const crumb = document.createElement('div');
26+
crumb.id = 'breadcrumb';
27+
crumb.style.cssText = 'font-size:11px;color:#666;margin-bottom:10px;text-align:left;';
28+
crumb.innerHTML = `<a href="hub.html" style="color:#666;text-decoration:none;" onmouseover="this.style.color='var(--neon-cyan)'" onmouseout="this.style.color='#666'">Hub</a> <span style="color:#444;">›</span> <span style="color:var(--neon-cyan);">${PAGE_NAMES[path] || path}</span>`;
29+
30+
const container = document.querySelector('.container');
31+
if (!container) return;
32+
const backBtn = container.querySelector('.back-btn');
33+
if (backBtn) backBtn.insertAdjacentElement('afterend', crumb);
34+
else container.prepend(crumb);
35+
}
36+
37+
document.addEventListener('DOMContentLoaded', injectBreadcrumb);

0 commit comments

Comments
 (0)