Few small optimizations.

This commit is contained in:
Nicolas Stepien 2012-02-18 01:58:11 +01:00
parent 06e450160f
commit b1f257fbd9
2 changed files with 16 additions and 23 deletions

View File

@ -634,7 +634,7 @@
expandComment = { expandComment = {
init: function() { init: function() {
var a, _i, _len, _ref, _results; var a, _i, _len, _ref, _results;
_ref = $$('.abbr a'); _ref = $$('.abbr > a');
_results = []; _results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
a = _ref[_i]; a = _ref[_i];
@ -837,22 +837,18 @@
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies); return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
}, },
hideHide: function(reply) { hideHide: function(reply) {
var a, div, name, table, trip, _ref; var div, name, table, trip, _ref;
table = reply.parentNode.parentNode.parentNode; table = reply.parentNode.parentNode.parentNode;
if (table.hidden) return; if (table.hidden) return;
table.hidden = true; table.hidden = true;
if (conf['Show Stubs']) { if (conf['Show Stubs']) {
name = $('.commentpostername', reply).textContent; name = $('.commentpostername', reply).textContent;
trip = ((_ref = $('.postertrip', reply)) != null ? _ref.textContent : void 0) || ''; trip = ((_ref = $('.postertrip', reply)) != null ? _ref.textContent : void 0) || '';
a = $.el('a', {
innerHTML: "<span>[ + ]</span> " + name + " " + trip,
href: 'javascript:;'
});
$.on(a, 'click', replyHiding.cb.show);
div = $.el('div', { div = $.el('div', {
className: 'stub' className: 'stub',
innerHTML: "<a href=javascript:;><span>[ + ]</span> " + name + " " + trip + "</a>"
}); });
$.add(div, a); $.on($('a', div), 'click', replyHiding.cb.show);
return $.before(table, div); return $.before(table, div);
} }
}, },
@ -2542,7 +2538,7 @@
html = '<div class=move>Thread Watcher</div>'; html = '<div class=move>Thread Watcher</div>';
watcher.dialog = ui.dialog('watcher', 'top: 50px; left: 0px;', html); watcher.dialog = ui.dialog('watcher', 'top: 50px; left: 0px;', html);
$.add(d.body, watcher.dialog); $.add(d.body, watcher.dialog);
inputs = $$('.op input'); inputs = $$('.op > input');
for (_i = 0, _len = inputs.length; _i < _len; _i++) { for (_i = 0, _len = inputs.length; _i < _len; _i++) {
input = inputs[_i]; input = inputs[_i];
favicon = $.el('img', { favicon = $.el('img', {
@ -2586,7 +2582,7 @@
} }
$.add(watcher.dialog, nodes); $.add(watcher.dialog, nodes);
watchedBoard = watched[g.BOARD] || {}; watchedBoard = watched[g.BOARD] || {};
_ref3 = $$('img.favicon'); _ref3 = $$('.favicon');
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
favicon = _ref3[_j]; favicon = _ref3[_j];
id = favicon.nextSibling.name; id = favicon.nextSibling.name;
@ -2973,7 +2969,7 @@
op = threading.op($('body > form', body).firstChild); op = threading.op($('body > form', body).firstChild);
html = op.innerHTML; html = op.innerHTML;
} else { } else {
_ref = $$('td.reply', body); _ref = $$('.reply', body);
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
reply = _ref[_i]; reply = _ref[_i];
if (reply.id === id) { if (reply.id === id) {
@ -3073,7 +3069,7 @@
op = threading.op($('body > form', body).firstChild); op = threading.op($('body > form', body).firstChild);
html = op.innerHTML; html = op.innerHTML;
} else { } else {
_ref = $$('td.reply', body); _ref = $$('.reply', body);
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
reply = _ref[_i]; reply = _ref[_i];
if (reply.id === id) { if (reply.id === id) {

View File

@ -473,7 +473,7 @@ strikethroughQuotes =
expandComment = expandComment =
init: -> init: ->
for a in $$ '.abbr a' for a in $$ '.abbr > a'
$.on a, 'click', expandComment.expand $.on a, 'click', expandComment.expand
expand: (e) -> expand: (e) ->
e.preventDefault() e.preventDefault()
@ -630,14 +630,11 @@ replyHiding =
if conf['Show Stubs'] if conf['Show Stubs']
name = $('.commentpostername', reply).textContent name = $('.commentpostername', reply).textContent
trip = $('.postertrip', reply)?.textContent or '' trip = $('.postertrip', reply)?.textContent or ''
a = $.el 'a',
innerHTML: "<span>[ + ]</span> #{name} #{trip}"
href: 'javascript:;'
$.on a, 'click', replyHiding.cb.show
div = $.el 'div', div = $.el 'div',
className: 'stub' className: 'stub'
$.add div, a innerHTML: "<a href=javascript:;><span>[ + ]</span> #{name} #{trip}</a>"
$.on $('a', div), 'click', replyHiding.cb.show
$.before table, div $.before table, div
show: (table) -> show: (table) ->
@ -2028,7 +2025,7 @@ watcher =
$.add d.body, watcher.dialog $.add d.body, watcher.dialog
#add watch buttons #add watch buttons
inputs = $$ '.op input' inputs = $$ '.op > input'
for input in inputs for input in inputs
favicon = $.el 'img', favicon = $.el 'img',
className: 'favicon' className: 'favicon'
@ -2065,7 +2062,7 @@ watcher =
$.add watcher.dialog, nodes $.add watcher.dialog, nodes
watchedBoard = watched[g.BOARD] or {} watchedBoard = watched[g.BOARD] or {}
for favicon in $$ 'img.favicon' for favicon in $$ '.favicon'
id = favicon.nextSibling.name id = favicon.nextSibling.name
if id of watchedBoard if id of watchedBoard
favicon.src = Favicon.default favicon.src = Favicon.default
@ -2352,7 +2349,7 @@ quoteInline =
op = threading.op $('body > form', body).firstChild op = threading.op $('body > form', body).firstChild
html = op.innerHTML html = op.innerHTML
else else
for reply in $$ 'td.reply', body for reply in $$ '.reply', body
if reply.id == id if reply.id == id
html = reply.innerHTML html = reply.innerHTML
break break
@ -2424,7 +2421,7 @@ quotePreview =
op = threading.op $('body > form', body).firstChild op = threading.op $('body > form', body).firstChild
html = op.innerHTML html = op.innerHTML
else else
for reply in $$ 'td.reply', body for reply in $$ '.reply', body
if reply.id == id if reply.id == id
html = reply.innerHTML html = reply.innerHTML
break break