diff --git a/exec/load/json-chat.js b/exec/load/json-chat.js index d9976fd483e83640fff4e8f1d1ca2bdf7d4b639f..c0390d2dbab7b91880888cdf5c237965890d2c31 100644 --- a/exec/load/json-chat.js +++ b/exec/load/json-chat.js @@ -6,6 +6,7 @@ function JSONChat(usernum,jsonclient,host,port) { this.nick; this.channels = {}; this.client = jsonclient; + this.view = undefined; this.settings = { NICK_COLOR:GREEN, TEXT_COLOR:LIGHTGRAY, @@ -128,6 +129,8 @@ function JSONChat(usernum,jsonclient,host,port) { this.client.cycle(); while(this.client.updates.length) this.update(this.client.updates.shift()); + if(this.view) + updateChatView(this.view,this); return true; } @@ -210,5 +213,22 @@ function JSONChat(usernum,jsonclient,host,port) { this.time = time; } + /* adapter for updating layout views */ + function updateChatView(view,chat) { + for each(var c in chat.channels) { + var found = false; + for each(var t in view.tabs) { + if(t.title == c.name) { + found = true; + break; + } + } + if(!found) { + view.addTab(c.name,"chat",chat); + } + } + } + + /* constructor */ this.connect(); }