diff options
author | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-10 16:56:15 -0700 |
---|---|---|
committer | David Vazgenovich Shakaryan <dvshakaryan@gmail.com> | 2022-05-10 16:56:15 -0700 |
commit | 29d471c8eea0bcf5d23b9e63180e9f1b7089850c (patch) | |
tree | 876e7ee19b520240ff0a578818200903fda9464d /web/static | |
parent | 99e7a11c25e704851cfbbaed64594acbbd752038 (diff) | |
download | dartboat-29d471c8eea0bcf5d23b9e63180e9f1b7089850c.tar.gz dartboat-29d471c8eea0bcf5d23b9e63180e9f1b7089850c.tar.xz |
web: add exit dialogue while match is active
Diffstat (limited to 'web/static')
-rw-r--r-- | web/static/dartboat.js | 11 |
1 files changed, 11 insertions, 0 deletions
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()); |