Simpler QR quoting code.

This commit is contained in:
Mayhem 2013-07-02 15:19:15 +02:00
parent 2939a81a21
commit 97087af42f

View File

@ -327,12 +327,9 @@ QR =
return unless QR.postingIsEnabled return unless QR.postingIsEnabled
sel = d.getSelection() sel = d.getSelection()
selectionRoot = $.x 'ancestor::div[contains(@class,"postContainer")][1]', sel.anchorNode
post = Get.postFromNode @ post = Get.postFromNode @
{OP} = Get.contextFromLink(@).thread
text = ">>#{post}\n" text = ">>#{post}\n"
if (s = sel.toString().trim()) and post.nodes.root is selectionRoot if (s = sel.toString().trim()) and post is Get.postFromNode sel.anchorNode
# XXX Opera doesn't retain `\n`s? # XXX Opera doesn't retain `\n`s?
s = s.replace /\n/g, '\n>' s = s.replace /\n/g, '\n>'
text += ">#{s}\n" text += ">#{s}\n"
@ -344,7 +341,7 @@ QR =
$.addClass QR.nodes.el, 'dump' $.addClass QR.nodes.el, 'dump'
QR.cooldown.auto = true QR.cooldown.auto = true
{com, thread} = QR.nodes {com, thread} = QR.nodes
thread.value = OP.ID unless com.value thread.value = Get.contextFromLink(@).thread unless com.value
caretPos = com.selectionStart caretPos = com.selectionStart
# Replace selection for text. # Replace selection for text.