From 37f8c16c885bb8a163b28241b07e33ccab5c26a8 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 3 Sep 2011 15:30:44 -0700 Subject: [PATCH] quote keybind --- 4chan_x.user.js | 18 +++++++++++------- script.coffee | 15 ++++++++------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index b7ec7269d..2aa85fa41 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -907,17 +907,19 @@ } }, qr: function(thread, quote) { - var qrLink; + var qrLink, tid; if (!(qrLink = $('td.replyhl span[id] a:not(:first-child)', thread))) { qrLink = $("span[id^=nothread] a:not(:first-child)", thread); } + tid = g.THREAD_ID || thread.firstChild.id; if (quote) { - return qr.quote.call(qrLink); + return QR.quote.call(qrLink); } else { - if (!qr.el) { - qr.dialog(qrLink); + if (QR.qr) { + return $('textarea', QR.qr).focus(); + } else { + return QR.dialog('', tid); } - return $('textarea', qr.el).focus(); } }, open: function(thread, tab) { @@ -1405,9 +1407,11 @@ e.preventDefault(); return QR.submit(); }, - quote: function(e) { + quote: function(e, blank) { var i, id, qr, s, sel, ss, ta, text, tid, v, _ref; - e.preventDefault(); + if (e != null) { + e.preventDefault(); + } tid = g.THREAD_ID || $.x('ancestor::div[@class="thread"]/div', this).id; id = this.textContent; text = ">>" + id + "\n"; diff --git a/script.coffee b/script.coffee index 48785a622..15140d794 100644 --- a/script.coffee +++ b/script.coffee @@ -652,13 +652,14 @@ keybinds = qr: (thread, quote) -> unless qrLink = $ 'td.replyhl span[id] a:not(:first-child)', thread qrLink = $ "span[id^=nothread] a:not(:first-child)", thread - + tid = g.THREAD_ID or thread.firstChild.id if quote - qr.quote.call qrLink + QR.quote.call qrLink else - unless qr.el - qr.dialog qrLink - $('textarea', qr.el).focus() + if QR.qr + $('textarea', QR.qr).focus() + else + QR.dialog '', tid open: (thread, tab) -> id = thread.firstChild.id @@ -1107,8 +1108,8 @@ QR = QR.captchaPush @ e.preventDefault() QR.submit() #derpy, but prevents calling QR.hasContent twice - quote: (e) -> - e.preventDefault() + quote: (e, blank) -> + e?.preventDefault() tid = g.THREAD_ID or $.x('ancestor::div[@class="thread"]/div', @).id id = @textContent text = ">>#{id}\n"