op backlinks

This commit is contained in:
James Campos 2011-05-28 11:34:34 -07:00
parent 5eac55bb49
commit 60e718bc9f
2 changed files with 9 additions and 5 deletions

View File

@ -91,6 +91,7 @@
},
quote: {
'Quote Backlinks': [true, 'Add quote backlinks'],
'OP Backlinks': [false, 'Add backlinks to the OP'],
'Quote Inline': [true, 'Show quoted post inline on quote click'],
'Quote Preview': [true, 'Show quote content on hover'],
'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes']
@ -1711,8 +1712,8 @@
return g.callbacks.push(quoteBacklink.node);
},
node: function(root) {
var container, el, id, link, qid, quote, quotes, tid, _i, _len, _ref, _results;
if (root.className) {
var container, el, id, link, opbl, qid, quote, quotes, tid, _i, _len, _ref, _results;
if (/inline/.test(root.className)) {
return;
}
container = $.el('span', {
@ -1722,13 +1723,14 @@
id = root.id || $('td[id]', root).id;
quotes = {};
tid = g.THREAD_ID || root.parentNode.firstChild.id;
opbl = $.config('OP Backlinks');
_ref = $$('a.quotelink', root);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote = _ref[_i];
if (!(qid = quote.hash.slice(1))) {
continue;
}
if (qid === tid) {
if (!opbl && qid === tid) {
continue;
}
quotes[qid] = quote;

View File

@ -31,6 +31,7 @@ config =
'Persistent QR': [false, 'Quick reply won\'t disappear after posting. Only in replies.']
quote:
'Quote Backlinks': [true, 'Add quote backlinks']
'OP Backlinks': [false, 'Add backlinks to the OP']
'Quote Inline': [true, 'Show quoted post inline on quote click']
'Quote Preview': [true, 'Show quote content on hover']
'Indicate OP quote': [true, 'Add \'(OP)\' to OP quotes']
@ -1380,17 +1381,18 @@ quoteBacklink =
init: ->
g.callbacks.push quoteBacklink.node
node: (root) ->
return if root.className
return if /inline/.test root.className
container = $.el 'span',
className: 'container'
$.before $('br, blockquote', root), container
id = root.id or $('td[id]', root).id
quotes = {}
tid = g.THREAD_ID or root.parentNode.firstChild.id
opbl = $.config 'OP Backlinks'
for quote in $$ 'a.quotelink', root
continue unless qid = quote.hash[1..]
#don't backlink the op
continue if qid == tid
continue if !opbl and qid is tid
#duplicate quotes get overwritten
quotes[qid] = quote
for qid, quote of quotes