Editing JavaScript to make it work on HTML, able to take out some errors, but not all