move javascript for index to index.js