improved messages management

This commit is contained in:
Rodolphe Breard 2012-12-18 17:33:16 +01:00
parent 1e089bf972
commit 257deaa4e6
3 changed files with 17 additions and 23 deletions

View file

@ -41,11 +41,10 @@ var NsClient = function() {
})(this.actions.msg.exp); })(this.actions.msg.exp);
this.actions.msg.act = (function(elem) { this.actions.msg.act = (function(elem) {
return function(msg) { return function(msg) {
if ($cs.opts.get("enable_msg")) {
var mo = {}; var mo = {};
mch = elem.actions.msg.exp.exec(msg); mch = elem.actions.msg.exp.exec(msg);
if (mch !== null && typeof elem.msgHandler !== "undefined") { if (mch !== null) {
mo.socket = mch[1]; mo.socket = mch[1];
mo.login = mch[2]; mo.login = mch[2];
mo.host = mch[3]; mo.host = mch[3];
@ -53,8 +52,7 @@ var NsClient = function() {
mo.group = mch[5]; mo.group = mch[5];
mo.message = elem.msgDecode(mch[6]); mo.message = elem.msgDecode(mch[6]);
elem.msgHandler(mo); $cs.ui.addContentToTab(mo.login, mo);
}
} }
}; };
})(this); })(this);

View file

@ -94,8 +94,12 @@ Nsui.prototype.addNewTab = function(tab_name) {
}; };
Nsui.prototype.addContentToTab = function(tab_name, content) { Nsui.prototype.addContentToTab = function(tab_name, content) {
var tab = this.addNewTab(tab_name); var tab = null;
if ($cs.opts.get("enable_msg")) {
tab = this.addNewTab(tab_name);
tab.appendText(this.formatMessage(content)); tab.appendText(this.formatMessage(content));
}
}; };
Nsui.prototype.formatInteger = function(num, len) { Nsui.prototype.formatInteger = function(num, len) {
@ -149,12 +153,4 @@ Nsui.prototype.init = function() {
elem.hideAllTabs(); elem.hideAllTabs();
}; };
})(this); })(this);
if (typeof $cs.client !== "undefined") {
NsClient.prototype.msgHandler = (function(elem) {
return function(msg) {
elem.addContentToTab(msg.login, msg);
};
})(this);
}
}; };

View file

@ -77,7 +77,7 @@ Tab.prototype.initBodyElement = function() {
var msg = this.value; var msg = this.value;
this.value = ""; this.value = "";
if (typeof $cs.client !== "undefined") { if (typeof $cs.client !== "undefined" && $cs.opts.get("enable_msg")) {
$cs.client.sendMessage(elem.name, msg); $cs.client.sendMessage(elem.name, msg);
$cs.ui.addContentToTab(elem.name, {"message": msg}); $cs.ui.addContentToTab(elem.name, {"message": msg});
} else { } else {