From: Darren Date: Fri, 28 Oct 2011 08:53:37 +0000 (+0100) Subject: Further mobile client dev. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=86921a5db88b89cdcf23ae5c6168c5a4fa40e47d;p=KiwiIRC.git Further mobile client dev. --- diff --git a/client/js/mobile.html b/client/js/mobile.html index 95806ae..7f3e241 100644 --- a/client/js/mobile.html +++ b/client/js/mobile.html @@ -17,7 +17,7 @@ $(function () { console.log('starting'); kiwi.init(); - kiwi.gateway.nick = "efhoerufre"; + kiwi.gateway.nick = "mobwok"+Math.floor(Math.random()*500); kiwi.gateway.start('/kiwi'); }); @@ -29,11 +29,11 @@ diff --git a/client/js/mobile.js b/client/js/mobile.js index 65d0aea..bcb70b2 100644 --- a/client/js/mobile.js +++ b/client/js/mobile.js @@ -226,6 +226,7 @@ kiwi.ui = { } tab = kiwi.objects.MessageView.getCurrent(); if (tab.title !== 'server') { + console.log(tab.title); kiwi.gateway.privmsg(tab.title, msg); tab.addMsg(kiwi.gateway.nick, msg); } @@ -304,6 +305,20 @@ kiwi.init = function () { } tab.addMsg(data.nick, data.msg); }); + gateway.bind('onjoin', function (e, data) { + var tab = kiwi.objects.MessageView.get(data.channel); + if (!tab) { + tab = new kiwi.objects.MessageView(data.channel); + } + tab.addMsg('', '--> ' + data.nick + ' has joined', 'join'); + }); + gateway.bind('onpart', function (e, data) { + var tab = kiwi.objects.MessageView.get(data.channel); + if (!tab) { + tab = new kiwi.objects.MessageView(data.channel); + } + tab.addMsg('', '<-- ' + data.nick + ' has left (' + data.message + ')', 'part'); + }); }; @@ -355,11 +370,15 @@ kiwi.objects.MessageView = function (name) { kiwi.ui.views[name.toLowerCase()] = this; } kiwi.objects.MessageView.prototype = new kiwi.objects.View(); -kiwi.objects.MessageView.prototype.addMsg = function (nick, text) { +kiwi.objects.MessageView.prototype.msg_count = 0; +kiwi.objects.MessageView.prototype.addMsg = function (nick, text, msg_class) { var msg, d = new Date(), time; - msg = $('
'); + // The CSS class to use + msg_class = msg_class || ''; + + msg = $('
'); time = d.getHours().toString().lpad(2, "0") + ":" + d.getMinutes().toString().lpad(2, "0") + ":" + d.getSeconds().toString().lpad(2, "0"); $('.time', msg).text(time); @@ -367,6 +386,12 @@ kiwi.objects.MessageView.prototype.addMsg = function (nick, text) { $('.body', msg).text(kiwi.ui.formatIRCMsg(text)); this.content.append(msg); + this.msg_count++; + if (this.msg_count > 5) { + $('.msg:first', this.content).remove(); + this.msg_count--; + } + this.scrollBottom(); } // Static functions