From 09bd4e2f4257b0e16899fa63c22823e03697608f Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 26 Apr 2010 22:28:32 -0700 Subject: [PATCH] auto-quote highlighted text --- 4chan_x/4chan_x.coffee | 6 ++++++ 4chan_x/4chan_x.js | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/4chan_x/4chan_x.coffee b/4chan_x/4chan_x.coffee index eb4ee7385..44e9b1610 100644 --- a/4chan_x/4chan_x.coffee +++ b/4chan_x/4chan_x.coffee @@ -452,7 +452,13 @@ quickReply: (e) -> textarea: $('textarea', qr) #goddamit moot + #xx textarea.value += '>>' + this.parentNode.id.match(/\d+$/)[0] + '\n' + selection: window.getSelection() + selid: x('ancestor::td', selection.anchorNode)?.id + if selid == x('ancestor::td', this).id + if selText: selection.toString() + textarea.value += ">$selText\n" textarea.focus() diff --git a/4chan_x/4chan_x.js b/4chan_x/4chan_x.js index b8a00d86a..7e01eeb2c 100644 --- a/4chan_x/4chan_x.js +++ b/4chan_x/4chan_x.js @@ -462,7 +462,7 @@ cursor: pointer; \ } }; quickReply = function quickReply(e) { - var a, clone, div, input, qr, textarea, xpath; + var _c, a, clone, div, input, qr, selText, selection, selid, textarea, xpath; e.preventDefault(); if (!(qr = $('#qr'))) { qr = tag('div'); @@ -503,7 +503,11 @@ cursor: pointer; \ } textarea = $('textarea', qr); //goddamit moot + //xx textarea.value += '>>' + this.parentNode.id.match(/\d+$/)[0] + '\n'; + selection = window.getSelection(); + selid = (_c = x('ancestor::td', selection.anchorNode)) == undefined ? undefined : _c.id; + selid === x('ancestor::td', this).id ? (selText = selection.toString()) ? textarea.value += (">" + selText + "\n") : null : null; return textarea.focus(); }; watch = function watch() {