Simpler QR quoting code.

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

View File

@ -326,13 +326,10 @@ QR =
e?.preventDefault() e?.preventDefault()
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 @ text = ">>#{post}\n"
{OP} = Get.contextFromLink(@).thread if (s = sel.toString().trim()) and post is Get.postFromNode sel.anchorNode
text = ">>#{post}\n"
if (s = sel.toString().trim()) and post.nodes.root is selectionRoot
# 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.