From 110ce6d4e8a84e9a8130357dbd12b1fb557fe4e7 Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Wed, 27 Jul 2011 02:29:49 +0100 Subject: [PATCH] Editable topic bar --- js/front.js | 24 ++++++++++++++++++++++++ node/client/index.html.jade | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/js/front.js b/js/front.js index 3259bc9..4880cef 100644 --- a/js/front.js +++ b/js/front.js @@ -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(); }, diff --git a/node/client/index.html.jade b/node/client/index.html.jade index 77e9dbe..a4fd68a 100644 --- a/node/client/index.html.jade +++ b/node/client/index.html.jade @@ -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 -- 2.25.1