mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-07 23:44:17 +09:00
35 lines
811 B
JavaScript
Vendored
35 lines
811 B
JavaScript
Vendored
const focusSearch = event => {
|
|
const searchInput = document.querySelector('input[name="q"]');
|
|
if (searchInput) {
|
|
event.preventDefault();
|
|
searchInput.focus();
|
|
}
|
|
};
|
|
|
|
const openFirstNonHiddenItem = event => {
|
|
if (event.target !== document.querySelector('input[name="q"]')) {
|
|
return;
|
|
}
|
|
|
|
const item = document.querySelector('#sortable section.item-container:not([style="display: none;"]) a');
|
|
|
|
if ('href' in item) {
|
|
event.preventDefault();
|
|
window.open(item.href);
|
|
}
|
|
};
|
|
|
|
const KEY_BINDINGS = {
|
|
'/': focusSearch,
|
|
'Enter': openFirstNonHiddenItem
|
|
};
|
|
|
|
document.addEventListener('keydown', function (event) {
|
|
try {
|
|
if (event.key in KEY_BINDINGS) {
|
|
KEY_BINDINGS[event.key](event);
|
|
}
|
|
} catch (e) {
|
|
|
|
}
|
|
}); |