<hr/>
<div id="prefs">
<p><label>
- <input type="number" size="4" min="500" max="5000" step="100" id="double-tap-duration"/>
+ <span data-l10n="text-content">(fast)</span><input type="range" min="0" max="0" id="double-tap-duration"/><span data-l10n="text-content">(slow)</span>
+ <br/>
<span data-l10n="text-content">Double tap duration</span>
- <span data-l10n="text-content">(ms)</span>
</label></p>
<p><label>
- <input type="number" size="4" min="500" max="5000" step="100" id="flash-light-duration"/>
+ <span data-l10n="text-content">(fast)</span><input type="range" min="0" max="0" id="flash-light-duration"/><span data-l10n="text-content">(slow)</span>
+ <br/>
<span data-l10n="text-content">Flash light duration</span>
- <span data-l10n="text-content">(ms)</span>
</label></p>
<p><label>
<input type="text" size="6" id="flash-light-color"/>
setConf("ENABLE_EVENT_SOURCE", true);
setConf("MAX_WEBSOCKET_ERRORS", 1);
setConf("APP_PATH", "");
- setConf("DOUBLE_TAP_DURATION", 1000);
- setConf("FLASH_LIGHT_DURATION", 1500);
+ setConf("DOUBLE_TAP_DURATIONS", [650, 1100, 1800, 3000, 5000]);
+ setConf("FLASH_LIGHT_DURATIONS", [800, 1600, 3200]);
setConf("FLASH_LIGHT_COLOR", "#E3E");
const _ = (window.libD && libD.l10n) ? libD.l10n() : function (s) {
}
}
+ function translateDuration(x, values) {
+ if (x < 0) {
+ return null;
+ } else if (x < values.length) {
+ return values[Math.floor(x)];
+ } else {
+ for (let i = 0; i < values.length; i++) {
+ if (x <= values[i]) {
+ return i;
+ }
+ }
+ return values.length - 1;
+ }
+ }
+
function initLaserPointer() {
if (!Object.prototype.hasOwnProperty.call(localStorage, "doubleTapDuration")) {
- localStorage.doubleTapDuration = Conf.DOUBLE_TAP_DURATION;
+ localStorage.doubleTapDuration = Conf.DOUBLE_TAP_DURATIONS[Math.floor(Conf.DOUBLE_TAP_DURATIONS.length / 2)];
}
const doubleTapDuration = document.getElementById("double-tap-duration");
if (doubleTapDuration) {
- doubleTapDuration.value = Number(localStorage.doubleTapDuration);
+ doubleTapDuration.max = Conf.DOUBLE_TAP_DURATIONS.length - 1;
+ doubleTapDuration.value = translateDuration(localStorage.doubleTapDuration, Conf.DOUBLE_TAP_DURATIONS);
doubleTapDuration.onchange = function () {
localStorage.doubleTapDuration =
- document.getElementById("double-tap-duration").value;
+ translateDuration(document.getElementById("double-tap-duration").value, Conf.DOUBLE_TAP_DURATIONS);
};
}
if (!Object.prototype.hasOwnProperty.call(localStorage, "flashLightDuration")) {
- localStorage.flashLightDuration = Conf.FLASH_LIGHT_DURATION;
+ localStorage.flashLightDuration = Conf.FLASH_LIGHT_DURATIONS[Math.floor(Conf.FLASH_LIGHT_DURATIONS.length / 2)];
}
const flashLightDuration = document.getElementById("flash-light-duration");
if (flashLightDuration) {
- flashLightDuration.value = Number(localStorage.flashLightDuration);
+ flashLightDuration.max = Conf.FLASH_LIGHT_DURATIONS.length - 1;
+ flashLightDuration.value = translateDuration(localStorage.flashLightDuration, Conf.FLASH_LIGHT_DURATIONS);
flashLightDuration.onchange = function () {
localStorage.flashLightDuration =
- document.getElementById("flash-light-duration").value;
+ translateDuration(document.getElementById("flash-light-duration").value, Conf.FLASH_LIGHT_DURATIONS);
};
}