Commit 73f4f828 authored by Siong-Ui Te's avatar Siong-Ui Te

update input func

parent 89fa4542
......@@ -4,8 +4,10 @@ import (
. "github.com/siongui/godom"
)
var input *Object
// https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key
func modalInputKeyupEventHandler(key string) {
func inputKeyupEventHandler(key string) {
switch key {
case "ArrowUp", "Up":
println("ArrowUp")
......@@ -18,9 +20,13 @@ func modalInputKeyupEventHandler(key string) {
}
}
func SetInputValue(v string) {
input.SetValue(v)
}
func SetupModalInput(selector string) {
input := Document.QuerySelector(selector)
input = Document.QuerySelector(selector)
input.AddEventListener("keyup", func(e Event) {
modalInputKeyupEventHandler(e.Key())
inputKeyupEventHandler(e.Key())
})
}
......@@ -27,7 +27,7 @@ func closeModal() {
//SetModalBody("")
SetModalWords("")
SetModalContent("")
SetModalInputValue("")
SetInputValue("")
HideModalInput()
}
......@@ -39,10 +39,6 @@ func SetModalWords(html string) {
Document.GetElementById("words").SetInnerHTML(html)
}
func SetModalInputValue(v string) {
Document.GetElementById("modal-input").SetValue(v)
}
func HideModalInput() {
Document.GetElementById("modal-input-toggle").Set("checked", false)
}
......
......@@ -53,7 +53,7 @@ func possibleWordClickHandler(word string) {
}
func possibleWordMouseenterHandler(i int, word string) {
SetModalInputValue(word)
SetInputValue(word)
//println(i)
}
......@@ -100,7 +100,7 @@ func showPossibleWords(word string) {
prefix := FindLongestPrefixWithNonZeroSuggestedWords(word)
SetModalWords(GetPossibleWordsHtml(prefix, dicmgr.GetSuggestedWords(prefix, 7)))
SetModalInputValue(prefix)
SetInputValue(prefix)
ShowModalInput()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment