From aa191535ff6a431c507333b339cdb184f660f4a2 Mon Sep 17 00:00:00 2001 From: Darren Date: Fri, 29 Jul 2011 23:42:52 +0100 Subject: [PATCH] Channel error/parting/banning messages moved to the relevant channel window Adjusted the topic esc key to work across browsers --- img/Thumbs.db | Bin 3072 -> 0 bytes js/front.js | 98 ++++++++++++++++++++++++++++++++++++-------------- js/gateway.js | 12 +++++++ node/kiwi.js | 5 +++ 4 files changed, 89 insertions(+), 26 deletions(-) delete mode 100644 img/Thumbs.db diff --git a/img/Thumbs.db b/img/Thumbs.db deleted file mode 100644 index 5ffc0f10823e3dcc37d9477f965a0e98a1c2b1b4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3072 zcmca`Uhu)fjZzO8(10BSGsD0CoD6J8;*3Bx2!nwD0|OI~0pkDr|NlQkkbwcn90fxt z1pWfu3W`4vW`V}#5OV&gQz;CAAclM(EMZV!aAn8?(nSoFu&hiJEylnK&-3uI0f){7 zg1YmLd7NQn2Ff1*5kO$XV9H>|5YJ%AkOstw3`qFNjV73W^F;Lb7EDBMLNop}L zF@nk=STJC!z%KG1qzMRM_8WoiHv_sQmBAe73KO6^l7M0$`$2BP1%UR$?FP94mpWu| z9w4V1S%5+|%Wy96-zo#9Tnk4aA@_f)_~hLD|Um zj?!9LeRE)c?qW*Qdtm1m_p#Ix?=SEGDF^MRc zQ|IAdW+|sNZPxqA>(_I;=f@s+rER`%*Bp`e$2ThM%vii#wzWKa!;_K&F!DGshUMoiQn5-R7tqGgOkgp(f!jxBc3fhjh{WrxNb-%YWcRe z-FNX>-5TfFx@?toSLi^Ie6a5_P z86Wc|C^>Ihq@eRc!Nv8@tSIMWs?wj<$2=A~WU+6@+$Xga!qfhkyyy&fRdNcH%+z{& zUEtaBT8(X2m7j0w?LM!*P0HQkkmH@r{QEcrKCp&l2eu@)=!!Kzn!fOU{-J4ZcO>tN z`Q40t^7f_6y_ZE9PYog_b(r4dw_I^+is;v0A`$&l6E?2qHNJGY#r5GH%gJF@^B3;8 z)6{!0@N4S=t1}A}dA9^!-E`=H6VJc)3FrPWyZ&{K4dH)p)xYN#o60APi?^KeHcxC@qn2f#u%zGbdY+nXUT0j| zvcP&zJ=<+FGS<9|Yr4(*spqh-uN!x5K=H5o6USrucFirFa4hQW?mPB#OjE?RR2Xgo zCRPSdS3j3^P6 Invalid command: '+parts[0].substring(1)); @@ -461,9 +489,12 @@ var front = { }, onKick: function (e, data) { if (front.tabviewExists(data.channel)) { - // If this is us, close the tabvi ew + // If this is us, close the tabview if (data.kicked === gateway.nick) { - front.tabviews[data.channel.toLowerCase()].close(); + //front.tabviews[data.channel.toLowerCase()].close(); + front.tabviews[data.channel.toLowerCase()].addMsg(null, ' ', '=== You have been kicked from ' + data.channel + '. ' + data.message, 'status'); + front.tabviews[data.channel.toLowerCase()].safe_to_close = true; + $('li', front.tabviews[data.channel.toLowerCase()].userlist).remove(); return; } @@ -506,18 +537,29 @@ var front = { }, onIRCError: function (e, data) { + var t_view; + if (data.channel !== undefined && front.tabviewExists(data.channel)) { + t_view = data.channel; + } else { + t_view = 'server'; + } + switch(data.error) { case 'banned_from_channel': - front.tabviews.server.addMsg(null, ' ', '=== You are banned from ' + data.channel + ': ' + data.reason, 'status'); + front.tabviews[t_view].addMsg(null, ' ', '=== You are banned from ' + data.channel + '. ' + data.reason, 'status'); + if (t_view !== 'server' ) front.tabviews[t_view].safe_to_close = true; break; case 'bad_channel_key': - front.tabviews.server.addMsg(null, ' ', '=== Bad channel key for ' + data.channel, 'status'); + front.tabviews[t_view].addMsg(null, ' ', '=== Bad channel key for ' + data.channel, 'status'); + if (t_view !== 'server' ) front.tabviews[t_view].safe_to_close = true; break; case 'invite_only_channel': - front.tabviews.server.addMsg(null, ' ', '=== ' + data.channel + ' is invite only.', 'status'); + front.tabviews[t_view].addMsg(null, ' ', '=== ' + data.channel + ' is invite only.', 'status'); + if (t_view !== 'server' ) front.tabviews[t_view].safe_to_close = true; break; case 'channel_is_full': - front.tabviews.server.addMsg(null, ' ', '=== ' + data.channel + ' is full.', 'status'); + front.tabviews[t_view].addMsg(null, ' ', '=== ' + data.channel + ' is full.', 'status'); + if (t_view !== 'server' ) front.tabviews[t_view].safe_to_close = true; break; case 'chanop_privs_needed': front.tabviews[data.channel].addMsg(null, ' ', '=== ' + data.reason, 'status'); @@ -533,11 +575,12 @@ var front = { registerKeys: function () { $('#kiwi_msginput').bind('keydown', function (e) { var windows = $('#windows'); - console.log(e.which); - //$('input').keypress(function(e){ + //var meta = e.altKey; + var meta = e.ctrlKey; + switch (true) { case (e.which >= 48) && (e.which <= 57): - if(e.altKey){ + if(meta){ var num = e.which - 48; if(num === 0) num = 10; num = num - 1; @@ -568,7 +611,7 @@ var front = { return false; break; case e.which === 37: // left - if(e.altKey){ + if(meta){ front.windowsPrevious(); return false; } @@ -580,7 +623,7 @@ var front = { } break; case e.which === 39: // right - if(e.altKey){ + if(meta){ front.windowsNext(); return false; } @@ -767,9 +810,11 @@ var front = { var tmp_userlistname = 'kiwi_userlist_' + htmlsafe_name; var tmp_tabname = 'kiwi_tab_' + htmlsafe_name - $('#kiwi .windows .scroller').append('
'); - $('#kiwi .userlist').append('
    '); - $('#kiwi .windowlist ul').append('
  • ' + v_name + '
  • '); + if(!front.tabviewExists(v_name)){ + $('#kiwi .windows .scroller').append('
    '); + $('#kiwi .userlist').append('
      '); + $('#kiwi .windowlist ul').append('
    • ' + v_name + '
    • '); + } //$('#kiwi .windowlist ul .window_'+v_name).click(function(){ front.windowShow(v_name); }); //front.windowShow(v_name); @@ -975,6 +1020,7 @@ tabview.prototype.div = null; tabview.prototype.userlist = null; tabview.prototype.tab = null; tabview.prototype.topic = ""; +tabview.prototype.safe_to_close = false; // If we have been kicked/banned/etc from this channel, don't wait for a part message tabview.prototype.show = function(){ $('#kiwi .messages').removeClass("active"); @@ -1006,7 +1052,7 @@ tabview.prototype.close = function(){ this.userlist.remove(); this.tab.remove(); - front.tabviews['server'].show(); + if(front.cur_channel == this) front.tabviews['server'].show(); delete front.tabviews[this.name.toLowerCase()]; } diff --git a/js/gateway.js b/js/gateway.js index 320f8b7..d7fda90 100644 --- a/js/gateway.js +++ b/js/gateway.js @@ -157,6 +157,18 @@ var gateway = { gateway.sendData(data, callback); }, + setTopic: function (s_channel, new_topic, callback){ + var data = { + method: 'topic', + args: { + channel: s_channel, + topic: new_topic + } + }; + + gateway.sendData(data, callback); + }, + raw: function (v_data, callback) { var data = { diff --git a/node/kiwi.js b/node/kiwi.js index e26482b..4183802 100644 --- a/node/kiwi.js +++ b/node/kiwi.js @@ -526,6 +526,11 @@ io.of('/kiwi').on('connection', function (websocket) { }); } break; + case 'topic': + if (args.channel) { + websocket.ircSocket.write('TOPIC ' + args.channel + ' :' + args.topic + '\r\n'); + } + break; case 'quit': websocket.ircSocket.end('QUIT :' + args.message + '\r\n'); websocket.sentQUIT = true; -- 2.25.1