Various JavaScript fixes (now passes jslint)

Excuse me, I have forked the reposotory as a fellow code writer and I am sending this e-note to you to request for editing rights.