Skip to content

Commit

Permalink
Preserve show inputs state
Browse files Browse the repository at this point in the history
  • Loading branch information
NeKzor committed Jun 9, 2024
1 parent f51a8d4 commit cb54b02
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/server/app/assets/js/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit cb54b02

Please sign in to comment.