Improved search

This commit is contained in:
2017-07-02 17:51:17 +02:00
parent 464a6ec26b
commit 326c4161aa
7 changed files with 43 additions and 14 deletions

View File

@ -145,10 +145,10 @@ export function search(arn: AnimeNotifier, search: HTMLInputElement, e: Keyboard
let term = search.value
if(!window.location.pathname.startsWith("/search/")) {
history.pushState("search", null, "/search/" + term)
} else {
if(window.location.pathname.startsWith("/search/")) {
history.replaceState("search", null, "/search/" + term)
} else {
history.pushState("search", null, "/search/" + term)
}
if(!term || term.length < 2) {
@ -165,7 +165,7 @@ export function search(arn: AnimeNotifier, search: HTMLInputElement, e: Keyboard
arn.app.content.appendChild(results)
}
arn.app.get("/_/search/" + encodeURI(term))
arn.app.get("/_/search/" + term)
.then(html => {
if(!search.value) {
return

View File

@ -199,13 +199,23 @@ export class AnimeNotifier {
}
modifyDelayed(className: string, func: (element: HTMLElement) => void) {
let mountableTypes = {
general: 0
}
const delay = 20
const maxDelay = 500
const maxDelay = 1000
let time = 0
for(let element of findAll(className)) {
time += delay
let type = element.dataset.mountableType || "general"
if(type in mountableTypes) {
time = mountableTypes[element.dataset.mountableType] += delay
} else {
time = mountableTypes[element.dataset.mountableType] = 0
}
if(time > maxDelay) {
func(element)