Add force full search options to wanted list

This commit is contained in:
Ruud
2012-09-26 20:59:03 +02:00
parent 3da0b1a804
commit ed0e54d64d
3 changed files with 84 additions and 3 deletions
+48 -1
View File
@@ -10,16 +10,63 @@ Page.Wanted = new Class({
if(!self.wanted){
self.manual_search = new Element('a', {
'title': 'Force a search for the full wanted list',
'text': 'Search all wanted',
'events':{
'click': self.doFullSearch.bind(self, true)
}
});
// Wanted movies
self.wanted = new MovieList({
'identifier': 'wanted',
'status': 'active',
'actions': MovieActions,
'add_new': true
'add_new': true,
'menu': [self.manual_search]
});
$(self.wanted).inject(self.el);
// Check if search is in progress
self.startProgressInterval();
}
},
doFullSearch: function(full){
var self = this;
if(!self.search_in_progress){
Api.request('searcher.full_search');
self.startProgressInterval();
}
},
startProgressInterval: function(){
var self = this;
var start_text = self.manual_search.get('text');
self.progress_interval = setInterval(function(){
Api.request('searcher.progress', {
'onComplete': function(json){
self.search_in_progress = true;
if(!json.progress){
clearInterval(self.progress_interval);
self.search_in_progress = false;
self.manual_search.set('text', start_text);
}
else {
var progress = json.progress;
self.manual_search.set('text', 'Searching.. (' + (((progress.total-progress.to_go)/progress.total)*100).round() + '%)');
}
}
})
}, 1000);
}
});