-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
36 lines (31 loc) · 1.04 KB
/
Copy pathscript.js
File metadata and controls
36 lines (31 loc) · 1.04 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
const buttons = document.querySelectorAll('.menu-btn');
const helpBtn = document.getElementById('help-btn');
const passwordText = document.getElementById('password-text');
let currentIndex = 0;
if (buttons.length > 0) {
buttons[currentIndex].focus();
}
document.addEventListener('keydown', (e) => {
if (e.keyCode === 38) {
currentIndex = (currentIndex > 0) ? currentIndex - 1 : buttons.length - 1;
buttons[currentIndex].focus();
} else if (e.keyCode === 40) {
currentIndex = (currentIndex < buttons.length - 1) ? currentIndex + 1 : 0;
buttons[currentIndex].focus();
} else if (e.keyCode === 461 || e.key === 'GoBack') {
window.close();
}
});
helpBtn.addEventListener('click', () => {
passwordText.classList.toggle('show-text');
});
buttons.forEach(btn => {
btn.addEventListener('click', () => {
const uri = btn.getAttribute('data-luna');
const params = btn.getAttribute('data-params');
if (window.PalmServiceBridge) {
const bridge = new PalmServiceBridge();
bridge.call(uri, params);
}
});
});