Merge pull request #360 from MayhemYDG/master

Fix weird backlink bug
This commit is contained in:
James Campos 2011-10-31 09:16:37 -07:00
commit dfa4d17ba6
2 changed files with 15 additions and 13 deletions

View File

@ -2336,11 +2336,10 @@
format = conf['backlink'].replace(/%id/, "' + id + '"); format = conf['backlink'].replace(/%id/, "' + id + '");
quoteBacklink.funk = Function('id', "return'" + format + "'"); quoteBacklink.funk = Function('id', "return'" + format + "'");
return g.callbacks.push(function(root) { return g.callbacks.push(function(root) {
var container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results; var a, container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results;
if (root.classList.contains('inline')) { if (root.classList.contains('inline')) {
return; return;
} }
id = $('input', root).name;
quotes = {}; quotes = {};
_ref = $$('.quotelink', root); _ref = $$('.quotelink', root);
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -2350,6 +2349,12 @@
} }
quotes[qid] = quote; quotes[qid] = quote;
} }
id = $('input', root).name;
a = $.el('a', {
href: "#" + id,
className: root.hidden ? 'filtered backlink' : 'backlink',
textContent: quoteBacklink.funk(id)
});
_results = []; _results = [];
for (qid in quotes) { for (qid in quotes) {
if (!(el = $.id(qid))) { if (!(el = $.id(qid))) {
@ -2358,11 +2363,7 @@
if (!conf['OP Backlinks'] && el.className === 'op') { if (!conf['OP Backlinks'] && el.className === 'op') {
continue; continue;
} }
link = $.el('a', { link = a.cloneNode(true);
href: "#" + id,
className: root.hidden ? 'filtered backlink' : 'backlink',
textContent: quoteBacklink.funk(id)
});
if (conf['Quote Preview']) { if (conf['Quote Preview']) {
$.bind(link, 'mouseover', quotePreview.mouseover); $.bind(link, 'mouseover', quotePreview.mouseover);
$.bind(link, 'mousemove', ui.hover); $.bind(link, 'mousemove', ui.hover);

View File

@ -1765,22 +1765,23 @@ quoteBacklink =
quoteBacklink.funk = Function 'id', "return'#{format}'" quoteBacklink.funk = Function 'id', "return'#{format}'"
g.callbacks.push (root) -> g.callbacks.push (root) ->
return if root.classList.contains 'inline' return if root.classList.contains 'inline'
# op or reply
id = $('input', root).name
quotes = {} quotes = {}
for quote in $$ '.quotelink', root for quote in $$ '.quotelink', root
#don't process >>>/b/ #don't process >>>/b/
continue unless qid = quote.hash[1..] continue unless qid = quote.hash[1..]
#duplicate quotes get overwritten #duplicate quotes get overwritten
quotes[qid] = quote quotes[qid] = quote
# op or reply
id = $('input', root).name
a = $.el 'a',
href: "##{id}"
className: if root.hidden then 'filtered backlink' else 'backlink'
textContent: quoteBacklink.funk id
for qid of quotes for qid of quotes
continue unless el = $.id qid continue unless el = $.id qid
#don't backlink the op #don't backlink the op
continue if !conf['OP Backlinks'] and el.className is 'op' continue if !conf['OP Backlinks'] and el.className is 'op'
link = $.el 'a', link = a.cloneNode true
href: "##{id}"
className: if root.hidden then 'filtered backlink' else 'backlink'
textContent: quoteBacklink.funk id
if conf['Quote Preview'] if conf['Quote Preview']
$.bind link, 'mouseover', quotePreview.mouseover $.bind link, 'mouseover', quotePreview.mouseover
$.bind link, 'mousemove', ui.hover $.bind link, 'mousemove', ui.hover