From 6dd35fa890123cc31b77055e38453e5f4a6c67d6 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Sat, 2 Nov 2013 17:22:22 +0100 Subject: [PATCH] Split messages with newline into multiple messages --- css/glowingbear.css | 6 ++++-- directives/input.html | 5 +++-- js/websockets.js | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 983c98d..b44c71a 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -105,8 +105,10 @@ body { padding-bottom:70px; } -input#sendMessage { +#sendMessage { width: 100%; + height: 36px; + resize: none; } #footer button { border-radius: 0; @@ -114,7 +116,7 @@ input#sendMessage { .panel input, .panel .input-group { max-width: 300px; } -input[type=text], input[type=password], .badge { +input[type=text], input[type=password], #sendMessage, .badge { border: 0; border-radius: 0; color: #ccc; diff --git a/directives/input.html b/directives/input.html index 43fd60d..181748f 100644 --- a/directives/input.html +++ b/directives/input.html @@ -1,6 +1,7 @@ -
+
- + diff --git a/js/websockets.js b/js/websockets.js index ff222c2..db1d9af 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -731,7 +731,11 @@ weechat.directive('inputBar', function() { // Send the message to the websocket $scope.sendMessage = function() { - connection.sendMessage($scope.command); + // Split the command into multiple commands based on line breaks + var commands = $scope.command.split(/\r?\n/); + commands.forEach(function(c) { + connection.sendMessage(c); + }); $scope.command = ""; } @@ -808,6 +812,15 @@ weechat.directive('inputBar', function() { return true; } + // Enter to submit, shift-enter for newline + if (code == 13 && !$event.shiftKey) { + $event.preventDefault(); + // Prevent inprog + setTimeout(function() {$('#inputform').submit();},0); + return true; + } + + } }