diff --git a/client/index.html b/client/index.html index 048b0b7..9a98819 100644 --- a/client/index.html +++ b/client/index.html @@ -63,9 +63,11 @@
+ {{#equal <%= messages %> messages.length}} + {{/equal}}
{{partial "messages"}}
diff --git a/client/js/chat.js b/client/js/chat.js index 0f655db..f043f51 100644 --- a/client/js/chat.js +++ b/client/js/chat.js @@ -65,7 +65,7 @@ $(function() { .sticky() .end() .find(".input") - .tabcomplete(commands, {hint: false}) + .tabcomplete(complete, {hint: false}) .history(); $("#network-" + data.id) @@ -97,16 +97,12 @@ $(function() { case "networks": var channels = $.map(data.networks, function(n) { return n.channels; }); chat.html(render("windows", {windows: channels})) - .find(".input") - .tabcomplete(commands, {hint: false}) - .history() - .end() - .find(".hidden") - .prev(".show-more") - .show(); - chat.find(".chat") + .find(".chat") .sticky() - .end(); + .end() + .find(".input") + .tabcomplete(complete, {hint: false}) + .history(); var networks = $("#networks") .html(render("networks", {networks: data.networks})) @@ -294,6 +290,15 @@ $(function() { }); + function complete(word) { + return $.grep( + commands, + function(cmd) { + return !cmd.indexOf(word); + } + ); + } + function toArray(val) { return Array.isArray(val) ? val : [val]; } @@ -308,6 +313,16 @@ $(function() { }); } + Handlebars.registerHelper( + "equal", function(a, b, opt) { + a = parseInt(a); + b = parseInt(b); + if (a == b) { + return opt.fn(this); + } + } + ); + Handlebars.registerHelper( "uri", function(text) { text = escape(text); diff --git a/lib/server.js b/lib/server.js index 0a263d0..239d45f 100644 --- a/lib/server.js +++ b/lib/server.js @@ -61,7 +61,7 @@ function index(req, res, next) { fs.readFile("client/index.html", function(err, file) { var data = _.merge( require("../package.json"), - {} // config + config ); res.end(_.template( file,