44 lines
No EOL
1.5 KiB
JavaScript
44 lines
No EOL
1.5 KiB
JavaScript
const input = document.querySelector('footer > .i > input')
|
|
const hints = document.querySelector('.hints')
|
|
var inputed_room = ''
|
|
|
|
input.addEventListener('focus', (e) => {
|
|
const fixed = `height: ${map.clientHeight}px !important;`
|
|
document.querySelector('#map').style = fixed
|
|
document.querySelector('#map > #wr').style = fixed
|
|
})
|
|
|
|
input.addEventListener('input', (e) => {
|
|
console.log(e.target.value)
|
|
inputed_room = e.target.value.toLowerCase()
|
|
if (inputed_room.length > 0) {
|
|
try {hints.classList.add('a')} catch {}
|
|
const out = fdata.results(inputed_room)
|
|
if (out.length == 0) {
|
|
Telegram.WebApp.HapticFeedback.notificationOccurred('error')
|
|
return hints.innerHTML = `<span>Результатов нет</span>`
|
|
}
|
|
hints.innerHTML = out.map(e => `<span onclick="find('${e.r}', ${e.f})">${e.r}</span>`).join('')
|
|
console.log(inputed_room)
|
|
|
|
} else {
|
|
try {hints.classList.remove('a')} catch {}
|
|
hints.innerHTML = ''
|
|
}
|
|
})
|
|
|
|
const sleep = ms => new Promise(r => setTimeout(r, ms));
|
|
|
|
const find = async (room_name, floor) => {
|
|
console.log(room_name, floor)
|
|
input.value = ''
|
|
input.placeholder = room_name
|
|
hints.innerHTML = ''
|
|
try {hints.classList.remove('a')} catch {}
|
|
if (!room_name.includes('Туал')) {
|
|
fswitch(floor)
|
|
await sleep(450)
|
|
}
|
|
Telegram.WebApp.HapticFeedback.notificationOccurred('success')
|
|
highlight(room_name)
|
|
} |