Improved forum navigation
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { Application } from "./Application"
|
||||
import { AnimeNotifier } from "./AnimeNotifier"
|
||||
import { Diff } from "./Diff"
|
||||
import { delay, findAll } from "./utils"
|
||||
|
||||
// Save new data from an input field
|
||||
export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaElement) {
|
||||
@ -53,6 +54,36 @@ export function save(arn: AnimeNotifier, input: HTMLInputElement | HTMLTextAreaE
|
||||
})
|
||||
}
|
||||
|
||||
// Diff
|
||||
export function diff(arn: AnimeNotifier, element: HTMLElement) {
|
||||
let url = element.dataset.url || (element as HTMLAnchorElement).getAttribute("href")
|
||||
let request = fetch("/_" + url).then(response => response.text())
|
||||
|
||||
history.pushState(url, null, url)
|
||||
arn.app.currentPath = url
|
||||
arn.app.markActiveLinks()
|
||||
arn.loading(true)
|
||||
arn.unmountMountables()
|
||||
|
||||
// for(let element of findAll("mountable")) {
|
||||
// element.classList.remove("mountable")
|
||||
// }
|
||||
|
||||
delay(300).then(() => {
|
||||
request
|
||||
.then(html => arn.app.setContent(html, true))
|
||||
.then(() => arn.app.markActiveLinks())
|
||||
// .then(() => {
|
||||
// for(let element of findAll("mountable")) {
|
||||
// element.classList.remove("mountable")
|
||||
// }
|
||||
// })
|
||||
.then(() => arn.app.emit("DOMContentLoaded"))
|
||||
.then(() => arn.loading(false))
|
||||
.catch(console.error)
|
||||
})
|
||||
}
|
||||
|
||||
// Search
|
||||
export function search(arn: AnimeNotifier, search: HTMLInputElement, e: KeyboardEvent) {
|
||||
if(e.ctrlKey || e.altKey) {
|
||||
|
Reference in New Issue
Block a user