Editable topic bar
authorJack Allnutt <m2ys4u@Gmail.com>
Wed, 27 Jul 2011 01:29:49 +0000 (02:29 +0100)
committerJack Allnutt <m2ys4u@Gmail.com>
Wed, 27 Jul 2011 01:29:49 +0000 (02:29 +0100)
js/front.js
node/client/index.html.jade

index 3259bc97819211d72e05e9dfc971f105ff817708..4880cef8f85310705194484cee5833bd0ae5aa05 100644 (file)
@@ -8,6 +8,8 @@ var front = {
        
        buffer: [],
        buffer_pos: 0,
+
+    original_topic: '',
        
        init: function () {     
                gateway.nick = 'kiwi_' + Math.ceil(100 * Math.random()) + Math.ceil(100 * Math.random());
@@ -103,6 +105,27 @@ var front = {
                
                //gateway.session_id = 'testses';
                
+        $('.cur_topic').live('keypress', function(e) {
+            if (e.keyCode === 13) {
+                e.preventDefault();
+                $(this).change();
+                $('#kiwi_msginput').focus();
+            }
+        });
+        $('.cur_topic').live('change', function (e) {
+            var chan, text;
+            text = $(this).text();
+            console.debug(text);
+            console.debug(front.original_topic);
+            console.debug(text === front.original_topic);
+            if (text !== front.original_topic) {
+                console.debug('sending topic msg');
+                chan = front.cur_channel.name;
+                gateway.raw('TOPIC ' + chan + ' :' + text);
+            }
+        });
+        
+        
                gateway.start();
                //front.sync();
        },
@@ -788,6 +811,7 @@ var front = {
        
        
        setTopicText: function (new_topic) {
+        front.original_topic = new_topic;
                $('#kiwi .cur_topic .topic').text(new_topic);
                front.doLayoutSize();
        },
index 77e9dbe99ed6977cdc295460b98bbbd1d629cef0..a4fd68a82efbf1c13041244e21400eb3883b086f 100644 (file)
@@ -147,7 +147,7 @@ html(xmlns="http://www.w3.org/1999/xhtml", lang="en-gb")
                 div.poweredby Powered by Kiwi IRC
                 ul
 
-            div.cur_topic
+            div.cur_topic(contenteditable="true", spellcheck="true")
                 //
                     ul.edit(style="float:right;")
                         li