mirror of
https://github.com/owntone/owntone-server.git
synced 2025-02-26 04:49:18 -05:00
playlist.js: add static playlist works, can't add any items
to the playlist though
This commit is contained in:
parent
3697dbd0aa
commit
22649c0da3
@ -50,7 +50,7 @@
|
||||
</select><br />
|
||||
<input type="text" id="edit_playlist_name" value="" />
|
||||
<div id="busymsg" style="text-align:center;color:red; visibility: hidden;">Busy ...</div>
|
||||
<a href="javascript:add()">Add static playlist</a>
|
||||
<a href="javascript:EditPlaylistName.add();">Add static playlist</a>
|
||||
</div>
|
||||
<div id="genre_div">
|
||||
Genre<br />
|
||||
|
@ -20,17 +20,17 @@ function initPlaylist() {
|
||||
Field.clear('search');
|
||||
}
|
||||
var GlobalEvents = {
|
||||
_listeners: [],
|
||||
_clickListeners: [],
|
||||
click: function (e) {
|
||||
GlobalEvents._listeners.each(function (name) {
|
||||
GlobalEvents._clickListeners.each(function (name) {
|
||||
name.click(e);
|
||||
});
|
||||
},
|
||||
addListener: function (el) {
|
||||
this._listeners.push(el);
|
||||
addClickListener: function (el) {
|
||||
this._clickListeners.push(el);
|
||||
},
|
||||
removeListener: function (el) {
|
||||
this._listeners = this._listeners.findAll(function (element) {
|
||||
removeClickListener: function (el) {
|
||||
this._clickListeners = this._clickListeners.findAll(function (element) {
|
||||
return (element != el);
|
||||
});
|
||||
}
|
||||
@ -71,6 +71,11 @@ var EditPlaylistName = {
|
||||
EditPlaylistName.save();
|
||||
}
|
||||
},
|
||||
add: function () {
|
||||
var url = '/databases/1/containers/add?output=xml';
|
||||
url += '&org.mt-daapd.playlist-type=0&dmap.itemname=new%20playlist';
|
||||
new Ajax.Request(url ,{method: 'get',onComplete:EditPlaylistName.responseAdd});
|
||||
},
|
||||
save: function () {
|
||||
input = $('edit_playlist_name');
|
||||
var url = '/databases/1/containers/edit?output=xml';
|
||||
@ -83,20 +88,38 @@ var EditPlaylistName = {
|
||||
},
|
||||
show: function () {
|
||||
input = $('edit_playlist_name');
|
||||
input.style.top = RicoUtil.toDocumentPosition(el).y+ 'px';
|
||||
input.style.top = RicoUtil.toDocumentPosition(EditPlaylistName._getOptionElement()).y+ 'px';
|
||||
input.value = this.playlistName;
|
||||
input.style.display = 'block';
|
||||
Field.activate(input);
|
||||
GlobalEvents.addListener(this);
|
||||
GlobalEvents.addClickListener(this);
|
||||
},
|
||||
hide: function () {
|
||||
$('edit_playlist_name').style.display = 'none';
|
||||
EditPlaylistName.playlistId = '';
|
||||
GlobalEvents.removeListener(this);
|
||||
GlobalEvents.removeClickListener(this);
|
||||
},
|
||||
response: function (request) {
|
||||
// Check that the save gave response 200 OK
|
||||
},
|
||||
responseAdd: function(request) {
|
||||
var status = Element.textContent(request.responseXML.getElementsByTagName('dmap.status')[0]);
|
||||
if ('200' != status) {
|
||||
alert(status);
|
||||
alert('Something went wrong');
|
||||
return;
|
||||
}
|
||||
EditPlaylistName.playlistId = Element.textContent(request.responseXML.getElementsByTagName('dmap.itemid')[0]);
|
||||
EditPlaylistName.playlistName = 'new playlist';
|
||||
var o = document.createElement('option');
|
||||
o.value = EditPlaylistName.playlistId;
|
||||
o.text = EditPlaylistName.playlistName;
|
||||
$('static_playlists').appendChild(o);
|
||||
$('source').value = EditPlaylistName.playlistId;
|
||||
EditPlaylistName.show();
|
||||
Query.setSource(EditPlaylistName.playlistId);
|
||||
Query.send('genres');
|
||||
},
|
||||
click: function (e) {
|
||||
var x = Event.pointerX(e);
|
||||
var y = Event.pointerY(e);
|
||||
@ -139,17 +162,9 @@ var EventHandler = {
|
||||
},
|
||||
sourceChange: function (e) {
|
||||
EventHandler.sourceClickCount = [];
|
||||
Query.clearSelection('genres');
|
||||
Query.clearSelection('artists');
|
||||
Query.clearSelection('albums');
|
||||
Query.setSearchString('');
|
||||
Field.clear('search');
|
||||
var playlistId = $('source').value;
|
||||
if (1 == playlistId) {
|
||||
Query.playlistUrl = '';
|
||||
} else {
|
||||
Query.playlistUrl = 'containers/' + playlistId + '/';
|
||||
}
|
||||
Query.setSource(playlistId);
|
||||
Query.send('genres');
|
||||
},
|
||||
search: function () {
|
||||
@ -198,6 +213,17 @@ var Query = {
|
||||
setSearchString: function (string) {
|
||||
this.searchString = string;
|
||||
},
|
||||
setSource: function (playlistId) {
|
||||
Query.clearSelection('genres');
|
||||
Query.clearSelection('artists');
|
||||
Query.clearSelection('albums');
|
||||
Query.setSearchString('');
|
||||
if (1 == playlistId) {
|
||||
Query.playlistUrl = '';
|
||||
} else {
|
||||
Query.playlistUrl = 'containers/' + playlistId + '/';
|
||||
}
|
||||
},
|
||||
getUrl: function (type) {
|
||||
var query=[];
|
||||
switch (type) {
|
||||
@ -385,7 +411,7 @@ function rsSource(request) {
|
||||
sourceSelect.appendChild(optgroup);
|
||||
}
|
||||
if (staticPlaylists.length > 0) {
|
||||
optgroup = Builder.node('optgroup',{label: 'Static playlists'});
|
||||
optgroup = Builder.node('optgroup',{label: 'Static playlists',id: 'static_playlists'});
|
||||
staticPlaylists.each(function (item) {
|
||||
var option = document.createElement('option');
|
||||
optgroup.appendChild(Builder.node('option',{value: item.id},item.name));
|
||||
|
Loading…
x
Reference in New Issue
Block a user