parent
812c3b5e7c
commit
c91391e0bc
|
@ -1,6 +1,5 @@
|
||||||
var H5P = H5P || {};
|
var H5P = H5P || {};
|
||||||
importScripts('/wp-content/plugins/h5p/h5p-php-library/js/h5p-version.js');
|
importScripts('h5p-version.js', 'h5p-content-upgrade-process.js');
|
||||||
importScripts('/wp-content/plugins/h5p/h5p-php-library/js/h5p-content-upgrade-process.js');
|
|
||||||
|
|
||||||
var libraryLoadedCallback;
|
var libraryLoadedCallback;
|
||||||
|
|
||||||
|
@ -61,16 +60,3 @@ onmessage = function (event) {
|
||||||
messageHandlers[event.data.action].call(this, event.data);
|
messageHandlers[event.data.action].call(this, event.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// if (library.upgradesScript) {
|
|
||||||
// self.loadScript(library.upgradesScript, function (err) {
|
|
||||||
// if (err) {
|
|
||||||
// err = info.errorScript.replace('%lib', name + ' ' + version);
|
|
||||||
// }
|
|
||||||
// next(err, library);
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// else {
|
|
||||||
// next(null, library);
|
|
||||||
// }
|
|
||||||
|
|
|
@ -78,8 +78,8 @@
|
||||||
// Create throbber with loading text and progress
|
// Create throbber with loading text and progress
|
||||||
self.throbber = new Throbber(info.inProgress.replace('%ver', self.version));
|
self.throbber = new Throbber(info.inProgress.replace('%ver', self.version));
|
||||||
|
|
||||||
self.started = new Date().getTime();
|
self.started = new Date().getTime();
|
||||||
self.io = 0;
|
self.io = 0;
|
||||||
|
|
||||||
// Track number of working
|
// Track number of working
|
||||||
self.working = 0;
|
self.working = 0;
|
||||||
|
@ -98,8 +98,8 @@ self.io = 0;
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// No workers, do the job our self
|
// No workers, do the job ourselves
|
||||||
self.loadScript('/wp-content/plugins/h5p/h5p-php-library/js/h5p-content-upgrade-process.js', start);
|
self.loadScript(info.scriptBaseUrl + '/h5p-content-upgrade-process.js' + info.buster, start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ self.io = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
for (var i = 0; i < numWorkers; i++) {
|
for (var i = 0; i < numWorkers; i++) {
|
||||||
self.workers[i] = new Worker('/wp-content/plugins/h5p/h5p-php-library/js/h5p-content-upgrade-worker.js');
|
self.workers[i] = new Worker(info.scriptBaseUrl + '/h5p-content-upgrade-worker.js' + info.buster);
|
||||||
self.workers[i].onmessage = function (event) {
|
self.workers[i].onmessage = function (event) {
|
||||||
if (event.data.action !== undefined && messageHandlers[event.data.action]) {
|
if (event.data.action !== undefined && messageHandlers[event.data.action]) {
|
||||||
messageHandlers[event.data.action].call(this, event.data);
|
messageHandlers[event.data.action].call(this, event.data);
|
||||||
|
@ -158,17 +158,20 @@ self.io = 0;
|
||||||
ContentUpgrade.prototype.nextBatch = function (outData) {
|
ContentUpgrade.prototype.nextBatch = function (outData) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
var start = new Date().getTime();
|
// Track time spent on IO
|
||||||
|
var start = new Date().getTime();
|
||||||
$.post(info.infoUrl, outData, function (inData) {
|
$.post(info.infoUrl, outData, function (inData) {
|
||||||
self.io += new Date().getTime() - start;
|
self.io += new Date().getTime() - start;
|
||||||
if (!(inData instanceof Object)) {
|
if (!(inData instanceof Object)) {
|
||||||
// Print errors from backend
|
// Print errors from backend
|
||||||
return self.setStatus(inData);
|
return self.setStatus(inData);
|
||||||
}
|
}
|
||||||
if (inData.left === 0) {
|
if (inData.left === 0) {
|
||||||
var total = new Date().getTime() - self.started;
|
var total = new Date().getTime() - self.started;
|
||||||
console.log('Upgrade took ' + total + 'ms');
|
|
||||||
console.log((self.io/(total/100)) + ' % of the time went to IO (' + self.io + 'ms)');
|
if (window.console && console.log) {
|
||||||
|
console.log('The upgrade process took ' + (total / 1000) + ' seconds. (' + (Math.round((self.io / (total / 100)) * 100) / 100) + ' % IO)' );
|
||||||
|
}
|
||||||
|
|
||||||
// Terminate workers
|
// Terminate workers
|
||||||
self.terminate();
|
self.terminate();
|
||||||
|
@ -347,17 +350,18 @@ self.io += new Date().getTime() - start;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var start = new Date().getTime();
|
// Track time spent loading
|
||||||
|
var start = new Date().getTime();
|
||||||
librariesCache[key] = true;
|
librariesCache[key] = true;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
cache: true,
|
cache: true,
|
||||||
url: info.libraryBaseUrl + '/' + key
|
url: info.libraryBaseUrl + '/' + key
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
self.io += new Date().getTime() - start;
|
self.io += new Date().getTime() - start;
|
||||||
next(info.errorData.replace('%lib', name + ' ' + version));
|
next(info.errorData.replace('%lib', name + ' ' + version));
|
||||||
}).done(function (library) {
|
}).done(function (library) {
|
||||||
self.io += new Date().getTime() - start;
|
self.io += new Date().getTime() - start;
|
||||||
librariesCache[key] = library;
|
librariesCache[key] = library;
|
||||||
next(null, library);
|
next(null, library);
|
||||||
|
|
||||||
|
@ -382,17 +386,18 @@ self.io += new Date().getTime() - start;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var start = new Date().getTime();
|
// Track time spent loading
|
||||||
|
var start = new Date().getTime();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
dataType: 'script',
|
dataType: 'script',
|
||||||
cache: true,
|
cache: true,
|
||||||
url: url
|
url: url
|
||||||
}).fail(function () {
|
}).fail(function () {
|
||||||
self.io += new Date().getTime() - start;
|
self.io += new Date().getTime() - start;
|
||||||
next(true);
|
next(true);
|
||||||
}).done(function () {
|
}).done(function () {
|
||||||
scriptsCache[url] = true;
|
scriptsCache[url] = true;
|
||||||
self.io += new Date().getTime() - start;
|
self.io += new Date().getTime() - start;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue