From 648e2c0105c73a7424ddca8e041d2b72dcb756ee Mon Sep 17 00:00:00 2001 From: Darren Date: Wed, 2 Jan 2013 00:30:28 +0000 Subject: [PATCH] /clear command implimented #144 --- client/assets/dev/model_application.js | 13 +++++++++++++ client/assets/dev/model_panel.js | 8 ++++++++ client/assets/dev/view.js | 10 +++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/client/assets/dev/model_application.js b/client/assets/dev/model_application.js index ef7deac..9b18f4a 100644 --- a/client/assets/dev/model_application.js +++ b/client/assets/dev/model_application.js @@ -829,6 +829,8 @@ _kiwi.model.Application = function () { controlbox.on('command_kick', kickCommand); + controlbox.on('command_clear', clearCommand); + controlbox.on('command_css', function (ev) { var queryString = '?reload=' + new Date().getTime(); @@ -1029,6 +1031,17 @@ _kiwi.model.Application = function () { _kiwi.gateway.kick(panel.get('name'), nick, ev.params.join(' ')); } + function clearCommand (ev) { + // Can't clear a server or applet panel + if (_kiwi.app.panels.active.isServer() || _kiwi.app.panels.active.isApplet()) { + return; + } + + if (_kiwi.app.panels.active.clearMessages) { + _kiwi.app.panels.active.clearMessages(); + } + } + function settingsCommand (ev) { var settings = _kiwi.model.Applet.loadOnce('kiwi_settings'); settings.view.show(); diff --git a/client/assets/dev/model_panel.js b/client/assets/dev/model_panel.js index dc1ba64..5fdcc9c 100644 --- a/client/assets/dev/model_panel.js +++ b/client/assets/dev/model_panel.js @@ -55,6 +55,14 @@ _kiwi.model.Panel = Backbone.Model.extend({ this.trigger("msg", message_obj); }, + + clearMessages: function () { + this.set({'scrollback': []}, {silent: true}); + this.addMsg('', 'Window cleared'); + + this.view.render(); + }, + closePanel: function () { if (this.view) { this.view.unbind(); diff --git a/client/assets/dev/view.js b/client/assets/dev/view.js index 0cd61c6..201ba9c 100644 --- a/client/assets/dev/view.js +++ b/client/assets/dev/view.js @@ -36,7 +36,7 @@ _kiwi.view.MemberList = Backbone.View.extend({ // Remove any existing userboxes $('.userbox', this.$el).remove(); - + $target.append(userbox.$el); }, show: function () { @@ -301,11 +301,15 @@ _kiwi.view.Panel = Backbone.View.extend({ }, render: function () { + var that = this; + this.$el.empty(); - this.model.get("backscroll").forEach(this.newMsg); + _.each(this.model.get('scrollback'), function (msg) { + that.newMsg(msg); + }); }, + newMsg: function (msg) { - // TODO: make sure that the message pane is scrolled to the bottom (Or do we? ~Darren) var re, line_msg, $this = this.$el, nick_colour_hex, nick_hex, is_highlight, msg_css_classes = ''; -- 2.25.1