/list response now shows in a new tab
authorJack Allnutt <m2ys4u@Gmail.com>
Thu, 15 Sep 2011 14:51:14 +0000 (15:51 +0100)
committerJack Allnutt <m2ys4u@Gmail.com>
Thu, 15 Sep 2011 14:51:14 +0000 (15:51 +0100)
js/front.js
js/underscore.min.js [new symlink]
node/app.js
node/client/index.html.jade

index ce921cffd3cc17faf660acaea725c3ba9f24f6f1..b8c5ba0bd7d76d71fb51734f725dd2b25ae3943b 100644 (file)
@@ -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 = {
         $('<div id="nicklist_resize" style="position:absolute; cursor:w-resize; width:5px;"></div>').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 = $('<table><thead style="font-weight: bold;"><tr><td>Channel Name</td><td>Members</td><td style="padding-left: 2em;">Topic</td></tr></thead><tbody style="vertical-align: top;"></tbody>');
+        body = table.children('tbody:first');
+        chanList = _.sortBy(chanList, function (channel) {
+            return parseInt(channel.num_users, 10);
+        }).reverse();
+        for (chan in chanList) {
+            body.append($('<tr><td><a class="chan">' + chanList[chan].channel + '</a></td><td style="text-align: center;">' + chanList[chan].num_users + '</td><td style="padding-left: 2em;">' + chanList[chan].topic + '</td></tr>'));
+        }
+        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 (symlink)
index 0000000..30be3eb
--- /dev/null
@@ -0,0 +1 @@
+../node/lib/underscore.min.js
\ No newline at end of file
index 5f33851eeeee2f6a1e98ed8019d40366c16acef9..6025dd41a62a7bfd6f632d8f27142b224e87ddff 100644 (file)
@@ -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);
index 8278d9f5b69d92ac69abc7daa28e78ba51167210..42484ca17b058f645ff24dfb76c8732802e39186 100644 (file)
@@ -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")