cleaned up web worker code

This commit is contained in:
Tankred Hase 2013-04-10 17:14:19 +02:00
parent edf78bc1af
commit 3f82fdf960
4 changed files with 16 additions and 16 deletions

View File

@ -16,7 +16,7 @@
* In the web worker thread context, 'this' and 'self' can be used as a global
* variable namespace similar to the 'window' object in the main thread
*/
self.addEventListener('message', function(e) {
self.onmessage = function(e) {
var args = e.data,
output = null,
@ -37,6 +37,6 @@
// pass output back to main thread
self.postMessage(output);
}, false);
};
}());

View File

@ -15,7 +15,7 @@
* In the web worker thread context, 'this' and 'self' can be used as a global
* variable namespace similar to the 'window' object in the main thread
*/
self.addEventListener('message', function(e) {
self.onmessage = function(e) {
var args = e.data,
output = null,
@ -35,6 +35,6 @@
// pass output back to main thread
self.postMessage(output);
}, false);
};
}());

View File

@ -54,10 +54,10 @@ app.crypto.Crypto = function(window, util) {
// init webworker thread
var worker = new Worker(app.config.workerPath + '/crypto/pbkdf2-worker.js');
worker.addEventListener('message', function(e) {
worker.onmessage = function(e) {
// return derived key from the worker
callback(e.data);
}, false);
};
// send plaintext data to the worker
worker.postMessage({
@ -81,9 +81,9 @@ app.crypto.Crypto = function(window, util) {
if (window.Worker) {
var worker = new Worker(app.config.workerPath + '/crypto/aes-worker.js');
worker.addEventListener('message', function(e) {
worker.onmessage = function(e) {
callback(e.data);
}, false);
};
worker.postMessage({
type: 'encrypt',
plaintext: plaintext,
@ -101,9 +101,9 @@ app.crypto.Crypto = function(window, util) {
if (window.Worker) {
var worker = new Worker(app.config.workerPath + '/crypto/aes-worker.js');
worker.addEventListener('message', function(e) {
worker.onmessage = function(e) {
callback(e.data);
}, false);
};
worker.postMessage({
type: 'decrypt',
ciphertext: ciphertext,
@ -133,9 +133,9 @@ app.crypto.Crypto = function(window, util) {
if (window.Worker) {
var worker = new Worker(app.config.workerPath + '/crypto/aes-batch-worker.js');
worker.addEventListener('message', function(e) {
worker.onmessage = function(e) {
callback(e.data);
}, false);
};
worker.postMessage({
type: 'encrypt',
list: list
@ -151,9 +151,9 @@ app.crypto.Crypto = function(window, util) {
if (window.Worker) {
var worker = new Worker(app.config.workerPath + '/crypto/aes-batch-worker.js');
worker.addEventListener('message', function(e) {
worker.onmessage = function(e) {
callback(e.data);
}, false);
};
worker.postMessage({
type: 'decrypt',
list: list

View File

@ -14,7 +14,7 @@
* In the web worker thread context, 'this' and 'self' can be used as a global
* variable namespace similar to the 'window' object in the main thread
*/
self.addEventListener('message', function(e) {
self.onmessage = function(e) {
var args = e.data,
key = null;
@ -30,6 +30,6 @@
// pass output back to main thread
self.postMessage(key);
}, false);
};
}());