Use 'change' event for preset-list rather than 'click'
This lets the user select events with their keyboard.
This commit is contained in:
parent
ccd196dabc
commit
4bc3d7dcc1
|
@ -114,6 +114,7 @@ const searchboxaspresetname = () => {
|
||||||
let textbox = document.getElementById("searchbox");
|
let textbox = document.getElementById("searchbox");
|
||||||
textbox.setAttribute("placeholder", "New preset name…");
|
textbox.setAttribute("placeholder", "New preset name…");
|
||||||
deselectengines();
|
deselectengines();
|
||||||
|
document.getElementById("searchbox").focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
const resetsearchbox = (clearText = false) => {
|
const resetsearchbox = (clearText = false) => {
|
||||||
|
@ -146,7 +147,8 @@ const saveselection = () => {
|
||||||
savepreset(engineselection(), name);
|
savepreset(engineselection(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const onpresetselected = (value) => {
|
const onpresetselected = (event) => {
|
||||||
|
let value = document.getElementById("presets").value;
|
||||||
if (value != "newPreset")
|
if (value != "newPreset")
|
||||||
localStorage.setItem("defaultPreset", value);
|
localStorage.setItem("defaultPreset", value);
|
||||||
resetsearchbox();
|
resetsearchbox();
|
||||||
|
@ -157,8 +159,6 @@ const onpresetselected = (value) => {
|
||||||
searchboxaspresetname();
|
searchboxaspresetname();
|
||||||
else
|
else
|
||||||
enablepresetbyname(value);
|
enablepresetbyname(value);
|
||||||
|
|
||||||
document.getElementById("searchbox").focus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const removefromarray = (array, item) => {
|
const removefromarray = (array, item) => {
|
||||||
|
@ -181,6 +181,11 @@ document.getElementById("searchbox").addEventListener("keypress", key => {
|
||||||
if (event.key == "Enter") search();
|
if (event.key == "Enter") search();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
document.addEventListener("change", e => {
|
||||||
|
if (e.target.id == "presets")
|
||||||
|
onpresetselected();
|
||||||
|
})
|
||||||
|
|
||||||
document.addEventListener("click", e => {
|
document.addEventListener("click", e => {
|
||||||
if (e.target.classList.contains("search"))
|
if (e.target.classList.contains("search"))
|
||||||
search();
|
search();
|
||||||
|
@ -188,7 +193,4 @@ document.addEventListener("click", e => {
|
||||||
saveselection();
|
saveselection();
|
||||||
else if (e.target.classList.contains("remove"))
|
else if (e.target.classList.contains("remove"))
|
||||||
removecurrentpreset();
|
removecurrentpreset();
|
||||||
else if (e.target.tagName == "OPTION") {
|
|
||||||
onpresetselected(e.target.getAttribute("value"));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
Ŝarĝante…
Reference in New Issue