From: Darren Date: Sat, 28 Sep 2013 11:52:24 +0000 (+0100) Subject: panel.addMsg moved to models/channel.js X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f8508c7a159b0360a22b66e53aee7b83334e83c9;p=KiwiIRC.git panel.addMsg moved to models/channel.js Not every panel needs .addMsg such as applets. --- diff --git a/client/assets/src/models/channel.js b/client/assets/src/models/channel.js index 9134ad7..06b9d38 100644 --- a/client/assets/src/models/channel.js +++ b/client/assets/src/models/channel.js @@ -47,5 +47,63 @@ _kiwi.model.Channel = _kiwi.model.Panel.extend({ this.addMsg(' ', '== ' + _kiwi.global.i18n.translate('client_models_channel_part').fetch(member.displayNick(true), msg), 'action part'); } }, this); + }, + + + addMsg: function (nick, msg, type, opts) { + var message_obj, bs, d, + scrollback = (parseInt(_kiwi.global.settings.get('scrollback'), 10) || 250); + + opts = opts || {}; + + // Time defaults to now + if (!opts || typeof opts.time === 'undefined') { + d = opts.date = new Date(); + opts.time = d.getHours().toString().lpad(2, "0") + ":" + d.getMinutes().toString().lpad(2, "0") + ":" + d.getSeconds().toString().lpad(2, "0"); + } + + // CSS style defaults to empty string + if (!opts || typeof opts.style === 'undefined') { + opts.style = ''; + } + + // Run through the plugins + message_obj = {"msg": msg, "date": opts.date, "time": opts.time, "nick": nick, "chan": this.get("name"), "type": type, "style": opts.style}; + //tmp = _kiwi.plugs.run('addmsg', message_obj); + if (!message_obj) { + return; + } + + // The CSS class (action, topic, notice, etc) + if (typeof message_obj.type !== "string") { + message_obj.type = ''; + } + + // Make sure we don't have NaN or something + if (typeof message_obj.msg !== "string") { + message_obj.msg = ''; + } + + // Update the scrollback + bs = this.get("scrollback"); + if (bs) { + bs.push(message_obj); + + // Keep the scrolback limited + if (bs.length > scrollback) { + bs.splice(scrollback); + } + this.set({"scrollback": bs}, {silent: true}); + } + + this.trigger("msg", message_obj); + }, + + + clearMessages: function () { + this.set({'scrollback': []}, {silent: true}); + this.addMsg('', 'Window cleared'); + + this.view.render(); } }); diff --git a/client/assets/src/models/panel.js b/client/assets/src/models/panel.js index fe41308..943658e 100644 --- a/client/assets/src/models/panel.js +++ b/client/assets/src/models/panel.js @@ -8,63 +8,6 @@ _kiwi.model.Panel = Backbone.Model.extend({ }, {"silent": true}); }, - addMsg: function (nick, msg, type, opts) { - var message_obj, bs, d, - scrollback = (parseInt(_kiwi.global.settings.get('scrollback'), 10) || 250); - - opts = opts || {}; - - // Time defaults to now - if (!opts || typeof opts.time === 'undefined') { - d = opts.date = new Date(); - opts.time = d.getHours().toString().lpad(2, "0") + ":" + d.getMinutes().toString().lpad(2, "0") + ":" + d.getSeconds().toString().lpad(2, "0"); - } - - // CSS style defaults to empty string - if (!opts || typeof opts.style === 'undefined') { - opts.style = ''; - } - - // Run through the plugins - message_obj = {"msg": msg, "date": opts.date, "time": opts.time, "nick": nick, "chan": this.get("name"), "type": type, "style": opts.style}; - //tmp = _kiwi.plugs.run('addmsg', message_obj); - if (!message_obj) { - return; - } - - // The CSS class (action, topic, notice, etc) - if (typeof message_obj.type !== "string") { - message_obj.type = ''; - } - - // Make sure we don't have NaN or something - if (typeof message_obj.msg !== "string") { - message_obj.msg = ''; - } - - // Update the scrollback - bs = this.get("scrollback"); - if (bs) { - bs.push(message_obj); - - // Keep the scrolback limited - if (bs.length > scrollback) { - bs.splice(scrollback); - } - this.set({"scrollback": bs}, {silent: true}); - } - - 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/src/models/server.js b/client/assets/src/models/server.js index a275393..f3017c2 100644 --- a/client/assets/src/models/server.js +++ b/client/assets/src/models/server.js @@ -1,4 +1,4 @@ -_kiwi.model.Server = _kiwi.model.Panel.extend({ +_kiwi.model.Server = _kiwi.model.Channel.extend({ // Used to determine if this is a server panel server: true, diff --git a/server/httphandler.js b/server/httphandler.js index 2cddc37..a6b8893 100644 --- a/server/httphandler.js +++ b/server/httphandler.js @@ -238,11 +238,11 @@ function generateSettings(request, debug, callback) { [ 'src/models/query.js', 'src/models/channel.js', - 'src/models/server.js', 'src/models/applet.js' ], [ + 'src/models/server.js', // Depends on models/channel.js 'src/applets/settings.js', 'src/applets/chanlist.js', 'src/applets/scripteditor.js'