Moved the main javascript code to ./js/main.js. Also fully commented all js functions