From 4899ac5ec7c378df1d450bbc7bd8d13a45327028 Mon Sep 17 00:00:00 2001 From: Ethan Fraenkel Date: Thu, 6 Sep 2018 12:33:22 +0100 Subject: [PATCH] added an event listener on enter key to have it as send --- .gitignore | 1 - app/javascript/packs/application.js | 1 + app/javascript/packs/webrtc.js | 15 +++++++++++++++ app/views/chat_rooms/show.html.erb | 18 ++++++++++-------- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 127293d..6e21a9c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,5 +13,4 @@ node_modules yarn-error.log .byebug_history .env* -.env* translation-credentials.json diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js index 72512a0..948618c 100644 --- a/app/javascript/packs/application.js +++ b/app/javascript/packs/application.js @@ -100,3 +100,4 @@ if (acceptButton) { document.getElementById('chat-room-id').value = chatRoomId }) } + diff --git a/app/javascript/packs/webrtc.js b/app/javascript/packs/webrtc.js index fd787df..e1d83e3 100644 --- a/app/javascript/packs/webrtc.js +++ b/app/javascript/packs/webrtc.js @@ -220,3 +220,18 @@ setTimeout(function() { window.__proto__.reload = () => { window.location = window.location } })(); + +// // have enter with JS +// const form = document.getElementById("chat-form") +// document.getElementById("chat-input").addEventListener("keyup", event => { +// if(event == "Enter"){ +// form.submit(); +// } +// }); + + +document.getElementById("chat-form").addEventListener("click", function(event){ + event.preventDefault() +}); + + diff --git a/app/views/chat_rooms/show.html.erb b/app/views/chat_rooms/show.html.erb index d4deb43..b96bbb5 100644 --- a/app/views/chat_rooms/show.html.erb +++ b/app/views/chat_rooms/show.html.erb @@ -28,14 +28,16 @@ <% end %> - - - - - - - - +
+ + + + + + + + +