Perfect history for the search
This commit is contained in:
parent
9bd99b7bd9
commit
7b685076c6
@ -24,6 +24,11 @@ var soundtrackSearchResults: HTMLElement
|
|||||||
var userSearchResults: HTMLElement
|
var userSearchResults: HTMLElement
|
||||||
var companySearchResults: HTMLElement
|
var companySearchResults: HTMLElement
|
||||||
|
|
||||||
|
// Fetch options
|
||||||
|
const fetchOptions: RequestInit = {
|
||||||
|
credentials: "same-origin"
|
||||||
|
}
|
||||||
|
|
||||||
// Search
|
// Search
|
||||||
export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: KeyboardEvent) {
|
export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: KeyboardEvent) {
|
||||||
if(e.ctrlKey || e.altKey) {
|
if(e.ctrlKey || e.altKey) {
|
||||||
@ -48,11 +53,11 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: Ke
|
|||||||
correctResponseRendered.forum = false
|
correctResponseRendered.forum = false
|
||||||
correctResponseRendered.soundtrack = false
|
correctResponseRendered.soundtrack = false
|
||||||
correctResponseRendered.user = false
|
correctResponseRendered.user = false
|
||||||
|
correctResponseRendered.company = false
|
||||||
|
|
||||||
// Set browser URL
|
// Set browser URL
|
||||||
let url = "/search/" + term
|
let url = "/search/" + term
|
||||||
document.title = "Search: " + term
|
document.title = "Search: " + term
|
||||||
history.replaceState(url, document.title, url)
|
|
||||||
arn.app.currentPath = url
|
arn.app.currentPath = url
|
||||||
|
|
||||||
// Unmount mountables to improve visual responsiveness on key press
|
// Unmount mountables to improve visual responsiveness on key press
|
||||||
@ -76,6 +81,10 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: Ke
|
|||||||
|
|
||||||
arn.app.content.innerHTML = ""
|
arn.app.content.innerHTML = ""
|
||||||
arn.app.content.appendChild(searchPage)
|
arn.app.content.appendChild(searchPage)
|
||||||
|
|
||||||
|
history.pushState(url, document.title, url)
|
||||||
|
} else {
|
||||||
|
history.replaceState(url, document.title, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!animeSearchResults) {
|
if(!animeSearchResults) {
|
||||||
@ -96,10 +105,6 @@ export async function search(arn: AnimeNotifier, search: HTMLInputElement, e: Ke
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchOptions: RequestInit = {
|
|
||||||
credentials: "same-origin"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start searching
|
// Start searching
|
||||||
fetch("/_/anime-search/" + term, fetchOptions)
|
fetch("/_/anime-search/" + term, fetchOptions)
|
||||||
.then(showResponseInElement(arn, url, "anime", animeSearchResults))
|
.then(showResponseInElement(arn, url, "anime", animeSearchResults))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user