diff options
Diffstat (limited to 'apps/media/js/music.js')
-rw-r--r-- | apps/media/js/music.js | 95 |
1 files changed, 17 insertions, 78 deletions
diff --git a/apps/media/js/music.js b/apps/media/js/music.js index ba34e66c3ba..b2464c3842f 100644 --- a/apps/media/js/music.js +++ b/apps/media/js/music.js @@ -1,85 +1,24 @@ $(document).ready(function(){ //load the collection - $.ajax({ - url: OC.linkTo('media','ajax/api.php')+'?action=get_collection', - dataType: 'json', - success: function(collection){ - displayCollection(collection); - } + $('#plugins a[href="#collection"]').click(function(){ + $('#plugins li.subentry a.active').removeClass('active'); + $(this).addClass('active'); + PlayList.hide(); + Collection.display(); }); -}); - -function displayCollection(collection){ - $('#collection').data('collection',collection); - $.each(collection,function(index,artist){ - var artistNode=$('<li class="artist">'+artist.artist_name+'<button class="add">Add</button><ul/></li>'); - artistNode.data('name',artist.artist_name); - artistNode.data('stuff',artist); - $('#collection>ul').append(artistNode); - $.each(artist.albums,function(index,album){ - var albumNode=$('<li class="album">'+album.album_name+'<button class="add">Add</button><ul/></li>'); - albumNode.data('name',album.album_name); - albumNode.data('stuff',album); - artistNode.children('ul').append(albumNode); - $.each(album.songs,function(index,song){ - var songNode=$('<li class="song">'+song.song_name+'<button class="add">Add</button></li>'); - song.artist_name=artist.artist_name; - song.album_name=album.album_name; - songNode.data('name',song.song_name); - songNode.data('stuff',song); - albumNode.children('ul').append(songNode); - }); - }); - }); - $('li.album').hide(); - $('li.song').hide(); - $('li.artist').click(function(){ - $(this).children().children().slideToggle(); - return false; - }); - $('li.album').click(function(){ - $(this).children().children().slideToggle(); - return false; - }); - $('li.song').click(function(){ - return false; + $('#plugins a[href="#playlist"]').click(function(){ + $('#plugins li.subentry a.active').removeClass('active'); + $(this).addClass('active'); + PlayList.render(); + Collection.hide(); }); - $('li>button.add').click(function(){ - PlayList.add($(this).parent().data('stuff')); - PlayList.render($('#playlist')); - return false; - }); - if(window.location.href.indexOf('#')>-1){//autoplay passed arist/album/song - var vars=getUrlVars(); - var play; - if(vars['artist']){ - $.each(collection,function(index,artist){ - if(artist.artist_name==vars['artist']){ - play=artist; - if(vars['album']){ - $.each(artist.albums,function(index,album){ - if(album.album_name==vars['album']){ - play=album; - if(vars['song']){ - $.each(album.songs,function(index,song){ - if(song.song_name==vars['song']){ - play=song; - } - }); - } - } - }); - } - } - }); - } - PlayList.add(play); - PlayList.play(); - }else{ - PlayList.init(); + var tab=window.location.href.slice(window.location.href.indexOf('#') + 1); + if(tab=='collection'){ + $('#plugins a[href="#collection"]').trigger('click'); } - -} +}); + + function getUrlVars(){ var vars = [], hash; @@ -94,7 +33,7 @@ function getUrlVars(){ } function musicTypeFromFile(file){ - var extention=file.substr(file.indexOf('.')+1); + var extention=file.split('.').pop(); if(extention=='ogg'){ return 'oga' } |