Don't add a class to hidden threads with stubs. This will slightly improve performance for thread id perparsing on board pages.

This commit is contained in:
Nicolas Stepien 2012-03-11 06:03:59 +01:00
parent 4db82feca5
commit 42377c69cd
2 changed files with 9 additions and 13 deletions

View File

@ -2438,7 +2438,7 @@
var hiddenThreads, id;
hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
id = $('.op', thread).id;
if (thread.hidden || /\bstub\b/.test(thread.className)) {
if (thread.hidden || thread.firstChild.className === 'block') {
ThreadHiding.show(thread);
delete hiddenThreads[id];
} else {
@ -2454,7 +2454,7 @@
thread.nextSibling.hidden = true;
return;
}
if (/\bstub\b/.test(thread.className)) return;
if (thread.firstChild.className === 'block') return;
num = 0;
if (span = $('.omittedposts', thread)) {
num = Number(span.textContent.match(/\d+/)[0]);
@ -2474,12 +2474,10 @@
className: 'block'
});
$.add(div, a);
$.prepend(thread, div);
return $.addClass(thread, 'stub');
return $.prepend(thread, div);
},
show: function(thread, id) {
$.rm($('.block', thread));
$.removeClass(thread, 'stub');
thread.hidden = false;
return thread.nextSibling.hidden = false;
}
@ -3279,7 +3277,7 @@
},
parse: function(req, id, threadID) {
var doc, node, post, qp;
if (!((qp = ui.el) && qp.innerHTML === ("Loading " + id + "..."))) return;
if (!((qp = ui.el) && qp.textContent === ("Loading " + id + "..."))) return;
if (req.status !== 200) {
qp.textContent = "" + req.status + " " + req.statusText;
return;
@ -3958,7 +3956,7 @@
el: klass === 'op' ? node : node.firstChild.firstChild.lastChild,
"class": klass,
id: node.getElementsByTagName('input')[0].name,
threadId: g.THREAD_ID || $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id,
threadId: g.THREAD_ID || $.x('ancestor::div[@class="thread"]', node).firstChild.id,
isOP: klass === 'op',
isInlined: /\binline\b/.test(klass),
filesize: node.getElementsByClassName('filesize')[0] || false,

View File

@ -2051,7 +2051,7 @@ ThreadHiding =
toggle: (thread) ->
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
id = $('.op', thread).id
if thread.hidden or /\bstub\b/.test thread.className
if thread.hidden or thread.firstChild.className is 'block'
ThreadHiding.show thread
delete hiddenThreads[id]
else
@ -2065,7 +2065,7 @@ ThreadHiding =
thread.nextSibling.hidden = true
return
return if /\bstub\b/.test thread.className # already hidden by filter
return if thread.firstChild.className is 'block' # already hidden by filter
num = 0
if span = $ '.omittedposts', thread
@ -2087,11 +2087,9 @@ ThreadHiding =
$.add div, a
$.prepend thread, div
$.addClass thread, 'stub'
show: (thread, id) ->
$.rm $ '.block', thread
$.removeClass thread, 'stub'
thread.hidden = false
thread.nextSibling.hidden = false
@ -2712,7 +2710,7 @@ QuotePreview =
$.off @, 'mouseout', QuotePreview.mouseout
$.off @, 'click', QuotePreview.mouseout
parse: (req, id, threadID) ->
return unless (qp = ui.el) and qp.innerHTML is "Loading #{id}..."
return unless (qp = ui.el) and qp.textContent is "Loading #{id}..."
if req.status isnt 200
qp.textContent = "#{req.status} #{req.statusText}"
@ -3297,7 +3295,7 @@ Main =
el: if klass is 'op' then node else node.firstChild.firstChild.lastChild
class: klass
id: node.getElementsByTagName('input')[0].name
threadId: g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]', node).firstChild.id
threadId: g.THREAD_ID or $.x('ancestor::div[@class="thread"]', node).firstChild.id
isOP: klass is 'op'
isInlined: /\binline\b/.test klass
filesize: node.getElementsByClassName('filesize')[0] or false