From: Darren Date: Fri, 31 Aug 2012 20:42:13 +0000 (+0100) Subject: Ignore blank lines on control input X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9f6217c1d71f86138356d8a90c1fa0d76d2e7085;p=KiwiIRC.git Ignore blank lines on control input --- diff --git a/client_backbone/view.js b/client_backbone/view.js index 76bf71e..1edda45 100644 --- a/client_backbone/view.js +++ b/client_backbone/view.js @@ -358,31 +358,36 @@ kiwi.view.ControlBox = Backbone.View.extend({ }, process: function (ev) { - var inp = $(ev.currentTarget); + var inp = $(ev.currentTarget), + inp_val = inp.val(); switch (true) { - case (ev.keyCode === 13): // return + case (ev.keyCode === 13): // return + inp_val = inp_val.trim(); + + if (inp_val) { this.processInput(inp.val()); this.buffer.push(inp.val()); this.buffer_pos = this.buffer.length; - - inp.val(''); - - break; - - case (ev.keyCode === 38): // up - if (this.buffer_pos > 0) { - this.buffer_pos--; - inp.val(this.buffer[this.buffer_pos]); - } - break; - - case (ev.keyCode === 40): // down - if (this.buffer_pos < this.buffer.length) { - this.buffer_pos++; - inp.val(this.buffer[this.buffer_pos]); - } + } + + inp.val(''); + + break; + + case (ev.keyCode === 38): // up + if (this.buffer_pos > 0) { + this.buffer_pos--; + inp.val(this.buffer[this.buffer_pos]); + } + break; + + case (ev.keyCode === 40): // down + if (this.buffer_pos < this.buffer.length) { + this.buffer_pos++; + inp.val(this.buffer[this.buffer_pos]); + } } },