1
0

Now audio volume is stored in localStorage.

This commit is contained in:
Alexander Andreev 2022-06-28 05:18:38 +04:00
parent 60f662109e
commit 8d8ae473ba
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -6,7 +6,9 @@ const image_formats = ["jpg", "jpeg", "gif", "png", "bmp", "webp"];
const overlay = document.getElementById("overlay"); const overlay = document.getElementById("overlay");
let g_scale = 1; let g_scale = 1;
let g_volume = 0.5;
if (localStorage.getItem('audio_volume') == null)
localStorage['audio_volume'] = 0.5;
function mousescroll(e) { function mousescroll(e) {
e.preventDefault(); e.preventDefault();
@ -15,7 +17,7 @@ function mousescroll(e) {
} }
function onvolumechange(e) { function onvolumechange(e) {
g_volume = e.target.volume; localStorage['audio_volume'] = e.target.volume;
} }
const ext_filter = (ext, pathname) => pathname.toLowerCase().endsWith(ext); const ext_filter = (ext, pathname) => pathname.toLowerCase().endsWith(ext);
@ -28,7 +30,7 @@ function to_overlay(eltyp, pathname) {
if (eltyp !== "img") { if (eltyp !== "img") {
el.autoplay = el.controls = true; el.autoplay = el.controls = true;
el.addEventListener("volumechange", onvolumechange); el.addEventListener("volumechange", onvolumechange);
el.volume = g_volume; el.volume = localStorage['audio_volume'];
} }
el.src = pathname; el.src = pathname;
overlay.appendChild(el); overlay.appendChild(el);