Move js code out of index.html