Fix Unlimited OP backlinks on thread expansion. Close #159

This commit is contained in:
Nicolas Stepien 2011-06-02 00:29:53 +02:00
parent 70296d1f85
commit 30925a3a12
2 changed files with 19 additions and 4 deletions

View File

@ -562,12 +562,15 @@
}
},
toggle: function(thread) {
var a, num, pathname, prev, table, threadID, _results;
var a, backlink, num, pathname, prev, table, threadID, _i, _len, _ref, _results;
threadID = thread.firstChild.id;
pathname = "/" + g.BOARD + "/res/" + threadID;
a = $('a.omittedposts', thread);
switch (a.textContent[0]) {
case '+':
if ($.config('OP Backlinks')) {
$('.op .container', thread).innerHTML = '';
}
a.textContent = a.textContent.replace('+', 'X Loading...');
return $.cache(pathname, (function() {
return expandThread.parse(this, pathname, thread, a);
@ -579,11 +582,18 @@
a.textContent = a.textContent.replace('-', '+');
num = g.BOARD === 'b' ? 3 : 5;
table = $.x("following::br[@clear][1]/preceding::table[" + num + "]", a);
_results = [];
while ((prev = table.previousSibling) && (prev.nodeName === 'TABLE')) {
_results.push($.rm(prev));
$.rm(prev);
}
if ($.config('OP Backlinks')) {
_ref = $$('.op a.backlink');
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
backlink = _ref[_i];
_results.push(!d.getElementById(backlink.hash.slice(1)) ? $.rm(backlink) : void 0);
}
return _results;
}
return _results;
}
},
parse: function(req, pathname, thread, a) {

View File

@ -386,6 +386,7 @@ expandThread =
switch a.textContent[0]
when '+'
$('.op .container', thread).innerHTML = '' if $.config 'OP Backlinks'
a.textContent = a.textContent.replace '+', 'X Loading...'
$.cache pathname, (-> expandThread.parse @, pathname, thread, a)
@ -401,6 +402,10 @@ expandThread =
table = $.x "following::br[@clear][1]/preceding::table[#{num}]", a
while (prev = table.previousSibling) and (prev.nodeName is 'TABLE')
$.rm prev
if $.config 'OP Backlinks'
for backlink in $$ '.op a.backlink'
$.rm backlink if !d.getElementById backlink.hash[1..]
parse: (req, pathname, thread, a) ->
if req.status isnt 200