move the js code to scripts/chat.js from index.php