Fix Thread Hiding.
This commit is contained in:
parent
59c879b59c
commit
a3c00a5792
@ -637,7 +637,7 @@
|
|||||||
if (result === true) {
|
if (result === true) {
|
||||||
if (isOP) {
|
if (isOP) {
|
||||||
if (!g.REPLY) {
|
if (!g.REPLY) {
|
||||||
ThreadHiding.hide(post.el.parentNode);
|
ThreadHiding.hide(post.root.parentNode);
|
||||||
} else {
|
} else {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2369,31 +2369,31 @@
|
|||||||
|
|
||||||
ThreadHiding = {
|
ThreadHiding = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var a, hiddenThreads, op, thread, _i, _len, _ref;
|
var a, hiddenThreads, thread, _i, _len, _ref;
|
||||||
hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
|
hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
|
||||||
_ref = $$('.thread');
|
_ref = $$('.thread');
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
thread = _ref[_i];
|
thread = _ref[_i];
|
||||||
op = $('.op', thread);
|
|
||||||
a = $.el('a', {
|
a = $.el('a', {
|
||||||
textContent: '[ - ]',
|
className: 'hide_thread_button',
|
||||||
|
innerHTML: '<span>[ - ]</span>',
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
});
|
});
|
||||||
$.on(a, 'click', ThreadHiding.cb);
|
$.on(a, 'click', ThreadHiding.cb);
|
||||||
$.prepend(op, a);
|
$.prepend(thread, a);
|
||||||
if (op.id in hiddenThreads) {
|
if (thread.id.slice(1) in hiddenThreads) {
|
||||||
ThreadHiding.hide(thread);
|
ThreadHiding.hide(thread);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
cb: function() {
|
cb: function() {
|
||||||
return ThreadHiding.toggle(this.parentNode.parentNode);
|
return ThreadHiding.toggle(this.parentNode);
|
||||||
},
|
},
|
||||||
toggle: function(thread) {
|
toggle: function(thread) {
|
||||||
var hiddenThreads, id;
|
var hiddenThreads, id;
|
||||||
hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
|
hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
|
||||||
id = $('.op', thread).id;
|
id = thread.id.slice(1);
|
||||||
if (thread.hidden || thread.firstChild.className === 'block') {
|
if (thread.hidden || /\bhidden_thread\b/.test(thread.firstChild.className)) {
|
||||||
ThreadHiding.show(thread);
|
ThreadHiding.show(thread);
|
||||||
delete hiddenThreads[id];
|
delete hiddenThreads[id];
|
||||||
} else {
|
} else {
|
||||||
@ -2403,40 +2403,34 @@
|
|||||||
return $.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
|
return $.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
|
||||||
},
|
},
|
||||||
hide: function(thread) {
|
hide: function(thread) {
|
||||||
var a, div, name, num, op, span, text, trip, uid, _ref, _ref1;
|
var a, num, opInfo, span, text;
|
||||||
if (!Conf['Show Stubs']) {
|
if (!Conf['Show Stubs']) {
|
||||||
thread.hidden = true;
|
thread.hidden = true;
|
||||||
thread.nextSibling.hidden = true;
|
thread.nextElementSibling.hidden = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (thread.firstChild.className === 'block') {
|
if (thread.firstChild.className === 'block') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
num = 0;
|
num = 0;
|
||||||
if (span = $('.omittedposts', thread)) {
|
if (span = $('.summary', thread)) {
|
||||||
num = Number(span.textContent.match(/\d+/)[0]);
|
num = Number(span.textContent.match(/\d+/));
|
||||||
}
|
}
|
||||||
num += $$('.op ~ table', thread).length;
|
num += $$('.opContainer ~ .replyContainer', thread).length;
|
||||||
text = num === 1 ? '1 reply' : "" + num + " replies";
|
text = num === 1 ? '1 reply' : "" + num + " replies";
|
||||||
op = $('.op', thread);
|
opInfo = $('.op > .postInfo > .nameBlock', thread).textContent;
|
||||||
name = $('.postername', op).textContent;
|
a = $('.hide_thread_button', thread);
|
||||||
uid = ((_ref = $('.posteruid', op)) != null ? _ref.textContent : void 0) || '';
|
$.addClass(a, 'hidden_thread');
|
||||||
trip = ((_ref1 = $('.postertrip', op)) != null ? _ref1.textContent : void 0) || '';
|
a.firstChild.textContent = '[ + ]';
|
||||||
a = $.el('a', {
|
return $.add(a, $.tn(" " + opInfo + " (" + text + ")"));
|
||||||
innerHTML: "<span>[ + ]</span> " + name + " " + uid + " " + trip + " (" + text + ")",
|
|
||||||
href: 'javascript:;'
|
|
||||||
});
|
|
||||||
$.on(a, 'click', ThreadHiding.cb);
|
|
||||||
div = $.el('div', {
|
|
||||||
className: 'block'
|
|
||||||
});
|
|
||||||
$.add(div, a);
|
|
||||||
return $.prepend(thread, div);
|
|
||||||
},
|
},
|
||||||
show: function(thread, id) {
|
show: function(thread) {
|
||||||
$.rm($('.block', thread));
|
var a;
|
||||||
|
a = $('.hide_thread_button', thread);
|
||||||
|
$.removeClass(a, 'hidden_thread');
|
||||||
|
a.innerHTML = '<span>[ - ]</span>';
|
||||||
thread.hidden = false;
|
thread.hidden = false;
|
||||||
return thread.nextSibling.hidden = false;
|
return thread.nextElementSibling.hidden = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -4066,9 +4060,7 @@
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Conf['Thread Hiding']) {
|
if (Conf['Thread Hiding']) {
|
||||||
setTimeout(function() {
|
ThreadHiding.init();
|
||||||
return ThreadHiding.init();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (Conf['Thread Expansion']) {
|
if (Conf['Thread Expansion']) {
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
@ -4215,11 +4207,15 @@ a[href="javascript:;"] {\
|
|||||||
text-decoration: none;\
|
text-decoration: none;\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
.block ~ *,\
|
.hide_thread_button {\
|
||||||
|
float: left;\
|
||||||
|
}\
|
||||||
|
\
|
||||||
|
.hidden_thread ~ *,\
|
||||||
#content > [name=tab]:not(:checked) + div,\
|
#content > [name=tab]:not(:checked) + div,\
|
||||||
#updater:not(:hover) > :not(.move),\
|
#updater:not(:hover) > :not(.move),\
|
||||||
#qp > input, #qp .inline, .forwarded {\
|
#qp > input, #qp .inline, .forwarded {\
|
||||||
display: none;\
|
display: none !important;\
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
h1 {\
|
h1 {\
|
||||||
|
|||||||
@ -528,7 +528,7 @@ Filter =
|
|||||||
if result is true
|
if result is true
|
||||||
if isOP
|
if isOP
|
||||||
unless g.REPLY
|
unless g.REPLY
|
||||||
ThreadHiding.hide post.el.parentNode
|
ThreadHiding.hide post.root.parentNode
|
||||||
else
|
else
|
||||||
continue
|
continue
|
||||||
else
|
else
|
||||||
@ -1879,24 +1879,24 @@ ThreadHiding =
|
|||||||
init: ->
|
init: ->
|
||||||
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
|
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
|
||||||
for thread in $$ '.thread'
|
for thread in $$ '.thread'
|
||||||
op = $ '.op', thread
|
|
||||||
a = $.el 'a',
|
a = $.el 'a',
|
||||||
textContent: '[ - ]'
|
className: 'hide_thread_button'
|
||||||
|
innerHTML: '<span>[ - ]</span>'
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
$.on a, 'click', ThreadHiding.cb
|
$.on a, 'click', ThreadHiding.cb
|
||||||
$.prepend op, a
|
$.prepend thread, a
|
||||||
|
|
||||||
if op.id of hiddenThreads
|
if thread.id[1..] of hiddenThreads
|
||||||
ThreadHiding.hide thread
|
ThreadHiding.hide thread
|
||||||
return
|
return
|
||||||
|
|
||||||
cb: ->
|
cb: ->
|
||||||
ThreadHiding.toggle @parentNode.parentNode
|
ThreadHiding.toggle @parentNode
|
||||||
|
|
||||||
toggle: (thread) ->
|
toggle: (thread) ->
|
||||||
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
|
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
|
||||||
id = $('.op', thread).id
|
id = thread.id[1..]
|
||||||
if thread.hidden or thread.firstChild.className is 'block'
|
if thread.hidden or /\bhidden_thread\b/.test thread.firstChild.className
|
||||||
ThreadHiding.show thread
|
ThreadHiding.show thread
|
||||||
delete hiddenThreads[id]
|
delete hiddenThreads[id]
|
||||||
else
|
else
|
||||||
@ -1907,36 +1907,29 @@ ThreadHiding =
|
|||||||
hide: (thread) ->
|
hide: (thread) ->
|
||||||
unless Conf['Show Stubs']
|
unless Conf['Show Stubs']
|
||||||
thread.hidden = true
|
thread.hidden = true
|
||||||
thread.nextSibling.hidden = true
|
thread.nextElementSibling.hidden = true
|
||||||
return
|
return
|
||||||
|
|
||||||
return if thread.firstChild.className is 'block' # already hidden by filter
|
return if thread.firstChild.className is 'block' # already hidden by filter
|
||||||
|
|
||||||
num = 0
|
num = 0
|
||||||
if span = $ '.omittedposts', thread
|
if span = $ '.summary', thread
|
||||||
num = Number span.textContent.match(/\d+/)[0]
|
num = Number span.textContent.match /\d+/
|
||||||
num += $$('.op ~ table', thread).length
|
num += $$('.opContainer ~ .replyContainer', thread).length
|
||||||
text = if num is 1 then '1 reply' else "#{num} replies"
|
text = if num is 1 then '1 reply' else "#{num} replies"
|
||||||
op = $ '.op', thread
|
opInfo = $('.op > .postInfo > .nameBlock', thread).textContent
|
||||||
name = $('.postername', op).textContent
|
|
||||||
uid = $('.posteruid', op)?.textContent or ''
|
|
||||||
trip = $('.postertrip', op)?.textContent or ''
|
|
||||||
|
|
||||||
a = $.el 'a',
|
a = $ '.hide_thread_button', thread
|
||||||
innerHTML: "<span>[ + ]</span> #{name} #{uid} #{trip} (#{text})"
|
$.addClass a, 'hidden_thread'
|
||||||
href: 'javascript:;'
|
a.firstChild.textContent = '[ + ]'
|
||||||
$.on a, 'click', ThreadHiding.cb
|
$.add a, $.tn " #{opInfo} (#{text})"
|
||||||
|
|
||||||
div = $.el 'div',
|
show: (thread) ->
|
||||||
className: 'block'
|
a = $ '.hide_thread_button', thread
|
||||||
|
$.removeClass a, 'hidden_thread'
|
||||||
$.add div, a
|
a.innerHTML = '<span>[ - ]</span>'
|
||||||
$.prepend thread, div
|
|
||||||
|
|
||||||
show: (thread, id) ->
|
|
||||||
$.rm $ '.block', thread
|
|
||||||
thread.hidden = false
|
thread.hidden = false
|
||||||
thread.nextSibling.hidden = false
|
thread.nextElementSibling.hidden = false
|
||||||
|
|
||||||
Updater =
|
Updater =
|
||||||
init: ->
|
init: ->
|
||||||
@ -3134,7 +3127,7 @@ Main =
|
|||||||
|
|
||||||
else #not reply
|
else #not reply
|
||||||
if Conf['Thread Hiding']
|
if Conf['Thread Hiding']
|
||||||
setTimeout -> ThreadHiding.init()
|
ThreadHiding.init()
|
||||||
|
|
||||||
if Conf['Thread Expansion']
|
if Conf['Thread Expansion']
|
||||||
setTimeout -> ExpandThread.init()
|
setTimeout -> ExpandThread.init()
|
||||||
@ -3237,11 +3230,15 @@ a[href="javascript:;"] {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.block ~ *,
|
.hide_thread_button {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden_thread ~ *,
|
||||||
#content > [name=tab]:not(:checked) + div,
|
#content > [name=tab]:not(:checked) + div,
|
||||||
#updater:not(:hover) > :not(.move),
|
#updater:not(:hover) > :not(.move),
|
||||||
#qp > input, #qp .inline, .forwarded {
|
#qp > input, #qp .inline, .forwarded {
|
||||||
display: none;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user