Merge pull request #168 from MayhemYDG/fix
Fix Unlimited OP backlinks on thread expansion. Close #159
This commit is contained in:
commit
c37af9d284
@ -562,12 +562,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
toggle: function(thread) {
|
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;
|
threadID = thread.firstChild.id;
|
||||||
pathname = "/" + g.BOARD + "/res/" + threadID;
|
pathname = "/" + g.BOARD + "/res/" + threadID;
|
||||||
a = $('a.omittedposts', thread);
|
a = $('a.omittedposts', thread);
|
||||||
switch (a.textContent[0]) {
|
switch (a.textContent[0]) {
|
||||||
case '+':
|
case '+':
|
||||||
|
if ($.config('OP Backlinks')) {
|
||||||
|
$('.op .container', thread).innerHTML = '';
|
||||||
|
}
|
||||||
a.textContent = a.textContent.replace('+', 'X Loading...');
|
a.textContent = a.textContent.replace('+', 'X Loading...');
|
||||||
return $.cache(pathname, (function() {
|
return $.cache(pathname, (function() {
|
||||||
return expandThread.parse(this, pathname, thread, a);
|
return expandThread.parse(this, pathname, thread, a);
|
||||||
@ -579,11 +582,18 @@
|
|||||||
a.textContent = a.textContent.replace('-', '+');
|
a.textContent = a.textContent.replace('-', '+');
|
||||||
num = g.BOARD === 'b' ? 3 : 5;
|
num = g.BOARD === 'b' ? 3 : 5;
|
||||||
table = $.x("following::br[@clear][1]/preceding::table[" + num + "]", a);
|
table = $.x("following::br[@clear][1]/preceding::table[" + num + "]", a);
|
||||||
_results = [];
|
|
||||||
while ((prev = table.previousSibling) && (prev.nodeName === 'TABLE')) {
|
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) {
|
parse: function(req, pathname, thread, a) {
|
||||||
|
|||||||
@ -386,6 +386,7 @@ expandThread =
|
|||||||
|
|
||||||
switch a.textContent[0]
|
switch a.textContent[0]
|
||||||
when '+'
|
when '+'
|
||||||
|
$('.op .container', thread).innerHTML = '' if $.config 'OP Backlinks'
|
||||||
a.textContent = a.textContent.replace '+', 'X Loading...'
|
a.textContent = a.textContent.replace '+', 'X Loading...'
|
||||||
$.cache pathname, (-> expandThread.parse @, pathname, thread, a)
|
$.cache pathname, (-> expandThread.parse @, pathname, thread, a)
|
||||||
|
|
||||||
@ -401,6 +402,10 @@ expandThread =
|
|||||||
table = $.x "following::br[@clear][1]/preceding::table[#{num}]", a
|
table = $.x "following::br[@clear][1]/preceding::table[#{num}]", a
|
||||||
while (prev = table.previousSibling) and (prev.nodeName is 'TABLE')
|
while (prev = table.previousSibling) and (prev.nodeName is 'TABLE')
|
||||||
$.rm prev
|
$.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) ->
|
parse: (req, pathname, thread, a) ->
|
||||||
if req.status isnt 200
|
if req.status isnt 200
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user