From d1d949cd7dae1d882b139e8e0e76c15cf11a36f2 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 17 Jun 2012 00:10:36 +0200 Subject: [PATCH] Fix Quote Highlighing getting inside the Quote Preview. --- 4chan_x.user.js | 38 +++++++++++++++++++++----------------- script.coffee | 23 +++++++++++++---------- 2 files changed, 34 insertions(+), 27 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index a69f69c3c..3e9da4b64 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -3530,6 +3530,9 @@ }); UI.hover(e); $.add(d.body, qp); + if (board === g.BOARD) { + el = $.id("p" + postID); + } Get.post(board, threadID, postID, qp, function() { var bq, img, post; bq = $('blockquote', qp); @@ -3559,25 +3562,26 @@ return Quotify.node(post); } }); - if (board === g.BOARD && (el = $.id("p" + postID))) { - if (Conf['Quote Highlighting']) { - if (/\bop\b/.test(el.className)) { - $.addClass(el.parentNode, 'qphl'); - } else { - $.addClass(el, 'qphl'); - } - } - quoterID = $.x('ancestor::*[@id][1]', this).id.match(/\d+$/)[0]; - _ref = $$('.quotelink, .backlink', qp); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - quote = _ref[_i]; - if (quote.hash.slice(2) === quoterID) { - $.addClass(quote, 'forwardlink'); - } + $.on(this, 'mousemove', UI.hover); + $.on(this, 'mouseout click', QuotePreview.mouseout); + if (!el) { + return; + } + if (Conf['Quote Highlighting']) { + if (/\bop\b/.test(el.className)) { + $.addClass(el.parentNode, 'qphl'); + } else { + $.addClass(el, 'qphl'); + } + } + quoterID = $.x('ancestor::*[@id][1]', this).id.match(/\d+$/)[0]; + _ref = $$('.quotelink, .backlink', qp); + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + quote = _ref[_i]; + if (quote.hash.slice(2) === quoterID) { + $.addClass(quote, 'forwardlink'); } } - $.on(this, 'mousemove', UI.hover); - return $.on(this, 'mouseout click', QuotePreview.mouseout); }, mouseout: function(e) { var el; diff --git a/script.coffee b/script.coffee index 85cc09823..ff7d4be35 100644 --- a/script.coffee +++ b/script.coffee @@ -2750,6 +2750,7 @@ QuotePreview = className: 'reply dialog' UI.hover e $.add d.body, qp + el = $.id "p#{postID}" if board is g.BOARD Get.post board, threadID, postID, qp, -> bq = $ 'blockquote', qp Main.prettify bq @@ -2771,18 +2772,20 @@ QuotePreview = if Conf['Resurrect Quotes'] Quotify.node post - if board is g.BOARD and el = $.id "p#{postID}" - if Conf['Quote Highlighting'] - if /\bop\b/.test el.className - $.addClass el.parentNode, 'qphl' - else - $.addClass el, 'qphl' - quoterID = $.x('ancestor::*[@id][1]', @).id.match(/\d+$/)[0] - for quote in $$ '.quotelink, .backlink', qp - if quote.hash[2..] is quoterID - $.addClass quote, 'forwardlink' $.on @, 'mousemove', UI.hover $.on @, 'mouseout click', QuotePreview.mouseout + + return unless el + if Conf['Quote Highlighting'] + if /\bop\b/.test el.className + $.addClass el.parentNode, 'qphl' + else + $.addClass el, 'qphl' + quoterID = $.x('ancestor::*[@id][1]', @).id.match(/\d+$/)[0] + for quote in $$ '.quotelink, .backlink', qp + if quote.hash[2..] is quoterID + $.addClass quote, 'forwardlink' + return mouseout: (e) -> UI.hoverend() if el = $.id @hash[1..]