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 />
|
</select><br />
|
||||||
<input type="text" id="edit_playlist_name" value="" />
|
<input type="text" id="edit_playlist_name" value="" />
|
||||||
<div id="busymsg" style="text-align:center;color:red; visibility: hidden;">Busy ...</div>
|
<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>
|
||||||
<div id="genre_div">
|
<div id="genre_div">
|
||||||
Genre<br />
|
Genre<br />
|
||||||
|
@ -20,17 +20,17 @@ function initPlaylist() {
|
|||||||
Field.clear('search');
|
Field.clear('search');
|
||||||
}
|
}
|
||||||
var GlobalEvents = {
|
var GlobalEvents = {
|
||||||
_listeners: [],
|
_clickListeners: [],
|
||||||
click: function (e) {
|
click: function (e) {
|
||||||
GlobalEvents._listeners.each(function (name) {
|
GlobalEvents._clickListeners.each(function (name) {
|
||||||
name.click(e);
|
name.click(e);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
addListener: function (el) {
|
addClickListener: function (el) {
|
||||||
this._listeners.push(el);
|
this._clickListeners.push(el);
|
||||||
},
|
},
|
||||||
removeListener: function (el) {
|
removeClickListener: function (el) {
|
||||||
this._listeners = this._listeners.findAll(function (element) {
|
this._clickListeners = this._clickListeners.findAll(function (element) {
|
||||||
return (element != el);
|
return (element != el);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -71,6 +71,11 @@ var EditPlaylistName = {
|
|||||||
EditPlaylistName.save();
|
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 () {
|
save: function () {
|
||||||
input = $('edit_playlist_name');
|
input = $('edit_playlist_name');
|
||||||
var url = '/databases/1/containers/edit?output=xml';
|
var url = '/databases/1/containers/edit?output=xml';
|
||||||
@ -83,20 +88,38 @@ var EditPlaylistName = {
|
|||||||
},
|
},
|
||||||
show: function () {
|
show: function () {
|
||||||
input = $('edit_playlist_name');
|
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.value = this.playlistName;
|
||||||
input.style.display = 'block';
|
input.style.display = 'block';
|
||||||
Field.activate(input);
|
Field.activate(input);
|
||||||
GlobalEvents.addListener(this);
|
GlobalEvents.addClickListener(this);
|
||||||
},
|
},
|
||||||
hide: function () {
|
hide: function () {
|
||||||
$('edit_playlist_name').style.display = 'none';
|
$('edit_playlist_name').style.display = 'none';
|
||||||
EditPlaylistName.playlistId = '';
|
EditPlaylistName.playlistId = '';
|
||||||
GlobalEvents.removeListener(this);
|
GlobalEvents.removeClickListener(this);
|
||||||
},
|
},
|
||||||
response: function (request) {
|
response: function (request) {
|
||||||
// Check that the save gave response 200 OK
|
// 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) {
|
click: function (e) {
|
||||||
var x = Event.pointerX(e);
|
var x = Event.pointerX(e);
|
||||||
var y = Event.pointerY(e);
|
var y = Event.pointerY(e);
|
||||||
@ -139,17 +162,9 @@ var EventHandler = {
|
|||||||
},
|
},
|
||||||
sourceChange: function (e) {
|
sourceChange: function (e) {
|
||||||
EventHandler.sourceClickCount = [];
|
EventHandler.sourceClickCount = [];
|
||||||
Query.clearSelection('genres');
|
|
||||||
Query.clearSelection('artists');
|
|
||||||
Query.clearSelection('albums');
|
|
||||||
Query.setSearchString('');
|
|
||||||
Field.clear('search');
|
Field.clear('search');
|
||||||
var playlistId = $('source').value;
|
var playlistId = $('source').value;
|
||||||
if (1 == playlistId) {
|
Query.setSource(playlistId);
|
||||||
Query.playlistUrl = '';
|
|
||||||
} else {
|
|
||||||
Query.playlistUrl = 'containers/' + playlistId + '/';
|
|
||||||
}
|
|
||||||
Query.send('genres');
|
Query.send('genres');
|
||||||
},
|
},
|
||||||
search: function () {
|
search: function () {
|
||||||
@ -198,6 +213,17 @@ var Query = {
|
|||||||
setSearchString: function (string) {
|
setSearchString: function (string) {
|
||||||
this.searchString = 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) {
|
getUrl: function (type) {
|
||||||
var query=[];
|
var query=[];
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -385,7 +411,7 @@ function rsSource(request) {
|
|||||||
sourceSelect.appendChild(optgroup);
|
sourceSelect.appendChild(optgroup);
|
||||||
}
|
}
|
||||||
if (staticPlaylists.length > 0) {
|
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) {
|
staticPlaylists.each(function (item) {
|
||||||
var option = document.createElement('option');
|
var option = document.createElement('option');
|
||||||
optgroup.appendChild(Builder.node('option',{value: item.id},item.name));
|
optgroup.appendChild(Builder.node('option',{value: item.id},item.name));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user