add. ime for real
This commit is contained in:
parent
9c513f8319
commit
57ea079eaf
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<script src="./heonian-ime/ime.js"></script>
|
||||||
<script src="./main.js"></script>
|
<script src="./main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
3
main.css
3
main.css
@ -101,6 +101,9 @@ header #search button {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
height: 2rem;
|
height: 2rem;
|
||||||
border-left: 1px solid var(--grey);
|
border-left: 1px solid var(--grey);
|
||||||
|
color: var(--grey);
|
||||||
|
transition: 0.3s color ease;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
header input {
|
header input {
|
||||||
|
20
main.js
20
main.js
@ -5,6 +5,19 @@ let searchDictionary = {};
|
|||||||
let header = null;
|
let header = null;
|
||||||
let main = 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) {
|
function animateHeader(inout = false) {
|
||||||
//todo: debounce this
|
//todo: debounce this
|
||||||
if (inout) {
|
if (inout) {
|
||||||
@ -47,10 +60,14 @@ document.addEventListener("keydown", (e) => {
|
|||||||
if (!header.querySelector("input").matches(":focus") && !header.classList.contains("fullscreen")) {
|
if (!header.querySelector("input").matches(":focus") && !header.classList.contains("fullscreen")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
animateHeader(true);
|
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 (e.keyCode === 13) {
|
||||||
if (header.querySelector("input").matches(":focus")) {
|
if (header.querySelector("input").matches(":focus") && ime == null) {
|
||||||
//search
|
//search
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (header.classList.contains("fullscreen")) {
|
if (header.classList.contains("fullscreen")) {
|
||||||
@ -262,5 +279,6 @@ function doSearch() {
|
|||||||
window.onload = () => {
|
window.onload = () => {
|
||||||
header = document.querySelector("header");
|
header = document.querySelector("header");
|
||||||
main = document.querySelector("main");
|
main = document.querySelector("main");
|
||||||
|
header.querySelector("#search button").onclick = () => {toggleIME();};
|
||||||
loadDictionary();
|
loadDictionary();
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user