|
|
|
@ -140,12 +140,21 @@ taginputs.forEach(function (tinput) {
|
|
|
|
|
// })
|
|
|
|
|
// }
|
|
|
|
|
let vals = suggest_input.value.split(' ')
|
|
|
|
|
console.log(vals)
|
|
|
|
|
// console.log(vals)
|
|
|
|
|
vals.forEach(tag => {
|
|
|
|
|
if (tag == '') return
|
|
|
|
|
add_selected(tag)
|
|
|
|
|
});
|
|
|
|
|
suggest_input.removeAttribute('value') // Disable prefill by browser
|
|
|
|
|
|
|
|
|
|
function select_suggestion(tagelement) {
|
|
|
|
|
add_selected(tagelement.dataset.tagname)
|
|
|
|
|
suggest_input.value = ''
|
|
|
|
|
render_suggestions([])
|
|
|
|
|
|
|
|
|
|
// yeeeeeeeet
|
|
|
|
|
setTimeout(() => suggest_input.focus(), 2)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function render_suggestions(data) { // 3 references
|
|
|
|
|
let drop = suggest_dropdown
|
|
|
|
@ -163,9 +172,7 @@ taginputs.forEach(function (tinput) {
|
|
|
|
|
let sugtag = create_suggestion_tag(el.content)
|
|
|
|
|
|
|
|
|
|
sugtag.addEventListener('click', (event) => {
|
|
|
|
|
add_selected(event.target.dataset.tagname)
|
|
|
|
|
sug_input.value = ''
|
|
|
|
|
render_suggestions([])
|
|
|
|
|
select_suggestion(event.target)
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
@ -195,15 +202,58 @@ taginputs.forEach(function (tinput) {
|
|
|
|
|
// fill suggestions
|
|
|
|
|
// console.log(data)
|
|
|
|
|
render_suggestions(data)
|
|
|
|
|
update_sug_selection('0')
|
|
|
|
|
})
|
|
|
|
|
}, 500)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// search_input.addEventListener('keypress', (event) => {
|
|
|
|
|
// if (event.keyCode == 13) {
|
|
|
|
|
// // event.preventDefault()
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
let sug_selected = 0
|
|
|
|
|
function update_sug_selection(move) {
|
|
|
|
|
let suggs = suggest_dropdown.querySelectorAll('a.tagsuggestion')
|
|
|
|
|
let last_selected = sug_selected
|
|
|
|
|
|
|
|
|
|
let subs = move.substring(0, 1)
|
|
|
|
|
if (subs == '+') {
|
|
|
|
|
sug_selected += parseInt(move.substring(1))
|
|
|
|
|
} else if (subs == '-') {
|
|
|
|
|
sug_selected -= parseInt(move.substring(1))
|
|
|
|
|
} else {
|
|
|
|
|
sug_selected = parseInt(move)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sug_selected = sug_selected%suggs.length
|
|
|
|
|
if (sug_selected < 0) sug_selected += suggs.length
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
suggs[last_selected].classList.remove('sug-sel')
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// console.log(error)
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
suggs[sug_selected].classList.add('sug-sel')
|
|
|
|
|
} catch (error) {
|
|
|
|
|
// console.log(error)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
suggest_input.addEventListener('keydown', (event) => {
|
|
|
|
|
// console.log(event)
|
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
|
if (suggest_input.value) {
|
|
|
|
|
select_suggestion(suggest_dropdown.querySelector('a.tagsuggestion.sug-sel'))
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (event.keyCode == 40 || (event.keyCode == 9 && !event.shiftKey)) {
|
|
|
|
|
update_sug_selection('+1')
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
if (event.keyCode == 38 || (event.keyCode == 9 && event.shiftKey)) {
|
|
|
|
|
update_sug_selection('-1')
|
|
|
|
|
event.preventDefault()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// search_input.addEventListener('blur', (event) => {
|
|
|
|
|
// if (event.explicitOriginalTarget != null) {
|
|
|
|
|
// classlist = event.explicitOriginalTarget.parentNode.classList
|
|
|
|
|