nextcloud/apps/media/js/scanner.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2011-08-02 01:53:01 +04:00
Scanner={
songsFound:0,
eventSource:null,
2011-08-02 01:53:01 +04:00
songsScanned:0,
findSongs:function(ready){
$.getJSON(OC.linkTo('media','ajax/api.php')+'?action=find_music',function(songs){
Scanner.songsFound=songs.length;
if(ready){
ready(songs)
}
});
},
scanCollection:function(ready){
$('#scanprogressbar').progressbar({
value:0,
});
$('#scanprogressbar').show();
Scanner.songsScanned=0;
Scanner.eventSource=new OC.EventSource(OC.linkTo('media','ajax/api.php'),{action:'scan'});
Scanner.eventSource.listen('count',function(total){
Scanner.songsFound=total;
});
Scanner.eventSource.listen('scanned',function(data){
Scanner.songsScanned=data.count;
$('#scan span.songCount').text(Scanner.songsScanned);
var progress=(Scanner.songsScanned/Scanner.songsFound)*100;
$('#scanprogressbar').progressbar('value',progress)
2011-08-02 01:53:01 +04:00
});
Scanner.eventSource.listen('done',function(count){
$('#scan input.start').show();
$('#scan input.stop').hide();
$('#scanprogressbar').hide();
Collection.load(Collection.display)
if(ready){
ready();
}
});
$('#scancount').show();
2011-08-02 01:53:01 +04:00
},
stop:function(){
Scanner.close();
2011-08-02 01:53:01 +04:00
},
}