From 92408d6f029108d635938f3acfea99f260f93b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 24 May 2020 14:47:15 +0200 Subject: [PATCH] MAPG-61 add onbeforeunload function to prevent accidental leave --- public/static/js/mapguesser.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public/static/js/mapguesser.js b/public/static/js/mapguesser.js index 0160819..7a4ada3 100644 --- a/public/static/js/mapguesser.js +++ b/public/static/js/mapguesser.js @@ -35,7 +35,7 @@ Core.loadPositionInfo(Core.realPosition); document.getElementById('currentRound').innerHTML = String(Core.rounds.length) + '/' + String(Core.NUMBER_OF_ROUNDS); - document.getElementById('currentScoreSum').innerHTML = String(Core.scoreSum) + '/' + String((Core.rounds.length-1) * Core.MAX_SCORE); + document.getElementById('currentScoreSum').innerHTML = String(Core.scoreSum) + '/' + String((Core.rounds.length - 1) * Core.MAX_SCORE); } else { Core.startNewRound(); @@ -286,7 +286,7 @@ fontFamily: 'Roboto', fontSize: '16px', fontWeight: '500', - text: String(i+1) + text: String(i + 1) }); round.realMarker.setVisible(true); round.guessMarker.setVisible(true); @@ -470,4 +470,9 @@ document.getElementById('startNewGameButton').onclick = function () { Core.startNewGame(); } + + window.onbeforeunload = function (e) { + e.preventDefault(); + e.returnValue = ''; + }; })();