From c720b90a86a955e2be26cbcc156ad671ee647060 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Thu, 3 Jan 2013 15:34:15 +0100 Subject: [PATCH] When quoting on the index, only change the target thread if the textarea is empty. Close #879 --- 4chan_x.user.js | 4 ++-- script.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3a9c9043b..48331ffc0 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1993,7 +1993,8 @@ e.preventDefault(); } QR.open(); - if (!g.REPLY) { + ta = $('textarea', QR.el); + if (!(g.REPLY || ta.value)) { QR.threadSelector.value = $.x('ancestor::div[parent::div[@class="board"]]', this).id.slice(1); } id = this.previousSibling.hash.slice(2); @@ -2003,7 +2004,6 @@ s = s.replace(/\n/g, '\n>'); text += ">" + s + "\n"; } - ta = $('textarea', QR.el); caretPos = ta.selectionStart; ta.value = ta.value.slice(0, caretPos) + text + ta.value.slice(ta.selectionEnd); range = caretPos + text.length; diff --git a/script.coffee b/script.coffee index 6eda9ea16..dec870351 100644 --- a/script.coffee +++ b/script.coffee @@ -1550,7 +1550,8 @@ QR = quote: (e) -> e?.preventDefault() QR.open() - unless g.REPLY + ta = $ 'textarea', QR.el + unless g.REPLY or ta.value QR.threadSelector.value = $.x('ancestor::div[parent::div[@class="board"]]', @).id[1..] # Make sure we get the correct number, even with XXX censors id = @previousSibling.hash[2..] @@ -1562,7 +1563,6 @@ QR = s = s.replace /\n/g, '\n>' text += ">#{s}\n" - ta = $ 'textarea', QR.el caretPos = ta.selectionStart # Replace selection for text. ta.value = ta.value[...caretPos] + text + ta.value[ta.selectionEnd..]