From f320d4c208a3c8f00093ab1f919967506f47f4ea Mon Sep 17 00:00:00 2001 From: Mattias Erming Date: Thu, 15 May 2014 23:56:23 +0200 Subject: [PATCH] Added '/say' command --- README.md | 2 +- client/js/chat.js | 1 + client/js/jquery.plugins.js | 9 ++------- lib/server.js | 3 +++ 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8aa5e3c0..9a3fcec2 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ These are the commands currently implemented: - [x] /query - [x] /quit - [ ] /raw -- [ ] /say +- [x] /say - [x] /send - [x] /server - [ ] /time diff --git a/client/js/chat.js b/client/js/chat.js index 4f80ad16..518b4b51 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -18,6 +18,7 @@ $(function() { "/part", "/query", "/quit", + "/say", "/send", "/server", "/topic", diff --git a/client/js/jquery.plugins.js b/client/js/jquery.plugins.js index 4ad0f84e..b7020541 100644 --- a/client/js/jquery.plugins.js +++ b/client/js/jquery.plugins.js @@ -214,7 +214,7 @@ } if (options.hint) { - if (word.length >= options.minLength) { + if (word.length >= options.minLength && words.length) { hint.call(self, words[0]); } else { // Clear hinting. @@ -309,16 +309,11 @@ var hint = ""; if (typeof word !== "undefined") { var text = input.val(); - hint = text + word.substr(last(text).length); + hint = text + word.substr(text.split(/ |\n/).pop().length); } clone.val(hint); } - - // Get the last word of a string. - function last(str) { - return str.split(/ |\n/).pop(); - } })(jQuery); /*! diff --git a/lib/server.js b/lib/server.js index 2e9e613e..74500bf6 100644 --- a/lib/server.js +++ b/lib/server.js @@ -129,6 +129,9 @@ function input(data) { var cmd = text.charAt(0) == "/" ? args[0].toLowerCase() : ""; switch (cmd) { + case "say": + // Remove '/say' and treat this command as a message. + args.shift(); case "": args.unshift( "msg",