1
0

Further code shortening in main.js!

This commit is contained in:
Alexander Andreev 2023-08-22 16:50:27 +04:00
parent 790b08e22c
commit 8a5666743f
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -36,15 +36,15 @@ $("radio-update").addEventListener("click", () => {
setInterval(updateRadioStatus, 45000); setInterval(updateRadioStatus, 45000);
setInterval(updateLastPlayedSong, 45000); setInterval(updateLastPlayedSong, 45000);
const audio = document.getElementsByTagName("audio")[0];
audio.hidden = true;
const audio_src = audio.childNodes[0].src;
const volume = $("radio-volume"); const volume = $("radio-volume");
volume.addEventListener("input", e => { audio.volume = volume.value / 100.0;
audio.volume = parseFloat(e.target.value) / 100.0; });
const audio = document.getElementsByTagName("audio")[0]; volume.addEventListener("input", e => audio.volume = e.target.value / 100.0);
const audio_src = audio.childNodes[0].src;
audio.hidden = true;
audio.volume = parseFloat(volume.value) / 100.0;
audio.addEventListener("timeupdate", e => { audio.addEventListener("timeupdate", e => {
const ct = e.target.currentTime; const ct = e.target.currentTime;
@ -53,14 +53,9 @@ audio.addEventListener("timeupdate", e => {
const h = Math.floor(ct / 3600); const h = Math.floor(ct / 3600);
$("radio-elapsed").textContent = `${h}h ${m}m ${s}s`; }); $("radio-elapsed").textContent = `${h}h ${m}m ${s}s`; });
$("player").style.display = $("player").style.display = $("player").firstChild.style.display = "flex";
$("player").firstChild.style.display = "flex";
$("radio-play").addEventListener("click", e => { $("radio-play").addEventListener("click", e => {
if (audio.paused) { audio.paused ? (audio.src = audio_src) && audio.play() : audio.src = "";
audio.src = audio_src;
audio.play();
} else
audio.src = "";
e.target.style.maskImage = e.target.style.webkitMaskImage = audio.paused ? e.target.style.maskImage = e.target.style.webkitMaskImage = audio.paused ?
"url(/assets/img/play.svg)" : "url(/assets/img/stop.svg)"; }); "url(/assets/img/play.svg)" : "url(/assets/img/stop.svg)"; });