diff --git a/admin-root/hdr.html b/admin-root/hdr.html index d744f8fb..e077bc5c 100644 --- a/admin-root/hdr.html +++ b/admin-root/hdr.html @@ -10,15 +10,14 @@ - +@ispage playlist.html:
 mt-daap logo
Version @VERSION@
- +@ispage playlist.html:-->:@
Home @@ -89,10 +88,10 @@
- + - + diff --git a/admin-root/mt-daapd.css b/admin-root/mt-daapd.css index d269c62a..c50aacd0 100644 --- a/admin-root/mt-daapd.css +++ b/admin-root/mt-daapd.css @@ -933,10 +933,48 @@ table.calendar td.todaynoevent { border: 2px solid #FFA500; } +.odd { + background-color: #ffffff; + border-top: 0px; + border-bottom: 0px; +} +.even { + background-color: #edf3fe; + border-top: 0px; + border-bottom: 0px; +} +.mytbody { + height: 300px; + overflow: auto; + font: icon; !important +} +#browse { + font: icon; !important +} +.mytable { + /* The default table for document listings. Contains name, document types, modification times etc in a file-browser-like fashion */ + border-collapse: collapse; + border-left: 1px solid #8CACBB; + border-bottom: 1px solid #8CACBB; + font-size: 80%; + margin: 1em 0em 1em 0em; + clear: both; +} - - - +.mytable th { + background: #DEE7EC; + border-top: 1px solid #8CACBB; + border-bottom: 1px solid #8CACBB; + border-right: 1px solid #8CACBB; + color: Black; + font-weight: normal; + padding: 0em 1em 0em 1em; + text-transform: lowercase; + white-space: nowrap; +} +.mytable td { + padding-left: 2px; +} /* */ diff --git a/admin-root/playlist.html b/admin-root/playlist.html index e3bff04c..3bb1e396 100644 --- a/admin-root/playlist.html +++ b/admin-root/playlist.html @@ -1,5 +1,4 @@ @include hdr.html@ -

Playlist

@@ -10,31 +9,32 @@ +
Genre
Artist
Album
-
- +
+
@@ -44,7 +44,8 @@ Album
- + +
Song Genre
diff --git a/admin-root/playlist.js b/admin-root/playlist.js index 8b8250b7..683b22c7 100644 --- a/admin-root/playlist.js +++ b/admin-root/playlist.js @@ -18,56 +18,213 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/* Detta script finns att hämta på http://www.jojoxx.net och + får användas fritt så länge som dessa rader står kvar. */ +function DataDumper(obj,n,prefix){ + var str=""; prefix=(prefix)?prefix:""; n=(n)?n+1:1; var ind=""; for(var i=0;i"); } + } else { + for(var i in obj){ str+=DataDumper(obj[i],n,i+"=>"); } + } + str+=ind+"]\n"; + } + return str; +} var g_req; +var g_requestor; +var g_selectedGenres = Array(); +var g_selectedAlbums = Array(); +var g_selectedArtists = Array(); + var baseUrl = window.location.toString(); baseUrl = baseUrl.substr(0,baseUrl.length-13); +String.prototype.myEncodeURI = function () { + s = encodeURI(this); + s = s.replace(/\'/,'%27'); + return s.replace(/&/,'%26'); +}; -function createRequest() { +Requestor = function(baseUrl) { + this.baseUrl = baseUrl; + this.que = Array(); // All browsers but IE - g_req = false; - if (window.XMLHttpRequest) { - g_req = new XMLHttpRequest(); + g_req = false; + if (window.XMLHttpRequest) { + g_req = new XMLHttpRequest(); // MS IE - } else if (window.ActiveXObject) { - g_req = new ActiveXObject("Microsoft.XMLHTTP"); + } else if (window.ActiveXObject) { + g_req = new ActiveXObject("Microsoft.XMLHTTP"); + } + this.busy = false; + +}; +Requestor.prototype.addRequest = function(url) { + if (this.busy) { + this.que.push(url); + } else { + this._openRequest(url); + } +}; + +Requestor.prototype._openRequest = function(url) { + this.busy = true; + if (url.search(/\?/)> -1) { + url += '&output=xml'; + } else { + url += '?output=xml'; } + g_req.open('get',this.baseUrl+url,true); + g_req.onreadystatechange = Requestor_handleRequest; + g_req.send(null); +}; +Requestor_handleRequest = function() { + if (4 == g_req.readyState) { + // readystate 4 means the whole document is loaded + if (200 == g_req.status) { + // Only try to parse the response if we got + // ok from the server + xmldoc = g_req.responseXML; + if ('daap.databaseplaylists' == xmldoc.firstChild.nodeName) { + el = document.getElementById('source'); + addPlaylists(el,xmldoc); + } else if ('daap.databasebrowse' == xmldoc.firstChild.nodeName) { + // Ok we have response from a browse query + + switch (xmldoc.firstChild.childNodes[3].nodeName) { + case 'daap.browsegenrelisting': + el = document.getElementById('genre'); + addOptions(el,'genre',xmldoc); + break; + case 'daap.browseartistlisting': + el = document.getElementById('artist'); + addOptions(el,'artist',xmldoc); + break; + case 'daap.browsealbumlisting': + el = document.getElementById('album'); + addOptions(el,'album',xmldoc); + break; + default: + // We got something else back... + } + } else if ('daap.databasesongs' == xmldoc.firstChild.nodeName) { + // Songlist + addSongs(xmldoc); + } + } + if (g_requestor.que.length > 0) { + // Just to be able to pull ourseves up by our boot straps + window.setTimeout(Requestor_queChecker,5); + return; + } else { + g_requestor.busy = false; + } + } +}; +function Requestor_queChecker() { + if (url = g_requestor.que.shift()) { + g_requestor._openRequest(url); + } } + function init() { + g_requestor = new Requestor(baseUrl); + g_requestor.addRequest('databases/1/containers'); + g_requestor.addRequest('databases/1/browse/genres'); + g_requestor.addRequest('databases/1/browse/artists'); + g_requestor.addRequest('databases/1/browse/albums'); + el = document.getElementById('source'); + el.addEventListener('change',playlistSelect,true); + + el = document.getElementById('genre'); + el.addEventListener('change',genreSelect,true); + + el = document.getElementById('artist'); + el.addEventListener('change',artistSelect,true); + +//###FIXME album select +return; // get playlists - createRequest(); - //alert(baseUrl+'databases/1/browse/genres?output=xml'); + g_req.open('get',baseUrl+'databases/1/containers?output=xml',false); g_req.send(null); - el = document.getElementById('source'); - addPlaylists(el,g_req.responseXML); - el.addEventListener('change',playlistSelect,true); + g_req.open('get',baseUrl+'databases/1/browse/genres?output=xml',false); g_req.send(null); - el = document.getElementById('genre'); - addOptions(el,g_req.responseXML); - + g_req.open('get',baseUrl+'databases/1/browse/artists?output=xml',false); g_req.send(null); - el = document.getElementById('artist'); - addOptions(el,g_req.responseXML); - + g_req.open('get',baseUrl+'databases/1/browse/albums?output=xml',false); g_req.send(null); el = document.getElementById('album'); - addOptions(el,g_req.responseXML); + addOptions(el,'album',g_req.responseXML); } -function addOptions(el,xmldoc) { +function addOptions(el,label,xmldoc) { + while(el.hasChildNodes()) { + el.removeChild(el.firstChild); + } + itemCnt = xmldoc.getElementsByTagName('dmap.specifiedtotalcount').item(0).textContent; + if (parseInt(itemCnt) > 1) { + plural = 's'; + } else { + plural = ''; + } + option = document.createElement('option'); + option.value = '1'; + option.selected = false; + option.appendChild(document.createTextNode('All ('+itemCnt+' '+label +plural+')')); + el.appendChild(option); + items = xmldoc.getElementsByTagName('dmap.listingitem'); for (i=0; i