Thread expansion optimizations.

This commit is contained in:
Nicolas Stepien 2011-12-13 15:17:48 +01:00
parent faa952511c
commit bc57aa561f
2 changed files with 16 additions and 23 deletions

View File

@ -760,21 +760,18 @@
}
},
parse: function(req, pathname, thread, a) {
var body, br, href, link, next, quote, reply, table, tables, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _results;
var body, br, frag, href, link, next, quote, reply, _i, _j, _len, _len2, _ref, _ref2;
if (req.status !== 200) {
a.textContent = "" + req.status + " " + req.statusText;
$.off(a, 'click', expandThread.cb.toggle);
return;
}
a.textContent = a.textContent.replace('X Loading...', '-');
while ((next = a.nextSibling) && !next.clear) {
$.rm(next);
}
br = next;
body = $.el('body', {
innerHTML: req.responseText
});
_ref = $$('td[id]', body);
frag = d.createDocumentFragment();
_ref = $$('.reply', body);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
reply = _ref[_i];
_ref2 = $$('.quotelink', reply);
@ -789,15 +786,13 @@
link = $('.quotejs', reply);
link.href = "res/" + thread.firstChild.id + "#" + reply.id;
link.nextSibling.href = "res/" + thread.firstChild.id + "#q" + reply.id;
$.add(frag, reply.parentNode.parentNode.parentNode);
}
tables = $$('form[name=delform] table', body);
tables.pop();
_results = [];
for (_k = 0, _len3 = tables.length; _k < _len3; _k++) {
table = tables[_k];
_results.push($.before(br, table));
while ((next = a.nextSibling) && !next.clear) {
$.rm(next);
}
return _results;
br = next;
return $.before(br, frag);
}
};

View File

@ -545,15 +545,11 @@ expandThread =
a.textContent = a.textContent.replace 'X Loading...', '-'
# eat everything, then replace with fresh full posts
while (next = a.nextSibling) and not next.clear #br[clear]
$.rm next
br = next
body = $.el 'body',
innerHTML: req.responseText
for reply in $$ 'td[id]', body
frag = d.createDocumentFragment()
for reply in $$ '.reply', body
for quote in $$ '.quotelink', reply
if (href = quote.getAttribute('href')) is quote.hash #add pathname to normal quotes
quote.pathname = pathname
@ -562,10 +558,12 @@ expandThread =
link = $ '.quotejs', reply
link.href = "res/#{thread.firstChild.id}##{reply.id}"
link.nextSibling.href = "res/#{thread.firstChild.id}#q#{reply.id}"
tables = $$ 'form[name=delform] table', body
tables.pop()
for table in tables
$.before br, table
$.add frag, reply.parentNode.parentNode.parentNode
# eat everything, then replace with fresh full posts
while (next = a.nextSibling) and not next.clear #br[clear]
$.rm next
br = next
$.before br, frag
replyHiding =
init: ->