2 function RefreshNowPlaying() {
4 var req = new XMLHttpRequest();
6 req.onreadystatechange = function () {
7 if (this.readyState != 4 || this.status != 200) return;
8 document.getElementById('nowplaying_content').innerHTML=this.responseText;
9 document.title='MPD Player: '+this.responseText;
12 req.open("GET", "ajax/trackinfo.php", true);
17 function RefreshPlayerState() {
19 var req = new XMLHttpRequest();
21 req.onreadystatechange = function () {
22 if (this.readyState != 4 || this.status != 200) return;
23 if (this.responseText=="play") {
24 document.getElementById('playpausebutton').innerHTML="<span onclick=\"Command('pause')\"><img class=\"button\" src=\"images/pause.png\"></span>";
26 document.getElementById('playpausebutton').innerHTML="<span onclick=\"Command('play')\"><img class=\"button\" src=\"images/play.png\"></span>";
30 req.open("GET", "ajax/playerstate.php", true);
35 function RefreshRepeatState() {
37 var req = new XMLHttpRequest();
39 req.onreadystatechange = function () {
40 if (this.readyState != 4 || this.status != 200) return;
41 if (this.responseText=="1") {
42 document.getElementById('repeatstate').innerHTML="<img src=\"images/repeaton.png\"></a>";
44 document.getElementById('repeatstate').innerHTML="<img src=\"images/repeatoff.png\"></a>";
48 req.open("GET", "ajax/repeatstate.php", true);
53 function RefreshVolume() {
55 var req = new XMLHttpRequest();
57 req.onreadystatechange = function () {
58 if (this.readyState != 4 || this.status != 200) return;
59 document.getElementById('volume_total').innerHTML="<div id=\"volume_actual\" style=\"width:"+this.responseText+"%\">";
62 req.open("GET", "ajax/volume.php", true);
67 function RefreshPageStatus() {
76 function RefreshPlaylist() {
78 var req = new XMLHttpRequest();
80 req.onreadystatechange = function () {
81 if (this.readyState != 4 || this.status != 200) return;
82 document.getElementById('playlist').innerHTML=this.responseText;
85 req.open("GET", "ajax/playlist.php", true);
90 function EditPlayList(dir) {
92 var req = new XMLHttpRequest();
94 req.onreadystatechange = function () {
95 if (this.readyState != 4 || this.status != 200) return;
96 document.getElementById('playlist').innerHTML=this.responseText;
99 if (!dir) { dir = ''; };
101 req.open("GET", "ajax/editplaylist.php?dir="+dir, true);
106 function RefreshPageContent() {
113 function Command(cmd) {
115 var req = new XMLHttpRequest();
117 req.onreadystatechange = function () {
118 if (this.readyState != 4 || this.status != 200) return;
122 req.open("GET", "ajax/command.php?task="+cmd, true);
127 function PlaylistCommand(cmd,item) {
129 var req = new XMLHttpRequest();
131 req.onreadystatechange = function () {
132 if (this.readyState != 4 || this.status != 200) return;
133 RefreshPageContent();
136 req.open("GET", "ajax/playlist-command.php?item="+item+"&task="+cmd, true);
141 function PlaylistEditCommand(cmd,item) {
143 var req = new XMLHttpRequest();
145 req.open("GET", "ajax/playlist-command.php?item="+item+"&task="+cmd, true);
151 function PlaylistItemsCommand(cmd) {
153 var req = new XMLHttpRequest();
155 var selected = [].filter.call(document.getElementsByName('itemlist[]'), function(c) {
161 req.onreadystatechange = function () {
162 if (this.readyState != 4 || this.status != 200) return;
163 RefreshPageContent();
166 params=selected.map(function(el) {
167 //Map each field into a name=value string, make sure to properly escape!
168 return 'itemlist[]=' + encodeURIComponent(el);
171 req.open("POST", "ajax/playlist-command.php?task="+cmd, true);
172 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
177 function PlaylistEditItemsCommand(cmd,dir) {
179 var req = new XMLHttpRequest();
181 var selected = [].filter.call(document.getElementsByName('itemlist[]'), function(c) {
187 params=selected.map(function(el) {
188 //Map each field into a name=value string, make sure to properly escape!
189 return 'itemlist[]=' + encodeURIComponent(el);
192 req.open("POST", "ajax/playlist-command.php?dir="+dir+"&task="+cmd, true);
193 req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
198 // setInterval(RefreshPageStatus, 5000);