Simplify javascript code

use events instead of an interval and passes jslint validation
Merge remote-tracking branch 'upstream/master'
Merge branch 'master' into fix-html5