From fde6ea95cdc6cc4f7b4da0e3bcf645561756df28 Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Thu, 15 Sep 2011 15:51:14 +0100 Subject: [PATCH] /list response now shows in a new tab --- js/front.js | 40 +++++++++++++++++++++++++++---------- js/underscore.min.js | 1 + node/app.js | 3 ++- node/client/index.html.jade | 1 + 4 files changed, 33 insertions(+), 12 deletions(-) create mode 120000 js/underscore.min.js diff --git a/js/front.js b/js/front.js index ce921cf..b8c5ba0 100644 --- a/js/front.js +++ b/js/front.js @@ -1,4 +1,4 @@ -/*jslint devel: true, undef: true, browser: true, continue: true, sloppy: true, forin: true, newcap: true, plusplus: true, maxerr: 50, indent: 4 */ +/*jslint nomen: true, devel: true, undef: true, browser: true, continue: true, sloppy: true, forin: true, newcap: true, plusplus: true, maxerr: 50, indent: 4 */ /*global gateway, io, $, iScroll, agent, touchscreen, init_data, plugs, plugins, registerTouches, randomString */ kiwi.front = { revision: 38, @@ -83,8 +83,8 @@ kiwi.front = { $('
').appendTo('#kiwi'); $('#nicklist_resize').draggable({axis: "x", drag: function () { var t = $(this), - new_width = $(document).width() - parseInt(t.css('left'), 10); - + new_width = $(document).width() - parseInt(t.css('left'), 10); + new_width = new_width - parseInt($('#kiwi .userlist').css('margin-left'), 10); new_width = new_width - parseInt($('#kiwi .userlist').css('margin-right'), 10); @@ -194,6 +194,8 @@ kiwi.front = { kiwi.front.joinChannel($(this).text()); return false; }); + + kiwi.data.set('chanList', []); (function () { var i; @@ -346,8 +348,8 @@ kiwi.front = { case '/k': case '/kick': if (typeof parts[1] === 'undefined') { - return; - } + return; + } kiwi.gateway.raw('KICK ' + kiwi.front.cur_channel.name + ' ' + msg.split(' ', 2)[1]); break; @@ -614,14 +616,30 @@ kiwi.front = { }, onChannelListStart: function (e, data) { - console.log('Channel listing started'); + kiwi.data.set('chanList', []); }, onChannelList: function (e, data) { - var network_name = kiwi.gateway.network_name; - kiwi.front.tabviews.server.addMsg(null, network_name, data.channel + ' (' + data.num_users + ') ' + data.topic, ''); + var network_name = kiwi.gateway.network_name, + chanList = kiwi.data.get('chanList'); + chanList.push(data); + kiwi.data.set('chanList', chanList); }, onChannelListEnd: function (e, data) { - console.log('Channel listing ended'); + var chanList, tab, table, body, chan; + + chanList = kiwi.data.get('chanList'); + tab = new Utilityview('Channel List'); + table = $(''); + body = table.children('tbody:first'); + chanList = _.sortBy(chanList, function (channel) { + return parseInt(channel.num_users, 10); + }).reverse(); + for (chan in chanList) { + body.append($('')); + } + tab.div.append(table); + tab.div.css('overflow-y', 'scroll'); + tab.show(); }, @@ -1369,8 +1387,8 @@ Tabview.prototype.close = function () { Tabview.prototype.setUserlistWidth = function (new_width) { var w, u; if (typeof new_width === 'number') { - this.userlist_width = new_width; - } + this.userlist_width = new_width; + } w = $('#windows'); u = $('#kiwi .userlist'); diff --git a/js/underscore.min.js b/js/underscore.min.js new file mode 120000 index 0000000..30be3eb --- /dev/null +++ b/js/underscore.min.js @@ -0,0 +1 @@ +../node/lib/underscore.min.js \ No newline at end of file diff --git a/node/app.js b/node/app.js index 5f33851..6025dd4 100644 --- a/node/app.js +++ b/node/app.js @@ -504,11 +504,12 @@ this.httpHandler = function (request, response) { if (kiwi.cache.alljs === '') { public_http_path = kiwi.kiwi_root + '/' + kiwi.config.public_http; + min.underscore = fs.readFileSync(public_http_path + 'js/underscore.min.js'); min.util = fs.readFileSync(public_http_path + 'js/util.js'); min.gateway = fs.readFileSync(public_http_path + 'js/gateway.js'); min.front = fs.readFileSync(public_http_path + 'js/front.js'); min.iscroll = fs.readFileSync(public_http_path + 'js/iscroll.js'); - min.ast = jsp.parse(min.util + min.gateway + min.front + min.iscroll); + min.ast = jsp.parse(min.underscore + min.util + min.gateway + min.front + min.iscroll); min.ast = pro.ast_mangle(min.ast); min.ast = pro.ast_squeeze(min.ast); min.final_code = pro.gen_code(min.ast); diff --git a/node/client/index.html.jade b/node/client/index.html.jade index 8278d9f..42484ca 100644 --- a/node/client/index.html.jade +++ b/node/client/index.html.jade @@ -17,6 +17,7 @@ html(xmlns="http://www.w3.org/1999/xhtml", lang="en-gb") script(type="text/javascript", src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js") script(type="text/javascript", src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js") script(type="text/javascript", src="/js/jquery.json-2.2.min.js") + //script(type="text/javascript", src="/js/underscore.min.js") //script(type="text/javascript", src="/js/util.js") //script(type="text/javascript", src="/js/gateway.js") //script(type="text/javascript", src="/js/front.js") -- 2.25.1
Channel NameMembersTopic
' + chanList[chan].channel + '' + chanList[chan].num_users + '' + chanList[chan].topic + '