Add warning before leaving /new/thread
This commit is contained in:
parent
e840075bbf
commit
54472ae927
@ -200,6 +200,9 @@ export class AnimeNotifier {
|
|||||||
this.notificationManager.update()
|
this.notificationManager.update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bind unload event
|
||||||
|
window.addEventListener("beforeunload", this.onBeforeUnload.bind(this))
|
||||||
|
|
||||||
// Download popular anime titles for the search
|
// Download popular anime titles for the search
|
||||||
// let response = await fetch("/api/popular/anime/titles/500")
|
// let response = await fetch("/api/popular/anime/titles/500")
|
||||||
// let titles = await response.json()
|
// let titles = await response.json()
|
||||||
@ -218,6 +221,20 @@ export class AnimeNotifier {
|
|||||||
// search.setAttribute("list", titleList.id)
|
// search.setAttribute("list", titleList.id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async onBeforeUnload(e: BeforeUnloadEvent) {
|
||||||
|
let message = undefined
|
||||||
|
|
||||||
|
// Prevent closing tab on new thread page
|
||||||
|
if(this.app.currentPath === "/new/thread" && document.activeElement.tagName === "TEXTAREA" && (document.activeElement as HTMLTextAreaElement).value.length > 20) {
|
||||||
|
message = "You have unsaved changes on the current page. Are you sure you want to leave?"
|
||||||
|
}
|
||||||
|
|
||||||
|
if(message) {
|
||||||
|
e.returnValue = message
|
||||||
|
return message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dragAndDrop() {
|
dragAndDrop() {
|
||||||
for(let element of findAll("inventory-slot")) {
|
for(let element of findAll("inventory-slot")) {
|
||||||
// Skip elements that have their event listeners attached already
|
// Skip elements that have their event listeners attached already
|
||||||
|
Loading…
Reference in New Issue
Block a user