moved js code to separate file and add date to chat history