From db8f87f53c8cad6a50bace3aeed045d1b28232bf Mon Sep 17 00:00:00 2001 From: Antonio Egizio Date: Tue, 8 Oct 2013 22:23:57 +0200 Subject: [PATCH] IE Compatibility fix - IE doesn't support add/remove EventListener, replaced with add/detach Event --- jsbn/rng.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jsbn/rng.js b/jsbn/rng.js index 2169874..244c2e4 100644 --- a/jsbn/rng.js +++ b/jsbn/rng.js @@ -21,15 +21,21 @@ if(rng_pool == null) { var onMouseMoveListener = function(ev) { this.count = this.count || 0; if (this.count >= 256 || rng_pptr >= rng_psize) { - window.removeEventListener("mousemove", onMouseMoveListener); + if (window.removeEventListener) + window.removeEventListener("mousemove", onMouseMoveListener); + else if (window.detachEvent) + window.detachEvent("onmousemove", onMouseMoveListener); return; } this.count += 1; var mouseCoordinates = ev.x + ev.y; rng_pool[rng_pptr++] = mouseCoordinates & 255; }; - - window.addEventListener("mousemove", onMouseMoveListener); + if (window.addEventListener) + window.addEventListener("mousemove", onMouseMoveListener); + else if (window.attachEvent) + window.attachEvent("onmousemove", onMouseMoveListener); + } function rng_get_byte() {