diff options
Diffstat (limited to 'static/index.js')
| -rw-r--r-- | static/index.js | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/static/index.js b/static/index.js index 6cda2f7..237386c 100644 --- a/static/index.js +++ b/static/index.js @@ -1,3 +1,4 @@ +let isInfoShown = true; function GetSongs() { fetch("/api/getSongs").then(r => r.json().then(body => { @@ -11,24 +12,37 @@ function SetRandomSong() { console.log(player); console.log(body); player.src = "/api/getSong?name=" + encodeURI(body.Name); - player.play(); - document.getElementById("Artist").innerHTML = "Artist: " + body.Meta.Name; - document.getElementById("Title").innerHTML = "Title: " + body.Meta.Author; + document.getElementById("Artist").innerHTML = "Artist: " + body.Meta.Author; + document.getElementById("Title").innerHTML = "Title: " + body.Meta.Name; document.getElementById("Album").innerHTML = "Album: " + body.Meta.Album; document.getElementById("Start").innerHTML = "Start: " + body.Start + "s"; + player.play(); + document.getElementById("Status").innerHTML = "Playing"; })); } function Pause() { const player = document.getElementById("mainAudio"); player.pause(); - console.log("Paused audio"); + document.getElementById("Status").innerHTML = "Paused"; } function Resume() { const player = document.getElementById("mainAudio"); player.play(); - console.log("Paused audio"); + document.getElementById("Status").innerHTML = "Playing"; +} + +function ToggleInfo() { + if (isInfoShown) { + document.getElementById("InfoBlock").style.display = 'none'; + document.getElementById("ToggleBtn").innerHTML = 'Show info'; + isInfoShown = false; + } else { + document.getElementById("InfoBlock").style.display = 'block'; + document.getElementById("ToggleBtn").innerHTML = 'Hide info'; + isInfoShown = true; + } } |
