diff --git a/index.html b/index.html
index 4b744a7..62aa70e 100755
--- a/index.html
+++ b/index.html
@@ -1,4 +1,4 @@
-
+
- - Auto Playlists
- - Random
-
+
Genre Playlists
+
Random
+
Alternative
+
Electronic
+
Hip-Hop
+
+
+
diff --git a/js/app.js b/js/app.js
index d28cff7..ecfa880 100755
--- a/js/app.js
+++ b/js/app.js
@@ -1,4 +1,4 @@
-// Global Variables
+// Global Variables
var debug = false;
var audio = null;
var hostURL = location.href;
@@ -85,6 +85,7 @@ function loadTabContent(tab) {
case '#tabPlaylists':
if (debug) { console.log("TAG PLAYLIST"); }
loadPlaylists();
+ loadFolders();
break;
case '#tabPodcasts':
if (debug) { console.log("TAG PODCAST"); }
diff --git a/js/libs/api.js b/js/libs/api.js
index 2f7035c..dd22083 100755
--- a/js/libs/api.js
+++ b/js/libs/api.js
@@ -229,15 +229,25 @@ function getAlbumListBy(id) {
}
});
}
-function getRandomSongList(action, appendto) {
- var size;
+function getRandomSongList(action, appendto, genre, folder) {
+ var size,gstring;
+ gstring = '';
if ($.cookie('AutoPlaylistSize') === null) {
size = 25;
} else {
size = $.cookie('AutoPlaylistSize');
}
+ if (genre !== undefined) {
+ gstring = '&genre=' + genre;
+ }
+ if (genre === 'Random') {
+ gstring = '';
+ }
+ if (folder !== undefined) {
+ gstring = '&musicFolderId=' + folder;
+ }
$.ajax({
- url: baseURL + '/getRandomSongs.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&size=' + size,
+ url: baseURL + '/getRandomSongs.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp&size=' + size + gstring,
method: 'GET',
dataType: 'jsonp',
timeout: 10000,
@@ -399,6 +409,40 @@ function search(type, query) {
});
}
+function loadFolders(refresh) {
+ if (debug) { console.log("LOAD FOLDERS"); }
+ if (refresh) {
+ $('#FolderContainer').empty();
+ }
+ var content = $('#FolderContainer').html();
+ if (content === "") {
+ // Load Folders
+ $.ajax({
+ url: baseURL + '/getMusicFolders.view?u=' + username + '&p=' + password + '&v=' + version + '&c=' + applicationName + '&f=jsonp',
+ method: 'GET',
+ dataType: 'jsonp',
+ timeout: 10000,
+ success: function (data) {
+ var musicFolders = [];
+ if (data["subsonic-response"].musicFolders.musicFolder.length > 0) {
+ musicFolders = data["subsonic-response"].musicFolders.musicFolder;
+ } else {
+ musicFolders[0] = data["subsonic-response"].musicFolders.musicFolder;
+ }
+ $.each(musicFolders, function (i, musicFolder) {
+ var html = "";
+ html += '
';
+ html += '' + musicFolder.name + '';
+ html += '';
+ html += '';
+ html += '';
+ $(html).appendTo("#FolderContainer");
+ });
+ }
+ });
+ }
+}
+
function loadPlaylists(refresh) {
if (debug) { console.log("LOAD PLAYLISTS"); }
if (refresh) {
diff --git a/js/ui-ready.js b/js/ui-ready.js
index 4a50235..e77af42 100755
--- a/js/ui-ready.js
+++ b/js/ui-ready.js
@@ -1,4 +1,4 @@
-$(document).ready(function () {
+$(document).ready(function () {
//User config staff
$('#Username').val($.cookie('username'));
//$('#Password').val($.cookie('passwordenc'));
@@ -402,18 +402,24 @@
return false;
});
// Playlist Click Events
- $('#AutoPlaylistContainer li.item').live('click', function () {
+ $('#AutoPlaylistContainer li.item, #FolderContainer li.item').live('click', function () {
$('#AutoPlaylistContainer li').removeClass('selected');
$('#PlaylistContainer li').removeClass('selected');
$(this).addClass('selected');
- getRandomSongList('', '#TrackContainer');
+ var genre = $(this).data('genre');
+ var folder = $(this).data('folder');
+ getRandomSongList('', '#TrackContainer', genre, folder);
});
- $('#AutoPlaylistContainer li.item a.play').live('click', function () {
- getRandomSongList('autoplay', '#CurrentPlaylistContainer');
+ $('#AutoPlaylistContainer li.item a.play, #FolderContainer li.item a.play').live('click', function () {
+ var genre = $(this).data('genre');
+ var folder = $(this).data('folder');
+ getRandomSongList('autoplay', '#CurrentPlaylistContainer', genre, folder);
return false;
});
- $('#AutoPlaylistContainer li.item a.add').live('click', function () {
- getRandomSongList('', '#CurrentPlaylistContainer');
+ $('#AutoPlaylistContainer li.item a.add, #FolderContainer li.item a.add').live('click', function () {
+ var genre = $(this).data('genre');
+ var folder = $(this).data('folder');
+ getRandomSongList('', '#CurrentPlaylistContainer', genre, folder);
return false;
});
$('#PlaylistContainer li.item').live('click', function () {
@@ -437,6 +443,7 @@
});
$('#action_RefreshPlaylists').click(function () {
loadPlaylists(true);
+ loadFolders(true);
return false;
});
$('#action_DeletePlaylist').click(function () {
@@ -679,4 +686,5 @@
}
}).disableSelection();
-}); // End document.ready
+}); // End document.ready
+