Fix cross-thread quotes after expanding the comment.

This commit is contained in:
Nicolas Stepien 2012-03-18 01:21:45 +01:00
parent 200ac59e12
commit b2792a05f9
2 changed files with 10 additions and 6 deletions

View File

@ -735,7 +735,7 @@
})); }));
}, },
parse: function(req, a, threadID, replyID) { parse: function(req, a, threadID, replyID) {
var doc, node, post, quote, quotes, _i, _len; var doc, href, node, post, quote, quotes, _i, _len;
if (req.status !== 200) { if (req.status !== 200) {
a.textContent = "" + req.status + " " + req.statusText; a.textContent = "" + req.status + " " + req.statusText;
return; return;
@ -747,8 +747,10 @@
quotes = node.getElementsByClassName('quotelink'); quotes = node.getElementsByClassName('quotelink');
for (_i = 0, _len = quotes.length; _i < _len; _i++) { for (_i = 0, _len = quotes.length; _i < _len; _i++) {
quote = quotes[_i]; quote = quotes[_i];
if (quote.hash === quote.getAttribute('href')) { if (quote.hash === (href = quote.getAttribute('href'))) {
quote.pathname = "/" + g.BOARD + "/res/" + threadID; quote.pathname = "/" + g.BOARD + "/res/" + threadID;
} else if (href !== quote.href) {
quote.href = "res/" + href;
} }
} }
post = { post = {
@ -853,7 +855,7 @@
_ref2 = $$('.quotelink', table); _ref2 = $$('.quotelink', table);
for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) { for (_j = 0, _len2 = _ref2.length; _j < _len2; _j++) {
quote = _ref2[_j]; quote = _ref2[_j];
if ((href = quote.getAttribute('href')) === quote.hash) { if (quote.hash === (href = quote.getAttribute('href'))) {
quote.pathname = pathname; quote.pathname = pathname;
} else if (href !== quote.href) { } else if (href !== quote.href) {
quote.href = "res/" + href; quote.href = "res/" + href;

View File

@ -646,8 +646,10 @@ ExpandComment =
quotes = node.getElementsByClassName 'quotelink' quotes = node.getElementsByClassName 'quotelink'
for quote in quotes for quote in quotes
if quote.hash is quote.getAttribute 'href' if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes
quote.pathname = "/#{g.BOARD}/res/#{threadID}" quote.pathname = "/#{g.BOARD}/res/#{threadID}"
else if href isnt quote.href # Fix cross-thread links, not cross-board ones
quote.href = "res/#{href}"
post = post =
el: node el: node
threadId: threadID threadId: threadID
@ -726,9 +728,9 @@ ExpandThread =
for reply in $$ '.reply', doc for reply in $$ '.reply', doc
table = d.importNode reply.parentNode.parentNode.parentNode table = d.importNode reply.parentNode.parentNode.parentNode
for quote in $$ '.quotelink', table for quote in $$ '.quotelink', table
if (href = quote.getAttribute 'href') is quote.hash #add pathname to normal quotes if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes
quote.pathname = pathname quote.pathname = pathname
else if href isnt quote.href #fix x-thread links, not x-board ones else if href isnt quote.href # Fix cross-thread links, not cross-board ones
quote.href = "res/#{href}" quote.href = "res/#{href}"
link = $ '.quotejs', table link = $ '.quotejs', table
link.href = "res/#{thread.firstChild.id}##{reply.id}" link.href = "res/#{thread.firstChild.id}##{reply.id}"