From cb54b022a9d21a9c648d77021274cb4c0fcbd614 Mon Sep 17 00:00:00 2001 From: NeKz Date: Sun, 9 Jun 2024 23:29:26 +0200 Subject: [PATCH] Preserve show inputs state --- src/server/app/assets/js/module.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/server/app/assets/js/module.js b/src/server/app/assets/js/module.js index eebc92b..438beb1 100644 --- a/src/server/app/assets/js/module.js +++ b/src/server/app/assets/js/module.js @@ -651,11 +651,18 @@ if (location.pathname.startsWith('/videos/') && location.pathname.length === 19) const btnPadding = 2; const fps = 60; // TODO: fetch this from video (60 should work for default autorender presets) - const shouldDraw = document.getElementById('ihud-checkbox'); + /** @type {HTMLInputElement} */ + const ihudCheckbox = document.getElementById('ihud-checkbox'); /** @type {HTMLCanvasElement} */ const canvas = document.getElementById('inputs'); const ctx = canvas.getContext('2d'); + ihudCheckbox.checked = localStorage.getItem('show-inputs') === 'true'; + + ihudCheckbox.addEventListener('change', (ev) => { + ev.target && localStorage.setItem('show-inputs', ev.target.checked.toString()); + }); + fetch(`/storage/inputs/${location.pathname.slice(location.pathname.lastIndexOf('/') + 1)}`) .then((res) => { if (!res.ok) { @@ -709,7 +716,7 @@ if (location.pathname.startsWith('/videos/') && location.pathname.length === 19) ctx.clearRect(0, 0, canvas.width, canvas.height); - if (!shouldDraw.checked) { + if (!ihudCheckbox.checked) { video.requestVideoFrameCallback(drawInputs); return; }