Skip to content

Commit

Permalink
IE Compatibility fix - IE doesn't support add/remove EventListener, r…
Browse files Browse the repository at this point in the history
…eplaced with add/detach Event
  • Loading branch information
Antonio Egizio committed Oct 8, 2013
1 parent 9f8ac99 commit db8f87f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions jsbn/rng.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit db8f87f

Please sign in to comment.