From 29d471c8eea0bcf5d23b9e63180e9f1b7089850c Mon Sep 17 00:00:00 2001 From: David Vazgenovich Shakaryan Date: Tue, 10 May 2022 16:56:15 -0700 Subject: web: add exit dialogue while match is active --- web/static/dartboat.js | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'web/static/dartboat.js') diff --git a/web/static/dartboat.js b/web/static/dartboat.js index aacb1bc..b2b8481 100644 --- a/web/static/dartboat.js +++ b/web/static/dartboat.js @@ -123,6 +123,17 @@ function storeOpt(opt, val) { localStorage.setItem(UTF8ToString(opt), UTF8ToString(val)); } +function prevDef(e) { + e.preventDefault(); +} + +function enableExitDialogue(enable) { + if (enable) + window.addEventListener('beforeunload', prevDef); + else + window.removeEventListener('beforeunload', prevDef); +} + function boatAfloat() { if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', () => _init()); -- cgit v1.2.3-70-g09d2