SobiPro.jQuery().ready(function(){SobiPro.jQuery('#SPAdminForm').on('BeforeAjaxSubmit',function(e,a,b){if(b=='crawler.init'||b=='crawler.restart'){a.takeOver=true;new SobiProCrawler(b)}})});function SobiProCrawler(d){var e=this;this.message=SobiPro.jQuery('#progressMessage');this.spinner='<i class="icon-refresh icon-spin"></i>&nbsp;';SobiPro.jQuery('#crawlerResponse').find('.invalidate').remove();this.row=SobiPro.jQuery('#crawlerResponse').find('tbody').find('tr');SobiPro.jQuery('#crawlerResponse').find('tbody').find('tr').addClass('hide');this.request={'option':'com_sobipro','format':'raw','task':d,'sid':SobiProSection};this.setMessage=function(a,b){if(b){this.message.html(this.spinner+a)}else{this.message.html(a)}};this.setMessage(SobiPro.Txt('PROGRESS_WORKING'),true);SobiPro.jQuery('#crawlerResponse').removeClass('hide');this.parseResponse=function(c){SobiPro.jQuery.each(c,function(i,a){switch(a.code){case 200:code='<span class="label label-success">'+a.code+'</span>';break;case 412:code='<span class="label label-inverse">'+a.code+'</span>';break;case 501:code='<span class="label label-important">'+a.code+'</span>';break;default:code='<span class="label label-warning">'+a.code+'</span>';break}var b=e.row.clone();b.find('.url').html(a.url);b.find('.code').html(code);b.find('.links').html(a.count);b.find('.time').html(a.time);b.removeClass('hide');b.addClass('invalidate');SobiPro.jQuery('#crawlerResponse').find('tbody').prepend(b)})};this.getResponse=function(){SobiPro.jQuery.ajax({'type':'post','url':SPLiveSite+'/index.php','data':e.request,'dataType':'json',success:function(a){e.request['task']='crawler';if(a.data.length){e.setMessage(a.message,true);e.parseResponse(a.data)}if(a.status!='done'){e.getResponse()}else{e.request['task']='crawler.init';e.setMessage(a.message,false)}}})};this.getResponse()}
