deploy dev version

This commit is contained in:
Julian Descottes
2017-05-22 09:56:42 +02:00
parent d7c6231e78
commit dbf8072343
937 changed files with 38520 additions and 225771 deletions

View File

@@ -0,0 +1,32 @@
(function () {
var ns = $.namespace('pskl.worker.hash');
ns.Hash = function (str, onSuccess, onStep, onError) {
this.str = str;
this.onStep = onStep;
this.onSuccess = onSuccess;
this.onError = onError;
this.worker = pskl.utils.WorkerUtils.createWorker(ns.HashWorker, 'hash');
this.worker.onmessage = this.onWorkerMessage.bind(this);
};
ns.Hash.prototype.process = function () {
this.worker.postMessage({
str : this.str
});
};
ns.Hash.prototype.onWorkerMessage = function (event) {
if (event.data.type === 'STEP') {
this.onStep(event);
} else if (event.data.type === 'SUCCESS') {
this.onSuccess(event);
this.worker.terminate();
} else if (event.data.type === 'ERROR') {
this.onError(event);
this.worker.terminate();
}
};
})();

View File

@@ -0,0 +1,34 @@
(function () {
var ns = $.namespace('pskl.worker.hash');
ns.HashWorker = function () {
var hashCode = function(str) {
var hash = 0;
if (str.length !== 0) {
for (var i = 0, l = str.length; i < l; i++) {
var chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
}
return hash;
};
this.onmessage = function(event) {
try {
var data = event.data;
var str = data.str;
var hash = hashCode(str);
this.postMessage({
type : 'SUCCESS',
hash : hash
});
} catch (e) {
this.postMessage({
type : 'ERROR',
message : e.message
});
}
};
};
})();