From 8d8ae473baa36c3956355c0a2bf700da62b554d9 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Tue, 28 Jun 2022 05:18:38 +0400 Subject: [PATCH] Now audio volume is stored in localStorage. --- web/assets/js/main.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/web/assets/js/main.js b/web/assets/js/main.js index c6c39ef..f752a09 100644 --- a/web/assets/js/main.js +++ b/web/assets/js/main.js @@ -6,7 +6,9 @@ const image_formats = ["jpg", "jpeg", "gif", "png", "bmp", "webp"]; const overlay = document.getElementById("overlay"); let g_scale = 1; -let g_volume = 0.5; + +if (localStorage.getItem('audio_volume') == null) + localStorage['audio_volume'] = 0.5; function mousescroll(e) { e.preventDefault(); @@ -15,7 +17,7 @@ function mousescroll(e) { } function onvolumechange(e) { - g_volume = e.target.volume; + localStorage['audio_volume'] = e.target.volume; } const ext_filter = (ext, pathname) => pathname.toLowerCase().endsWith(ext); @@ -28,7 +30,7 @@ function to_overlay(eltyp, pathname) { if (eltyp !== "img") { el.autoplay = el.controls = true; el.addEventListener("volumechange", onvolumechange); - el.volume = g_volume; + el.volume = localStorage['audio_volume']; } el.src = pathname; overlay.appendChild(el);