From 3f82fdf960624efb07b6fb27bdbeb5d88e519879 Mon Sep 17 00:00:00 2001 From: Tankred Hase Date: Wed, 10 Apr 2013 17:14:19 +0200 Subject: [PATCH] cleaned up web worker code --- src/js/crypto/aes-batch-worker.js | 4 ++-- src/js/crypto/aes-worker.js | 4 ++-- src/js/crypto/crypto.js | 20 ++++++++++---------- src/js/crypto/pbkdf2-worker.js | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/js/crypto/aes-batch-worker.js b/src/js/crypto/aes-batch-worker.js index d8c95c4..c9132f4 100644 --- a/src/js/crypto/aes-batch-worker.js +++ b/src/js/crypto/aes-batch-worker.js @@ -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); + }; }()); \ No newline at end of file diff --git a/src/js/crypto/aes-worker.js b/src/js/crypto/aes-worker.js index 6910822..de4a92e 100644 --- a/src/js/crypto/aes-worker.js +++ b/src/js/crypto/aes-worker.js @@ -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); + }; }()); \ No newline at end of file diff --git a/src/js/crypto/crypto.js b/src/js/crypto/crypto.js index 5b06ee3..aa1b6ff 100644 --- a/src/js/crypto/crypto.js +++ b/src/js/crypto/crypto.js @@ -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 diff --git a/src/js/crypto/pbkdf2-worker.js b/src/js/crypto/pbkdf2-worker.js index 8d43d65..a70c6f4 100644 --- a/src/js/crypto/pbkdf2-worker.js +++ b/src/js/crypto/pbkdf2-worker.js @@ -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); + }; }()); \ No newline at end of file