From 425b95a1e2cacd19cd2298c135aa370e6f15f4bf Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Mon, 30 Apr 2012 04:29:20 +0200 Subject: [PATCH] Quote Previewing and QR fixes. Quote previewing works, but UI doesn't so you won't see anything. --- 4chan_x.user.js | 19 +++++++++---------- script.coffee | 21 ++++++++------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 3ad45d0b4..1475c7552 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1360,7 +1360,7 @@ return $.on(d, 'dragstart dragend', QR.drag); }, node: function(post) { - return $.on($('.postInfo > .postNum > a:last-child', post.el), 'click', QR.quote); + return $.on($('.postInfo > .postNum > a[title="Quote this post"]', post.el), 'click', QR.quote); }, open: function() { if (QR.el) { @@ -1481,7 +1481,7 @@ if (!g.REPLY) { $('select', QR.el).value = $.x('ancestor::div[@class="thread"]', this).id.slice(1); } - id = this.hash.slice(2); + id = this.parentNode.parentNode.id.slice(2); text = ">>" + id + "\n"; sel = window.getSelection(); if ((s = sel.toString()) && id === ((_ref = $.x('ancestor-or-self::blockquote', sel.anchorNode)) != null ? _ref.id.slice(1) : void 0)) { @@ -3249,7 +3249,7 @@ } }, mouseover: function(e) { - var el, id, node, qp, quote, replyID, threadID, _i, _len, _ref; + var el, id, qp, quote, replyID, threadID, _i, _len, _ref; if (/\binlined\b/.test(this.className)) { return; } @@ -3258,14 +3258,13 @@ className: 'reply dialog' }); $.add(d.body, qp); - id = this.hash.slice(1); - if (el = $.id(id)) { + id = this.hash.slice(2); + if (el = $.id("p" + id)) { qp.innerHTML = el.innerHTML; if (Conf['Quote Highlighting']) { $.addClass(el, 'qphl'); } - node = /\bbacklink\b/.test(this.className) ? this.parentNode : $.x('ancestor::blockquote', this); - replyID = $.x('preceding-sibling::input', node).name; + replyID = $.x('ancestor::div[contains(@class,"post")]', this).id; _ref = $$('.quotelink, .backlink', qp); for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; @@ -3275,7 +3274,7 @@ } } else { qp.textContent = "Loading " + id + "..."; - threadID = this.pathname.split('/').pop() || $.x('ancestor::div[@class="thread"]', this).firstChild.id; + threadID = this.pathname.split('/').pop(); $.cache(this.pathname, (function() { return QuotePreview.parse(this, id, threadID); })); @@ -3304,10 +3303,10 @@ } doc = d.implementation.createHTMLDocument(''); doc.documentElement.innerHTML = req.response; - node = doc.getElementById(id); + node = doc.getElementById("p" + id); qp.innerHTML = node.innerHTML; post = { - root: qp, + el: qp, filesize: $('.filesize', qp), img: $('img[data-md5]', qp) }; diff --git a/script.coffee b/script.coffee index ae58701ef..d15e27bcc 100644 --- a/script.coffee +++ b/script.coffee @@ -1030,7 +1030,7 @@ QR = $.on d, 'dragstart dragend', QR.drag node: (post) -> - $.on $('.postInfo > .postNum > a:last-child', post.el), 'click', QR.quote + $.on $('.postInfo > .postNum > a[title="Quote this post"]', post.el), 'click', QR.quote open: -> if QR.el @@ -1116,7 +1116,7 @@ QR = $('select', QR.el).value = $.x('ancestor::div[@class="thread"]', @).id[1..] # Make sure we get the correct number, even with XXX censors - id = @hash[2..] + id = @parentNode.parentNode.id[2..] text = ">>#{id}\n" sel = window.getSelection() @@ -2518,22 +2518,17 @@ QuotePreview = className: 'reply dialog' $.add d.body, qp - id = @hash[1..] - if el = $.id id + id = @hash[2..] + if el = $.id "p#{id}" qp.innerHTML = el.innerHTML $.addClass el, 'qphl' if Conf['Quote Highlighting'] - node = - if /\bbacklink\b/.test @className - @parentNode - else - $.x 'ancestor::blockquote', @ - replyID = $.x('preceding-sibling::input', node).name + replyID = $.x('ancestor::div[contains(@class,"post")]', @).id for quote in $$ '.quotelink, .backlink', qp if quote.hash[1..] is replyID $.addClass quote, 'forwardlink' else qp.textContent = "Loading #{id}..." - threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]', @).firstChild.id + threadID = @pathname.split('/').pop() $.cache @pathname, (-> QuotePreview.parse @, id, threadID) UI.hover e $.on @, 'mousemove', UI.hover @@ -2554,10 +2549,10 @@ QuotePreview = doc = d.implementation.createHTMLDocument '' doc.documentElement.innerHTML = req.response - node = doc.getElementById id + node = doc.getElementById "p#{id}" qp.innerHTML = node.innerHTML post = - root: qp + el: qp filesize: $ '.filesize', qp img: $ 'img[data-md5]', qp if Conf['Image Auto-Gif']