From: Laurent Mazet Date: Wed, 12 Aug 2020 19:56:17 +0000 (+0200) Subject: make durations (double tap and flash light) configurable X-Git-Url: https://secure.softndesign.org/git/?a=commitdiff_plain;h=a0df72a53a0534dad250f95b238a42ac739d9b0a;p=trivabble.git make durations (double tap and flash light) configurable --- diff --git a/public/index.html b/public/index.html index 4811d72..30f3f9f 100644 --- a/public/index.html +++ b/public/index.html @@ -50,10 +50,23 @@ Configuration window × -
+

+
+
+

+

+
diff --git a/public/trivabble.css b/public/trivabble.css index 4aae8bd..3042316 100644 --- a/public/trivabble.css +++ b/public/trivabble.css @@ -447,11 +447,11 @@ td.blink { } } -#prefs-sound { +#prefs { margin:1ex 0 0 0; } -#prefs-sound p { +#prefs p { margin:0; padding:0; font-size:small @@ -461,7 +461,7 @@ td.blink { font-size:small; } -#prefs-sound input, #prefs-sound label { +#prefs input, #prefs label { vertical-align:middle } diff --git a/public/trivabble.js b/public/trivabble.js index b71c3f9..5d0be42 100644 --- a/public/trivabble.js +++ b/public/trivabble.js @@ -1448,7 +1448,7 @@ return; } if (e.type === "touchstart") { - if ((highlightTile.id !== id) || (Date.now() - highlightTile.date > Conf.DOUBLE_TAP_DURATION)) { + if ((highlightTile.id !== id) || (Date.now() - highlightTile.date > localStorage.doubleTapDuration)) { highlightTile.id = id; highlightTile.date = Date.now(); return; @@ -1481,23 +1481,23 @@ setTimeout( function (x) { x.classList.remove("highlight"); - }, Conf.FLASH_LIGHT_DURATION*1/3, placeholder); + }, localStorage.flashLightDuration*1/3, placeholder); setTimeout( function (x) { x.classList.add("highlight"); - }, Conf.FLASH_LIGHT_DURATION*1/2, placeholder); + }, localStorage.flashLightDuration*1/2, placeholder); setTimeout( function (x) { x.classList.remove("highlight"); - }, Conf.FLASH_LIGHT_DURATION*2/3, placeholder); + }, localStorage.flashLightDuration*2/3, placeholder); setTimeout( function (x) { x.classList.add("highlight"); - }, Conf.FLASH_LIGHT_DURATION*5/6, placeholder); + }, localStorage.flashLightDuration*5/6, placeholder); setTimeout( function (x) { x.classList.remove("highlight"); - }, Conf.FLASH_LIGHT_DURATION*1, placeholder); + }, localStorage.flashLightDuration*1, placeholder); } function initChat() { @@ -1580,6 +1580,33 @@ } } + function initLaserPointer() { + + if (!Object.prototype.hasOwnProperty.call(localStorage, "doubleTapDuration")) { + localStorage.doubleTapDuration = Conf.DOUBLE_TAP_DURATION; + } + const doubleTapDuration = document.getElementById("double-tap-duration"); + if (doubleTapDuration) { + doubleTapDuration.value = localStorage.doubleTapDuration; + doubleTapDuration.onchange = function () { + localStorage.doubleTapDuration = + document.getElementById("double-tap-duration").value; + } + } + + if (!Object.prototype.hasOwnProperty.call(localStorage, "flashLightDuration")) { + localStorage.flashLightDuration = Conf.FLASH_LIGHT_DURATION; + } + const flashLightDuration = document.getElementById("flash-light-duration"); + if (flashLightDuration) { + flashLightDuration.value = localStorage.flashLightDuration; + flashLightDuration.onchange = function () { + localStorage.flashLightDuration = + document.getElementById("flash-light-duration").value; + } + } + } + function repromptName(f) { if (localStorage.trivabblePlayerName && localStorage.trivabblePlayerName.trim()) { f(); @@ -1799,6 +1826,7 @@ initChat(); initGame(); initSound(); + initLaserPointer(); }; trivabble.l10nError = trivabble.run;