From c8ac1b899f7a79898b3ec84157db642051e8e1ae Mon Sep 17 00:00:00 2001 From: metamuffin Date: Sun, 9 Oct 2022 18:59:23 +0200 Subject: onbeforeunload --- client-web/source/index.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'client-web/source/index.ts') diff --git a/client-web/source/index.ts b/client-web/source/index.ts index be44c57..c16fa23 100644 --- a/client-web/source/index.ts +++ b/client-web/source/index.ts @@ -40,7 +40,14 @@ window.onhashchange = () => { // TODO might just destroy room object and create a new one, but cleanup probably wont work. lets reload instead window.location.reload() } +window.onbeforeunload = ev => { + if (r.local_user.resources.size != 0 && PREFS.enable_onbeforeunload) { + ev.preventDefault() + return ev.returnValue = "You have local resources shared. Really quit?" + } +} +let r: Room; export async function main() { log("*", "starting up") document.body.querySelectorAll("p").forEach(e => e.remove()) @@ -54,7 +61,7 @@ export async function main() { if (PREFS.warn_redirect) log({ scope: "crypto", warn: true }, "You were redirected from the old URL format. The server knows the room name now - e2ee is insecure!") const conn = await (new SignalingConnection().connect(room_name)) - const r = new Room(conn) + r = new Room(conn) setup_keybinds(r) r.on_ready = () => { -- cgit v1.2.3-70-g09d2