add replies in correct order

This commit is contained in:
James Campos 2010-12-29 13:39:35 -08:00
parent ef5e04e407
commit c03072f0e0
2 changed files with 24 additions and 17 deletions

View File

@ -832,20 +832,24 @@ updateCallback = ->
body = n 'body', innerHTML: @responseText body = n 'body', innerHTML: @responseText
replies = $$ 'td.reply', body replies = $$ 'td.reply', body
root = $('br[clear]').previousElementSibling root = $('br[clear]')
if reply = $ 'td.reply, td.replyhl', root if reply = $ 'td.reply, td.replyhl', root.previousElementSibling
id = Number reply.id id = Number reply.id
else else
id = 0 id = 0
i = 0
arr = []
while (reply = replies.pop()) and (Number reply.id > id) while (reply = replies.pop()) and (Number reply.id > id)
table = x 'ancestor::table', reply arr.push reply
inAfter root, table
++i
count.textContent = "+#{i}" l = arr.length
count.className = if i is 0 then '' else 'new' count.textContent = "+#{l}"
count.className = if l is 0 then '' else 'new'
#insert replies in order, so backlinks resolve
while reply = arr.pop()
table = x 'ancestor::table', reply
inBefore root, table
timer.textContent = -1 * GM_getValue 'Interval', 10 timer.textContent = -1 * GM_getValue 'Interval', 10

View File

@ -1070,7 +1070,7 @@
return r; return r;
}; };
updateCallback = function() { updateCallback = function() {
var body, count, i, id, input, replies, reply, root, s, table, timer, _i, _len, _ref; var arr, body, count, id, input, l, replies, reply, root, s, table, timer, _i, _len, _ref;
count = $('#updater #count'); count = $('#updater #count');
timer = $('#updater #timer'); timer = $('#updater #timer');
if (this.status === 404) { if (this.status === 404) {
@ -1098,20 +1098,23 @@
innerHTML: this.responseText innerHTML: this.responseText
}); });
replies = $$('td.reply', body); replies = $$('td.reply', body);
root = $('br[clear]').previousElementSibling; root = $('br[clear]');
if (reply = $('td.reply, td.replyhl', root)) { if (reply = $('td.reply, td.replyhl', root.previousElementSibling)) {
id = Number(reply.id); id = Number(reply.id);
} else { } else {
id = 0; id = 0;
} }
i = 0; arr = [];
while ((reply = replies.pop()) && (Number(reply.id > id))) { while ((reply = replies.pop()) && (Number(reply.id > id))) {
table = x('ancestor::table', reply); arr.push(reply);
inAfter(root, table); }
++i; l = arr.length;
count.textContent = "+" + l;
count.className = l === 0 ? '' : 'new';
while (reply = arr.pop()) {
table = x('ancestor::table', reply);
inBefore(root, table);
} }
count.textContent = "+" + i;
count.className = i === 0 ? '' : 'new';
return timer.textContent = -1 * GM_getValue('Interval', 10); return timer.textContent = -1 * GM_getValue('Interval', 10);
}; };
updateFavicon = function() { updateFavicon = function() {