eddie.js 843 B

12345678910111213141516171819202122232425262728293031
  1. var eddieChatWindow
  2. var eddieInput
  3. var eddieButton
  4. function eddieGuestTalk() {
  5. eddieChatWindow.innerHTML += eddieInput.value + "\n"
  6. eddieChatWindow.scrollTop = eddieChatWindow.scrollHeight
  7. eddieInput.value = ""
  8. }
  9. function initChat() {
  10. document.getElementById("eddie-chat").innerHTML = `
  11. <textarea id='eddie-chatwindow' readonly></textarea>
  12. <div id='eddie-inputbar'>
  13. <input type='text' id='eddie-textfield' onblur='eddieGuestTalk()'>
  14. <input type='submit' value='Submit' id='eddie-submitbutton' onclick='eddieGuestTalk()'>
  15. </div>
  16. `
  17. eddieChatWindow = document.getElementById("eddie-chatwindow")
  18. eddieInput = document.getElementById("eddie-textfield")
  19. eddieButton = document.getElementById("eddie-submitbutton")
  20. eddieInput.addEventListener("keyup", function(event) {
  21. if (event.keyCode === 13) {
  22. eddieGuestTalk()
  23. }
  24. })
  25. }