2011-08-02 01:53:01 +04:00
|
|
|
Scanner={
|
|
|
|
songsFound:0,
|
2012-02-08 20:30:16 +04:00
|
|
|
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){
|
2012-02-22 01:31:35 +04:00
|
|
|
ready(songs);
|
2011-08-02 01:53:01 +04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
scanCollection:function(ready){
|
|
|
|
$('#scanprogressbar').progressbar({
|
|
|
|
value:0,
|
|
|
|
});
|
2012-01-20 04:41:37 +04:00
|
|
|
$('#scanprogressbar').show();
|
2011-08-02 06:43:08 +04:00
|
|
|
Scanner.songsScanned=0;
|
2012-02-08 20:30:16 +04:00
|
|
|
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;
|
2012-02-22 01:31:35 +04:00
|
|
|
$('#scanprogressbar').progressbar('value',progress);
|
2011-08-02 01:53:01 +04:00
|
|
|
});
|
2012-02-08 20:30:16 +04:00
|
|
|
Scanner.eventSource.listen('done',function(count){
|
|
|
|
$('#scan input.start').show();
|
|
|
|
$('#scan input.stop').hide();
|
|
|
|
$('#scanprogressbar').hide();
|
2012-02-22 01:31:35 +04:00
|
|
|
Collection.load(Collection.display);
|
2012-02-08 20:30:16 +04:00
|
|
|
if(ready){
|
|
|
|
ready();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('#scancount').show();
|
2011-08-02 01:53:01 +04:00
|
|
|
},
|
|
|
|
stop:function(){
|
2012-03-11 20:29:21 +04:00
|
|
|
Scanner.eventSource.close();
|
2011-08-02 01:53:01 +04:00
|
|
|
},
|
|
|
|
|
2012-02-22 01:31:35 +04:00
|
|
|
};
|