X-Git-Url: https://git.rvb.name/mpd-web.git/blobdiff_plain/e05325ceb8b812fc40b7c3475c59602dde9efdae..40bb089389b428c836f544e2d94a48dfae415229:/ajax/mpd.js diff --git a/ajax/mpd.js b/ajax/mpd.js index 5d64a92..3717603 100644 --- a/ajax/mpd.js +++ b/ajax/mpd.js @@ -6,7 +6,6 @@ var req = new XMLHttpRequest(); req.onreadystatechange = function () { if (this.readyState != 4 || this.status != 200) return; document.getElementById('nowplaying_content').innerHTML=this.responseText; - document.title='MPD Player: '+this.responseText; }; req.open("GET", "ajax/trackinfo.php", true); @@ -14,6 +13,19 @@ req.send(); } +function RefreshTitle() { + +var req = new XMLHttpRequest(); + +req.onreadystatechange = function () { + if (this.readyState != 4 || this.status != 200) return; + document.title='MPD Player: '+this.responseText; +}; + +req.open("GET", "ajax/trackname.php", true); +req.send(); +} + function RefreshPlayerState() { var req = new XMLHttpRequest(); @@ -66,6 +78,7 @@ req.send(); function RefreshPageStatus() { + RefreshTitle(); RefreshNowPlaying(); RefreshPlayerState(); RefreshRepeatState(); @@ -103,6 +116,55 @@ req.send(); } +function LoadPlayList() { + +var req = new XMLHttpRequest(); + +req.onreadystatechange = function () { + if (this.readyState != 4 || this.status != 200) return; + document.getElementById('playlist').innerHTML=this.responseText; +}; + +req.open("GET", "ajax/playlists.php", true); +req.send(); + +} + +function SavePlayList() { + +var name=window.prompt('Имя списка',''); + +var req = new XMLHttpRequest(); + +req.onreadystatechange = function () { + if (this.readyState != 4 || this.status != 200) return; + if (this.responseText != 'OK') { + window.alert(this.responseText); + } +}; + +req.open("GET", "ajax/save.php?item="+name, true); +req.send(); + +} + +function DelPlayList(item) { + +var req = new XMLHttpRequest(); + +//if (! window.alert("Удалить список "+item+"?")) return; + +req.onreadystatechange = function () { + if (this.readyState != 4 || this.status != 200) return; + RefreshPageStatus(); + LoadPlayList(); +}; + +req.open("GET", "ajax/playlist-command.php?task=dellist&item="+item, true); +req.send(); + +} + function RefreshPageContent() { RefreshPageStatus(); @@ -138,10 +200,43 @@ req.send(); } +function PlaylistCommandRefStatus(cmd,item) { + +var req = new XMLHttpRequest(); + +req.onreadystatechange = function () { + if (this.readyState != 4 || this.status != 200) return; + RefreshPageStatus(); +}; + +req.open("GET", "ajax/playlist-command.php?item="+item+"&task="+cmd, true); +req.send(); + +} + function PlaylistEditCommand(cmd,item) { var req = new XMLHttpRequest(); +req.onreadystatechange = function () { + if (this.readyState != 4 || this.status != 200) return; + RefreshPageStatus(); +}; + +req.open("GET", "ajax/playlist-command.php?item="+item+"&task="+cmd, true); +req.send(); + +} + +function PlaylistEditCommandRefFull(cmd,item) { + +var req = new XMLHttpRequest(); + +req.onreadystatechange = function () { + if (this.readyState != 4 || this.status != 200) return; + RefreshPageContent(); +}; + req.open("GET", "ajax/playlist-command.php?item="+item+"&task="+cmd, true); req.send(); @@ -189,10 +284,15 @@ params=selected.map(function(el) { return 'itemlist[]=' + encodeURIComponent(el); }).join('&'); +req.onreadystatechange = function () { + if (this.readyState != 4 || this.status != 200) return; + RefreshPageStatus(); +}; + req.open("POST", "ajax/playlist-command.php?dir="+dir+"&task="+cmd, true); req.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); req.send(params); } -// setInterval(RefreshPageStatus, 5000); +setInterval(RefreshPageStatus, 10000);