1
0
mirror of https://github.com/moparisthebest/mail synced 2025-02-07 02:20:14 -05:00

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 * 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 * variable namespace similar to the 'window' object in the main thread
*/ */
self.addEventListener('message', function(e) { self.onmessage = function(e) {
var args = e.data, var args = e.data,
output = null, output = null,
@ -37,6 +37,6 @@
// pass output back to main thread // pass output back to main thread
self.postMessage(output); 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 * 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 * variable namespace similar to the 'window' object in the main thread
*/ */
self.addEventListener('message', function(e) { self.onmessage = function(e) {
var args = e.data, var args = e.data,
output = null, output = null,
@ -35,6 +35,6 @@
// pass output back to main thread // pass output back to main thread
self.postMessage(output); self.postMessage(output);
}, false); };
}()); }());

View File

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

View File

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