add. ime for real
This commit is contained in:
20
main.js
20
main.js
@@ -5,6 +5,19 @@ let searchDictionary = {};
|
||||
let header = null;
|
||||
let main = null;
|
||||
|
||||
let ime = null;
|
||||
|
||||
function toggleIME() {
|
||||
if (ime == null) {
|
||||
ime = new HeonianIME(header.querySelector("input"));
|
||||
header.querySelector("#search button").style.color = "var(--fg)";
|
||||
} else {
|
||||
ime.imeDetach();
|
||||
ime = null;
|
||||
header.querySelector("#search button").style.color = "var(--grey)";
|
||||
}
|
||||
}
|
||||
|
||||
function animateHeader(inout = false) {
|
||||
//todo: debounce this
|
||||
if (inout) {
|
||||
@@ -47,10 +60,14 @@ document.addEventListener("keydown", (e) => {
|
||||
if (!header.querySelector("input").matches(":focus") && !header.classList.contains("fullscreen")) {
|
||||
e.preventDefault();
|
||||
animateHeader(true);
|
||||
} else if (header.querySelector("input").matches(":focus") && ime != null) {
|
||||
toggleIME();
|
||||
} else if (header.querySelector("input").matches(":focus")) {
|
||||
header.querySelector("input").value = "";
|
||||
}
|
||||
}
|
||||
if (e.keyCode === 13) {
|
||||
if (header.querySelector("input").matches(":focus")) {
|
||||
if (header.querySelector("input").matches(":focus") && ime == null) {
|
||||
//search
|
||||
e.preventDefault();
|
||||
if (header.classList.contains("fullscreen")) {
|
||||
@@ -262,5 +279,6 @@ function doSearch() {
|
||||
window.onload = () => {
|
||||
header = document.querySelector("header");
|
||||
main = document.querySelector("main");
|
||||
header.querySelector("#search button").onclick = () => {toggleIME();};
|
||||
loadDictionary();
|
||||
}
|
||||
Reference in New Issue
Block a user