fix several syntax errors in javascript