From 86358c619bfd2acf4300484f23759825507dce3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Astori?= Date: Wed, 14 Dec 2016 01:35:32 -0500 Subject: [PATCH] Lock input message when app is disconnected --- client/js/lounge.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/client/js/lounge.js b/client/js/lounge.js index ee6c8b0d..4c7b3b2f 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -89,6 +89,18 @@ $(function() { window.location.reload(); }); + // Disables sending a message by pressing Enter. `off` is necessary to + // cancel `inputhistory`, which overrides hitting Enter. `on` is then + // necessary to avoid creating new lines when hitting Enter without Shift. + // This is fairly hacky but this solution is not permanent. + $("#input").off("keydown").on("keydown", function(event) { + if (event.which === 13 && !event.shiftKey) { + event.preventDefault(); + } + }); + // Hides the "Send Message" button + $("#submit").remove(); + console.error(data); }); });