diff --git a/public/js/chat.js b/public/js/chat.js index 381dd22..73f5af0 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -765,16 +765,24 @@ chatInput.addEventListener("keypress", function (event) { // Make links clickable msg = msg.autoLink(); // Send message over data channel + if (isEmptyOrSpaces(msg) == false) { dataChanel.send("mes:" + msg); - // Add message to screen addMessageToScreen(msg, true); + + } + // Add message to screen // Auto scroll chat down chatZone.scrollTop(chatZone[0].scrollHeight); // Clear chat input chatInput.value = ""; + } }); +function isEmptyOrSpaces(str){ + return str === null || str.match(/^ *$/) !== null; +} + // Called when a message is recieved over the dataChannel function handleRecieveMessage(msg) { // Add message to screen