From fee03312d76d115e081f9a96fd95b54259579559 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 5 Oct 2014 17:26:50 -0700 Subject: [PATCH] optional backlink hiding --- js/inline.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/js/inline.js b/js/inline.js index e4b24381..1ce0edc3 100644 --- a/js/inline.js +++ b/js/inline.js @@ -51,14 +51,11 @@ var $root = $(this).closest('.post') var targetNum = this.textContent.slice(2) - var $clone = $root.find('#inline_' + targetNum) - if ($clone.length) - return $clone.remove() - var srcOP = $root.closest('[id^=thread]').attr('id').match(/\d+/)[0] var node, targetOP - if (this.className) {// backlink + var isBacklink = !!this.className + if (isBacklink) { node = $root.find('> .intro') targetOP = srcOP } else { @@ -67,14 +64,25 @@ } var link = { - node: node, - id: 'inline_' + targetNum + id: 'inline_' + targetNum, + isBacklink: isBacklink, + node: node } var selector = targetNum === targetOP ? '#op_' + srcOP : '#reply_' + targetNum + var $clone = $root.find('#inline_' + targetNum) + if ($clone.length) { + $clone.remove() + $(selector) + .show() + .next() + .show() + return + } + if (srcOP === targetOP) { if (targetNum === targetOP) link.node = link.node.next()// bypass `(OP)` @@ -97,6 +105,13 @@ var add = function(link, $target) { var $clone = $target.clone(true) + + if (link.isBacklink && App.options.get('hidePost')) + $target + .hide() + .next() + .hide() + $clone.find('.inline').remove() $clone.attr({ "class": 'inline post', @@ -106,10 +121,7 @@ $clone.insertAfter(link.node) } - App.options.add('inline', 'Inline quoted posts') - - if (!App.options.get('inline')) - return + App.options.add('hidePost', 'Hide inlined backlinked posts') $('head').append( '