From e88892642b29606d3c57dff6d5d43608827ee759 Mon Sep 17 00:00:00 2001 From: Griatch Date: Sat, 21 May 2016 11:58:46 +0200 Subject: [PATCH] Added a close warning event to the webclient. --- .../web/webclient/static/webclient/js/webclient_gui.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/evennia/web/webclient/static/webclient/js/webclient_gui.js b/evennia/web/webclient/static/webclient/js/webclient_gui.js index d3ddd37dd..55d18d4c3 100644 --- a/evennia/web/webclient/static/webclient/js/webclient_gui.js +++ b/evennia/web/webclient/static/webclient/js/webclient_gui.js @@ -233,6 +233,12 @@ function onDefault(cmdname, args, kwargs) { mwin.scrollTop(mwin[0].scrollHeight); } +// Ask if user really wants to exit session when closing +// the tab or reloading the page. Note: the message is not shown +// in Firefox, there it's a standard error. +function onBeforeUnload() { + return "You are about to leave the game. Please confirm."; +} // // Register Events @@ -269,7 +275,8 @@ $(document).ready(function() { // Handle pressing the send button $("#inputsend").bind("click", doSendText); // Event when closing window (have to have Evennia initialized) - $(window).bind("beforeunload", Evennia.connection.close); + $(window).bind("beforeunload", onBeforeUnload); + $(window).bind("unload", Evennia.connection.close); doWindowResize(); // set an idle timer to send idle every 3 minutes,