Update Thread and Comment Expansion.

This commit is contained in:
Nicolas Stepien 2012-05-01 17:11:43 +02:00
parent bce07659a0
commit b8e953d4ae
2 changed files with 18 additions and 28 deletions

View File

@ -770,9 +770,9 @@
_ref = this.href.match(/(\d+)#p(\d+)/), _ = _ref[0], threadID = _ref[1], replyID = _ref[2]; _ref = this.href.match(/(\d+)#p(\d+)/), _ = _ref[0], threadID = _ref[1], replyID = _ref[2];
this.textContent = "Loading " + replyID + "..."; this.textContent = "Loading " + replyID + "...";
a = this; a = this;
return $.cache(this.pathname, (function() { return $.cache(this.pathname, function() {
return ExpandComment.parse(this, a, threadID, replyID); return ExpandComment.parse(this, a, threadID, replyID);
})); });
}, },
parse: function(req, a, threadID, replyID) { parse: function(req, a, threadID, replyID) {
var doc, href, node, post, quote, quotes, _i, _len; var doc, href, node, post, quote, quotes, _i, _len;
@ -786,11 +786,11 @@
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 === (href = quote.getAttribute('href'))) { href = quote.getAttribute('href');
quote.pathname = "/" + g.BOARD + "/res/" + threadID; if (href[0] === '/') {
} else if (href !== quote.href) { continue;
quote.href = "res/" + href;
} }
quote.href = "res/" + href;
} }
post = { post = {
el: node, el: node,
@ -846,9 +846,9 @@
$.rm(container); $.rm(container);
} }
a.textContent = a.textContent.replace('+', '\u00d7 Loading...'); a.textContent = a.textContent.replace('+', '\u00d7 Loading...');
return $.cache(pathname, (function() { return $.cache(pathname, function() {
return ExpandThread.parse(this, pathname, thread, a); return ExpandThread.parse(this, pathname, thread, a);
})); });
case '\u00d7': case '\u00d7':
a.textContent = a.textContent.replace('\u00d7 Loading...', '+'); a.textContent = a.textContent.replace('\u00d7 Loading...', '+');
return $.cache.requests[pathname].abort(); return $.cache.requests[pathname].abort();
@ -902,11 +902,10 @@
for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
quote = _ref1[_j]; quote = _ref1[_j];
href = quote.getAttribute('href'); href = quote.getAttribute('href');
if (quote.hash === href) { if (href[0] === '/') {
quote.pathname = pathname; continue;
} else if (href !== quote.href) {
quote.href = "res/" + href;
} }
quote.href = "res/" + href;
} }
id = reply.firstElementChild.id.slice(2); id = reply.firstElementChild.id.slice(2);
link = $('.postNum.desktop', reply).firstElementChild; link = $('.postNum.desktop', reply).firstElementChild;

View File

@ -614,7 +614,7 @@ ExpandComment =
[_, threadID, replyID] = @href.match /(\d+)#p(\d+)/ [_, threadID, replyID] = @href.match /(\d+)#p(\d+)/
@textContent = "Loading #{replyID}..." @textContent = "Loading #{replyID}..."
a = @ a = @
$.cache @pathname, (-> ExpandComment.parse @, a, threadID, replyID) $.cache @pathname, -> ExpandComment.parse @, a, threadID, replyID
parse: (req, a, threadID, replyID) -> parse: (req, a, threadID, replyID) ->
if req.status isnt 200 if req.status isnt 200
a.textContent = "#{req.status} #{req.statusText}" a.textContent = "#{req.status} #{req.statusText}"
@ -629,13 +629,9 @@ ExpandComment =
quotes = node.getElementsByClassName 'quotelink' quotes = node.getElementsByClassName 'quotelink'
for quote in quotes for quote in quotes
if quote.hash is href = quote.getAttribute 'href' # Add pathname to in-thread quotes href = quote.getAttribute 'href'
quote.pathname = "/#{g.BOARD}/res/#{threadID}" continue if href[0] is '/' # Cross-board quote
# NEW HTML ??? quote.href = "res/#{href}" # Fix pathnames
# OP quotes have different href attribute than normal quotes.
# Waiting for a reply from moot.
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
@ -674,7 +670,7 @@ ExpandThread =
if container = $ '.container', thread.firstElementChild if container = $ '.container', thread.firstElementChild
$.rm container $.rm container
a.textContent = a.textContent.replace '+', '\u00d7 Loading...' a.textContent = a.textContent.replace '+', '\u00d7 Loading...'
$.cache pathname, (-> ExpandThread.parse @, pathname, thread, a) $.cache pathname, -> ExpandThread.parse @, pathname, thread, a
when '\u00d7' when '\u00d7'
a.textContent = a.textContent.replace '\u00d7 Loading...', '+' a.textContent = a.textContent.replace '\u00d7 Loading...', '+'
@ -711,13 +707,8 @@ ExpandThread =
reply = d.importNode reply reply = d.importNode reply
for quote in $$ '.quotelink', reply for quote in $$ '.quotelink', reply
href = quote.getAttribute 'href' href = quote.getAttribute 'href'
if quote.hash is href # Add pathname to in-thread quotes continue if href[0] is '/' # Cross-board quote
quote.pathname = pathname quote.href = "res/#{href}" # Fix pathnames
# NEW HTML ???
# OP quotes have different href attribute than normal quotes.
# Waiting for a reply from moot.
else if href isnt quote.href # Fix cross-thread links, not cross-board ones
quote.href = "res/#{href}"
id = reply.firstElementChild.id[2..] id = reply.firstElementChild.id[2..]
link = $('.postNum.desktop', reply).firstElementChild link = $('.postNum.desktop', reply).firstElementChild
link.href = "res/#{threadID}#p#{id}" link.href = "res/#{threadID}#p#{id}"