diff options
author | Robin Appelman <icewind1991@gmail.com> | 2011-08-01 23:53:01 +0200 |
---|---|---|
committer | Robin Appelman <icewind1991@gmail.com> | 2011-08-01 23:55:47 +0200 |
commit | 9f981de85437930ec89ecc85c2e79f096f65b5bb (patch) | |
tree | 49a313889f8aefdc131af360d539a4840d7422d5 /apps/media/js/collection.js | |
parent | ad45c78b44f887be547329501cba7c84c3a3c331 (diff) | |
download | nextcloud-server-9f981de85437930ec89ecc85c2e79f096f65b5bb.tar.gz nextcloud-server-9f981de85437930ec89ecc85c2e79f096f65b5bb.zip |
fance collection scanning wip
Diffstat (limited to 'apps/media/js/collection.js')
-rw-r--r-- | apps/media/js/collection.js | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/apps/media/js/collection.js b/apps/media/js/collection.js index 95e5293ea48..42d249112b1 100644 --- a/apps/media/js/collection.js +++ b/apps/media/js/collection.js @@ -32,6 +32,10 @@ Collection={ for(var i=0;i<Collection.loadedListeners.length;i++){ Collection.loadedListeners[i](); } + if(collection.length==0){ + $('#scan input.start').val('Scan'); + $('#plugins a[href="#collection"]').trigger('click'); + } } }); @@ -159,6 +163,35 @@ Collection={ } } } + }, + addSong:function(song){ + var artist=false + var album=false; + for(var i=0;i<Collection.artists.length;i++){ + if(Collection.artists[i].artist_id==song.song_artist){ + artist=Collection.artists[i]; + for(var j=0;j<artist.albums.length;j++){ + if(artist.albums[j].album_id==song.song_album){ + album=artist.albums[j]; + break; + } + } + break; + } + } + if(!artist){ + artist={artist_id:song.song_artist,artist_name:song.artist,albums:[]}; + Collection.artists.push(artist); + if(!Collection.parent || Collection.parent.is(":visible")){ + Collection.display(); + } + + } + if(!album){ + album={album_id:song.song_album,album_name:song.album,album_artist:song.song_artist,songs:[]}; + artist.albums.push(album) + } + album.songs.push(song) } } @@ -173,4 +206,13 @@ $(document).ready(function(){ $(this).parent().toggleClass('active'); Collection.showSongs($(this).parent()); }); + Collection.parent.hide(); + $('#scan input.start').click(function(){ + $('#scan input.start').hide(); + $('#scan input.stop').show(); + $('#scan input.stop').click(function(){ + Scanner.toggle(); + }); + Scanner.scanCollection(); + }); }); |