Implemented EventListeners extension in JavaScript.

Based on EventListeners.py, which is also in this commit.