From d937491545a5d7eb145c5c288985a33f56dba2c2 Mon Sep 17 00:00:00 2001 From: mappu Date: Sun, 5 Feb 2017 20:57:38 +1300 Subject: [PATCH] client: add warning popup if closing the tab while the connection is still open --- client/dcwebui.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/client/dcwebui.js b/client/dcwebui.js index 8d57042..e31a702 100644 --- a/client/dcwebui.js +++ b/client/dcwebui.js @@ -974,6 +974,16 @@ window.onload = function() { usermenu.hide(); }; + window.onbeforeunload = function (e) { + if (hub_state === STATE_ACTIVE) { + // n.b. recent Firefox / Chrome don't display the custom message here. + var confirmationMessage = "Still connected to the hub \"" + hub_hubname + "\".\nAre you sure you want to close?"; + e.returnValue = confirmationMessage; + return confirmationMessage; + } + // else: ignore + }; + timestamp_format_index = persistence_get("timestamps", 0); desktop_notifications_enabled = persistence_get("popups");