First go on the web based playlist editor. This is just a quick hack.

Adds a new tab 'playlist' in the html interface.
This commit is contained in:
Anders Betnér 2005-03-06 00:16:58 +00:00
parent 2dff79abb8
commit 1dd266c228
3 changed files with 202 additions and 1 deletions

View File

@ -6,9 +6,10 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="mt-daapd.css" />
@ispage status.html:<meta http-equiv="refresh" content="10" />:@
@ispage playlist.html:<script type="text/javascript" src="playlist.js"></script>:@
</head>
<body>
<body @ispage playlist.html:onload="init()":@>
<div>
<!-- <h1>.: m t - d a a p d :.</h1> -->
@ -23,6 +24,7 @@
<a href="index.html" class="@ispage index.html:selected:plain@">Home</a>
<a href="config.html" class="@ispage config.html:selected:plain@">Config</a>
<a href="status.html" class="@ispage status.html:selected:plain@">Status</a>
<a href="playlist.html" class="@ispage playlist.html:selected:plain@">Playlist</a>
<a href="feedback.html" class="@ispage feedback.html:selected:plain@">Feedback</a>
<a href="thanks.html" class="@ispage thanks.html:selected:plain@">Thanks</a>
</div>
@ -38,6 +40,7 @@
<table class="columns">
<tbody>
<tr>
@ispage playlist.html:<!--:@
<td class="left">
<div class="box">
<h5>Links</h5>
@ -93,6 +96,7 @@
</td>
@ispage playlist.html:-->:@
<td class="main">
<div class="document">
<div>

54
admin-root/playlist.html Normal file
View File

@ -0,0 +1,54 @@
@include hdr.html@
<h1>Playlist</h1>
<table>
<tr>
<td valign="top">
Source<br />
<select id="source" name="select" size="20">
<option value="1">Library</option>
</select>
</td>
<td valign="top">
<table id="browse">
<tr>
<td>
Genre<br />
<select id="genre" name="select" size="10">
<option value="1">All genres</option>
</select>
</td>
<td>
Artist<br />
<select id="artist" name="select" size="10">
<option value="1">All artists</option>
</select>
</td>
<td>
Album<br />
<select id="album" name="select" size="10">
<option value="1">All albums</option>
</select>
</td>
</tr>
</table>
<div class="stx" style="break: both;">
<table id="songs" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<th>Song</th>
<th>Time</th>
<th>Artist</th>
<th>Album</th>
<th>Genre</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</td>
</tr>
</table>
@include ftr.html@

143
admin-root/playlist.js Normal file
View File

@ -0,0 +1,143 @@
/*
* $Id$
* Javascript for playlist.html
*
* Copyright (C) 2005 Anders Betnér (andbe611@users.sourceforge.net)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
var g_req;
var baseUrl = window.location.toString();
baseUrl = baseUrl.substr(0,baseUrl.length-13);
function createRequest() {
// All browsers but IE
g_req = false;
if (window.XMLHttpRequest) {
g_req = new XMLHttpRequest();
// MS IE
} else if (window.ActiveXObject) {
g_req = new ActiveXObject("Microsoft.XMLHTTP");
}
}
function init() {
// 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);
}
function addOptions(el,xmldoc) {
items = xmldoc.getElementsByTagName('dmap.listingitem');
for (i=0; i<items.length; i++) {
option = document.createElement('option');
option.setAttribute('value',items[i].firstChild.nodeValue);
option.appendChild(document.createTextNode(items[i].textContent));
el.appendChild(option);
}
}
function addPlaylists(el,xmldoc) {
//items = xmldoc.getElementsByTagName('dmap.listingitem');
list = xmldoc.childNodes[0].childNodes[4];
// Start on 1 since the first node is the name of the daap server
for (i=1; i < list.childNodes.length; i++) {
option = document.createElement('option');
listNumber = list.childNodes[i].childNodes[0].textContent;
listName = list.childNodes[i].childNodes[2].textContent;
option.appendChild(document.createTextNode(listName));
option.setAttribute('value',listNumber);
el.appendChild(option);
}
}
function playlistSelect(event) {
table = document.getElementById('songs');
tableBody = removeRows(table);
playlistNumber = document.getElementById('source').value;
browse = document.getElementById('browse');
if (1 == playlistNumber) {
browse.style.display = 'block';
} else {
browse.style.display = 'none';
}
g_req.open('get',baseUrl + 'databases/1/containers/' + playlistNumber +
'/items?meta=dmap.itemname,daap.songalbum,daap.songartist,daap.songgenre,daap.songtime&output=xml',false);
g_req.send(null);
items = g_req.responseXML.getElementsByTagName('dmap.listingitem');
for (i=0; i < items.length; i++) {
song = items[i].getElementsByTagName('dmap.itemname').item(0).textContent;
time = ''; //items[i].getElementsByTagName('daap.songtime').item(0).textContent;
artist = items[i].getElementsByTagName('daap.songartist').item(0).textContent;
album = items[i].getElementsByTagName('daap.songalbum').item(0).textContent;
genre = items[i].getElementsByTagName('daap.songgenre').item(0).textContent;
addRow(tableBody,song,time,artist,album,genre);
}
}
function addRow(tbody,song,time,artist,album,genre) {
row = document.createElement("tr");
cell = document.createElement("td");
cell.appendChild(document.createTextNode(song));
row.appendChild(cell);
cell = document.createElement("td");
cell.appendChild(document.createTextNode(time));
row.appendChild(cell);
cell = document.createElement("td");
cell.appendChild(document.createTextNode(artist));
row.appendChild(cell);
cell = document.createElement("td");
cell.appendChild(document.createTextNode(album));
row.appendChild(cell);
cell = document.createElement("td");
cell.appendChild(document.createTextNode(genre));
row.appendChild(cell);
tbody.appendChild(row);
}
function removeRows(table) {
tableBody = table.getElementsByTagName('tbody').item(0);
table.removeChild(tableBody);
tableBody = document.createElement('tbody');
table.appendChild(tableBody);
return tableBody;
}