Update script.js

Separate the event handlers into a separate handler script.