-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathscript.js
More file actions
55 lines (40 loc) · 1.93 KB
/
script.js
File metadata and controls
55 lines (40 loc) · 1.93 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
// MSA Core Scripts
// Handles global interactions and keyboard shortcuts for all pages
document.addEventListener('DOMContentLoaded', () => {
console.log('MSA Core Systems: ONLINE 🚀');
// --- Global Keyboard Shortcuts ---
document.addEventListener('keydown', (e) => {
const inputs = {
hero: document.getElementById('hero-ticker'), // index.html
dash: document.getElementById('ticker-input'), // dashboard.html
compA: document.getElementById('ticker-a'), // compare.html (Input A)
compB: document.getElementById('ticker-b') // compare.html (Input B)
};
let targetInput = inputs.dash || inputs.hero;
if (inputs.compA && inputs.compB) {
if (inputs.compA.value.trim() !== '' && inputs.compB.value.trim() === '') {
targetInput = inputs.compB;
} else {
targetInput = inputs.compA;
}
}
if (!targetInput) return;
const activeTag = document.activeElement.tagName;
if (e.key === '/' && activeTag !== 'INPUT' && activeTag !== 'TEXTAREA') {
e.preventDefault();
targetInput.focus();
if (targetInput === inputs.hero || targetInput === inputs.compA || targetInput === inputs.compB) {
targetInput.parentElement.classList.add('ring-2', 'ring-bull', 'ring-opacity-50');
setTimeout(() => targetInput.parentElement.classList.remove('ring-2', 'ring-bull', 'ring-opacity-50'), 200);
}
else if (targetInput === inputs.dash) {
targetInput.classList.add('bg-bull/10');
setTimeout(() => targetInput.classList.remove('bg-bull/10'), 200);
}
}
// --- Shortcut 2: Press "Esc" to Blur (Unfocus) ---
if (e.key === 'Escape') {
document.activeElement.blur();
}
});
});