Skip to content
Snippets Groups Projects
Commit 94360516 authored by ale's avatar ale
Browse files

cleanup playlist list methods

parent a348d860
No related branches found
No related tags found
No related merge requests found
...@@ -85,6 +85,7 @@ djr.init = function (userid) { ...@@ -85,6 +85,7 @@ djr.init = function (userid) {
var pltitle = $('#savetext').val(); var pltitle = $('#savetext').val();
if (pltitle != '') { if (pltitle != '') {
djr.state.player.savePlaylistWithTitle(pltitle); djr.state.player.savePlaylistWithTitle(pltitle);
djr.updatePlaylists();
} }
$('#saveForm').hide(); $('#saveForm').hide();
}); });
...@@ -131,21 +132,8 @@ djr.init = function (userid) { ...@@ -131,21 +132,8 @@ djr.init = function (userid) {
}); });
$('#pllistbtn').click(function () { $('#pllistbtn').click(function () {
if ($('#pllist').is(':visible') == false) { if ($('#pllist').is(':visible') == false) {
djr.updatePlaylists();
$('#pllist').show('slow'); $('#pllist').show('slow');
djr.state.backend.getPlList(djr.state.userid, function(results) {
var pllist = results;
if (pllist.length == 0) {
djr.debug('No results found.');
return;
}
var output = "<ul>";
for (var i; i < pllist.length; i++) {
output += "<li><a onclick='djm.player.loadPlaylist(\"" + pllist[i].uuid + "\")' >" + pllist[i].title + "</a></li>";
}
output += "</ul>";
$('#pllist').html(output);
});
} else { } else {
$('#pllist').hide('slow') $('#pllist').hide('slow')
} }
...@@ -158,6 +146,8 @@ djr.init = function (userid) { ...@@ -158,6 +146,8 @@ djr.init = function (userid) {
}); });
djr.debug('initialization done.'); djr.debug('initialization done.');
djr.updatePlaylists();
}; };
// Export the player for quick onclick access // Export the player for quick onclick access
...@@ -165,6 +155,24 @@ djr.player = function() { ...@@ -165,6 +155,24 @@ djr.player = function() {
return djr.state.player; return djr.state.player;
}; };
// Update the list of playlists.
djr.updatePlaylists = function() {
djr.state.backend.getPlList(djr.state.userid, function(results) {
if (results.length == 0) {
djr.debug('No playlists found.');
return;
}
var output = '<ul>';
$.each(results, function(idx, x) {
if (x.title) {
output += "<li><a onclick='djm.player.loadPlaylist(\"" + x.uuid + "\")' >" + x.title + "</a></li>";
}
});
output += '</ul>';
$('#pllist').html(output);
});
};
// Show/hide the 'loader' animated GIF. // Show/hide the 'loader' animated GIF.
// Keep a counter so we can nest calls. // Keep a counter so we can nest calls.
djr.loading = function(active) { djr.loading = function(active) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment