X-Git-Url: https://git.rvb.name/mpd-lua.git/blobdiff_plain/7e7b0d2b9ec3b3c62370de418cf9b0a4a667b1fb..HEAD:/ajax/mpd.js
diff --git a/ajax/mpd.js b/ajax/mpd.js
deleted file mode 100644
index 9cd2667..0000000
--- a/ajax/mpd.js
+++ /dev/null
@@ -1,392 +0,0 @@
-urlbase="mpd.lua?"
-
-function GetFilename(url)
-{
- if (url)
- return url.split('/').pop().split('#')[0].split('?')[0];
-}
-
-function EscapeStr(str) {
- res = str.replace(/'/g,"\\'");
- return res;
-}
-
-function RefreshPageStatus() {
-
- var req = new XMLHttpRequest();
-
- req.onreadystatechange = function () {
- if (this.readyState != 4 || this.status != 200) return;
- var returnedData = JSON.parse(this.responseText);
- nowPlaying = GetFilename(returnedData['current_playing'])
- document.title='MPD Player: '+nowPlaying;
- nowPlaying = (1+Number(returnedData['song'])) + '/' + returnedData['playlistlength'] + ' '+nowPlaying;
- if (returnedData['state']=='stop') {
- nowPlaying = '' + nowPlaying+ ''
- }
- document.getElementById('nowplaying_content').innerHTML=nowPlaying;
- if (returnedData["state"]=="play") {
- document.getElementById('playpausebutton').innerHTML="";
- } else {
- document.getElementById('playpausebutton').innerHTML="";
- }
- if (returnedData["repeat"]=="1") {
- document.getElementById('repeatstate').innerHTML="";
- } else {
- document.getElementById('repeatstate').innerHTML="";
- }
- document.getElementById('volume_total').innerHTML="
";
- };
-
- req.open("GET", urlbase+"status", true);
- req.send();
-
-
-}
-
-function RefreshPlaylist() {
-
-var req = new XMLHttpRequest();
-
-req.onreadystatechange = function () {
- if (this.readyState != 4 || this.status != 200) return;
- var returnedData = JSON.parse(this.responseText);
-
- var text = "\
-
\
-
\
- \
- | Title | Controls | \
-
";
-
- var even = 0;
- for (var key in returnedData) {
- var rec=returnedData[key];
- var name=GetFilename(rec["name"]);
- var id=rec["id"];
-
- if (even) {
- evText="itemEven";
- } else {
- evText="itemOdd";
- };
-
- even = ! even;
-
- text = text + "\
- \
- | \
- \
- \
- "+name+"\
- | \
- \
- \
- | \
- \
- \
- | \
- \
- \
- | \
-
";
- }
-
- text = text + "
\
-
\
- ";
-
- document.getElementById('playlist').innerHTML=text;
-};
-
-req.open("GET", urlbase+"playlist", true);
-req.send();
-
-}
-
-function EditPlayList(dir) {
-
-var req = new XMLHttpRequest();
-
-req.onreadystatechange = function () {
- if (this.readyState != 4 || this.status != 200) return;
- var returnedData = JSON.parse(this.responseText);
-
- var text = "\
-
\
- ";
- document.getElementById('playlist').innerHTML=text;
-};
-
-if (!dir) { dir = ''; };
-
-req.open("GET", urlbase+"lists|edit|"+dir, true);
-req.send();
-
-}
-
-function LoadPlayList() {
-
-var req = new XMLHttpRequest();
-
-req.onreadystatechange = function () {
- if (this.readyState != 4 || this.status != 200) return;
- var returnedData = JSON.parse(this.responseText);
- text="\
-
\
-
\
- \
- | Name | Controls | \
-
";
-
- var even = 0;
- for (var key in returnedData) {
- var name=returnedData[key];
-
- if (even) {
- evText="itemEven";
- } else {
- evText="itemOdd";
- };
-
- even = ! even;
-
- text = text + "\
- | \
- "+name+" | \
- | \
-
";
- }
-
- text=text+"
";
-
- document.getElementById('playlist').innerHTML=text;
-};
-
-req.open("GET", urlbase+"lists|load", true);
-req.send();
-
-}
-
-function SavePlayList() {
-
-var name=window.prompt('List name','');
-
-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", urlbase+"lists|save|"+name, true);
-req.send();
-
-}
-
-function DelPlayList(item) {
-
-var req = new XMLHttpRequest();
-
-req.onreadystatechange = function () {
- if (this.readyState != 4 || this.status != 200) return;
- RefreshPageStatus();
- LoadPlayList();
-};
-
-req.open("GET", urlbase+"lists|delete|"+item, true);
-req.send();
-
-}
-
-function RefreshPageContent() {
-
- RefreshPageStatus();
- RefreshPlaylist();
-
-}
-
-function Command(cmd) {
-
-var req = new XMLHttpRequest();
-
-req.onreadystatechange = function () {
- if (this.readyState != 4 || this.status != 200) return;
- RefreshPageStatus();
-};
-
-req.open("GET", urlbase+cmd, true);
-req.send();
-
-}
-
-function PlaylistCommand(cmd,item) {
-
-var req = new XMLHttpRequest();
-
-req.onreadystatechange = function () {
- if (this.readyState != 4 || this.status != 200) return;
- RefreshPageContent();
-};
-
-req.open("GET", urlbase+"cpl|"+cmd+"|"+item, true);
-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", urlbase+"cpl|"+cmd+"|"+item, 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", urlbase+"lists|"+cmd+"|"+item, 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", urlbase+"lists|"+cmd+"|"+item, true);
-req.send();
-
-}
-
-setInterval(RefreshPageStatus, 10000);