Add a progress bar on the UI
This commit is contained in:
@@ -79,6 +79,12 @@ var PhantomasWrapper = function() {
|
||||
deferred.reject('Phantomas failed: ' + res.message);
|
||||
});
|
||||
|
||||
promise.on('milestone', function(event) {
|
||||
if (event === 'domReady' || event === 'domComplete') {
|
||||
deferred.notify(event);
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -33,6 +33,7 @@ var Redownload = function() {
|
||||
function recheckAllFiles(data) {
|
||||
var startTime = Date.now();
|
||||
debug('Redownload started');
|
||||
|
||||
var deferred = Q.defer();
|
||||
|
||||
var requestsOffenders = data.toolsResults.phantomas.offenders.requests;
|
||||
@@ -43,6 +44,9 @@ var Redownload = function() {
|
||||
|
||||
var requestsList = mergeOffenders(requestsOffenders, gzipOffenders, postOffenders, notFoundOffenders, redirectOffenders);
|
||||
|
||||
var totalCount = requestsList.length;
|
||||
var doneCount = 0;
|
||||
|
||||
var httpAuth = null;
|
||||
if (data.params && data.params.options && data.params.options.authUser && data.params.options.authPass) {
|
||||
httpAuth = {
|
||||
@@ -89,6 +93,11 @@ var Redownload = function() {
|
||||
|
||||
.then(function(newEntry) {
|
||||
debug('File %s - Redownloaded, optimized, minified, compressed, analyzed: done', entry.url);
|
||||
|
||||
// For the progress bar
|
||||
doneCount ++;
|
||||
deferred.notify(doneCount/totalCount);
|
||||
|
||||
callback(null, newEntry);
|
||||
})
|
||||
|
||||
@@ -745,9 +754,9 @@ var Redownload = function() {
|
||||
|
||||
function detectWordPress(requests) {
|
||||
// Check the first file only
|
||||
if (requests[0].isHTML
|
||||
&& requests[0].weightCheck.bodyBuffer
|
||||
&& requests[0].weightCheck.bodyBuffer.indexOf('/wp-content/') > 0) {
|
||||
if (requests[0].isHTML &&
|
||||
requests[0].weightCheck.bodyBuffer &&
|
||||
requests[0].weightCheck.bodyBuffer.indexOf('/wp-content/') > 0) {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user