callbacks only take single posts

This commit is contained in:
James Campos 2011-05-09 23:52:10 -07:00
parent 8af31eb927
commit 170d98709c
2 changed files with 118 additions and 126 deletions

View File

@ -603,21 +603,20 @@
return replyHiding.hide(reply); return replyHiding.hide(reply);
}, },
node: function(root) { node: function(root) {
var a, id, reply, td, tds, _i, _len, _results; var a, dd, id, reply;
tds = $$('td.doubledash', root); if (!(dd = $('td.doubldash', root))) {
_results = []; return;
for (_i = 0, _len = tds.length; _i < _len; _i++) { }
td = tds[_i]; a = $.el('a', {
a = $.el('a', { textContent: '[ - ]'
textContent: '[ - ]' });
}); $.bind(a, 'click', replyHiding.cb.hide);
$.bind(a, 'click', replyHiding.cb.hide); $.replace(dd, a);
$.replace(td.firstChild, a); reply = dd.nextSibling;
reply = td.nextSibling; id = reply.id;
id = reply.id; if (id in g.hiddenReplies) {
_results.push(id in g.hiddenReplies ? replyHiding.hide(reply) : void 0); return replyHiding.hide(reply);
} }
return _results;
}, },
show: function(e) { show: function(e) {
var div, table; var div, table;
@ -1028,14 +1027,9 @@
return $('iframe[name=iframe]').src = 'about:blank'; return $('iframe[name=iframe]').src = 'about:blank';
}, },
node: function(root) { node: function(root) {
var quote, quotes, _i, _len, _results; var quote;
quotes = $$('a.quotejs:not(:first-child)', root); quote = $('a.quotejs:not(:first-child)', root);
_results = []; return $.bind(quote, 'click', qr.cb.quote);
for (_i = 0, _len = quotes.length; _i < _len; _i++) {
quote = quotes[_i];
_results.push($.bind(quote, 'click', qr.cb.quote));
}
return _results;
}, },
submit: function(e) { submit: function(e) {
var form, id, isQR, op; var form, id, isQR, op;
@ -1588,19 +1582,16 @@
}, },
cb: { cb: {
node: function(root) { node: function(root) {
var name, names, trip, _i, _j, _len, _len2, _ref, _results; var name, trip;
names = $$('span.postername, span.commentpostername', root); name = $$('span.postername, span.commentpostername', root);
for (_i = 0, _len = names.length; _i < _len; _i++) { name.innerHTML = 'Anonymous';
name = names[_i]; if (trip = $('span.postertrip', root)) {
name.innerHTML = 'Anonymous'; if (trip.parentNode.nodeName === 'A') {
return $.remove(trip.parentNode);
} else {
return $.remove(trip);
}
} }
_ref = $$('span.postertrip', root);
_results = [];
for (_j = 0, _len2 = _ref.length; _j < _len2; _j++) {
trip = _ref[_j];
_results.push(trip.parentNode.nodeName === 'A' ? $.remove(trip.parentNode) : $.remove(trip));
}
return _results;
} }
} }
}; };
@ -1610,7 +1601,7 @@
}, },
cb: { cb: {
node: function(root) { node: function(root) {
var i, link, names, prefix, prefixes, s, span, suffix, _i, _len, _ref, _results; var i, link, names, prefix, prefixes, s, span, suffix, _len, _results;
prefixes = (function() { prefixes = (function() {
var _i, _len, _ref, _results; var _i, _len, _ref, _results;
_ref = $.config('flavors').split('\n'); _ref = $.config('flavors').split('\n');
@ -1632,26 +1623,19 @@
} }
return _results; return _results;
})(); })();
_ref = $$('span.filesize', root); if (span = $('span.filesize', root)) {
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
span = _ref[_i];
suffix = $('a', span).href; suffix = $('a', span).href;
_results.push((function() { _results = [];
var _len2, _results2; for (i = 0, _len = prefixes.length; i < _len; i++) {
_results2 = []; prefix = prefixes[i];
for (i = 0, _len2 = prefixes.length; i < _len2; i++) { link = $.el('a', {
prefix = prefixes[i]; textContent: names[i],
link = $.el('a', { href: prefix + suffix
textContent: names[i], });
href: prefix + suffix _results.push($.append(span, $.tn(' '), link));
}); }
_results2.push($.append(span, $.tn(' '), link)); return _results;
}
return _results2;
})());
} }
return _results;
} }
} }
}; };
@ -1694,7 +1678,7 @@
}, },
node: function(root) { node: function(root) {
var el, id, link, qid, quote, quotes, _i, _len, _ref, _results; var el, id, link, qid, quote, quotes, _i, _len, _ref, _results;
id = $('td[id]', root).id; id = root.id || $('td[id]', root).id;
quotes = {}; quotes = {};
_ref = $$('a.quotelink', root); _ref = $$('a.quotelink', root);
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -1804,19 +1788,14 @@
}, },
cb: { cb: {
node: function(root) { node: function(root) {
var a, arr, el, _i, _len, _results; var a, span;
arr = $$('span[id^=no]', root); span = $('span[id^=no]', root);
_results = []; a = $.el('a', {
for (_i = 0, _len = arr.length; _i < _len; _i++) { innerHTML: '[&nbsp;!&nbsp;]'
el = arr[_i]; });
a = $.el('a', { $.bind(a, 'click', quickReport.cb.report);
innerHTML: '[&nbsp;!&nbsp;]' $.after(span, a);
}); return $.after(span, $.tn(' '));
$.bind(a, 'click', quickReport.cb.report);
$.after(el, a);
_results.push($.after(el, $.tn(' ')));
}
return _results;
}, },
report: function(e) { report: function(e) {
return quickReport.report(this); return quickReport.report(this);
@ -1839,7 +1818,7 @@
}, },
cb: { cb: {
node: function(root) { node: function(root) {
unread.replies = unread.replies.concat($$('td[id]', root)); unread.replies.push(root);
unread.updateTitle(); unread.updateTitle();
return Favicon.update(); return Favicon.update();
}, },
@ -1989,16 +1968,13 @@
}, },
cb: { cb: {
node: function(root) { node: function(root) {
var thumb, _i, _len, _ref2, _results; var thumb;
_ref2 = $$('img[md5]', root); if (!(thumb = $('img[md5]', root))) {
_results = []; return;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
thumb = _ref2[_i];
$.bind(thumb, 'mouseover', imageHover.cb.mouseover);
$.bind(thumb, 'mousemove', ui.hover);
_results.push($.bind(thumb, 'mouseout', ui.hoverend));
} }
return _results; $.bind(thumb, 'mouseover', imageHover.cb.mouseover);
$.bind(thumb, 'mousemove', ui.hover);
return $.bind(thumb, 'mouseout', ui.hoverend);
}, },
mouseover: function(e) { mouseover: function(e) {
var el; var el;
@ -2050,16 +2026,15 @@
}, },
cb: { cb: {
node: function(root) { node: function(root) {
var a, thumb, _i, _len, _ref2, _results; var a, thumb;
_ref2 = $$('img[md5]', root); if (!(thumb = $('img[md5]', root))) {
_results = []; return;
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { }
thumb = _ref2[_i]; a = thumb.parentNode;
a = thumb.parentNode; $.bind(a, 'click', imgExpand.cb.toggle);
$.bind(a, 'click', imgExpand.cb.toggle); if (imgExpand.on) {
_results.push(imgExpand.on ? imgExpand.toggle(a) : void 0); return imgExpand.toggle(a);
} }
return _results;
}, },
toggle: function(e) { toggle: function(e) {
if (e.shiftKey || e.altKey || e.ctrlKey || e.button !== 0) { if (e.shiftKey || e.altKey || e.ctrlKey || e.button !== 0) {
@ -2194,7 +2169,7 @@
}; };
main = { main = {
init: function() { init: function() {
var DAY, callback, cutoff, hiddenThreads, id, lastChecked, now, pathname, temp, timestamp, tzOffset, _i, _len, _ref2, _ref3; var DAY, callback, cutoff, hiddenThreads, id, lastChecked, now, op, pathname, reply, table, temp, timestamp, tzOffset, _i, _j, _k, _l, _len, _len2, _len3, _len4, _ref2, _ref3, _ref4, _ref5, _ref6;
pathname = location.pathname.substring(1).split('/'); pathname = location.pathname.substring(1).split('/');
g.BOARD = pathname[0], temp = pathname[1]; g.BOARD = pathname[0], temp = pathname[1];
if (temp === 'res') { if (temp === 'res') {
@ -2323,10 +2298,24 @@
expandComment.init(); expandComment.init();
} }
} }
_ref3 = g.callbacks; _ref3 = $$('div.op');
for (_i = 0, _len = _ref3.length; _i < _len; _i++) { for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
callback = _ref3[_i]; op = _ref3[_i];
callback(); _ref4 = g.callbacks;
for (_j = 0, _len2 = _ref4.length; _j < _len2; _j++) {
callback = _ref4[_j];
callback(op);
}
}
_ref5 = $$('td[id]');
for (_k = 0, _len3 = _ref5.length; _k < _len3; _k++) {
reply = _ref5[_k];
table = reply.parentNode.parentNode.parentNode;
_ref6 = g.callbacks;
for (_l = 0, _len4 = _ref6.length; _l < _len4; _l++) {
callback = _ref6[_l];
callback(table);
}
} }
$.bind(d.body, 'DOMNodeInserted', nodeInserted); $.bind(d.body, 'DOMNodeInserted', nodeInserted);
return options.init(); return options.init();

View File

@ -429,17 +429,16 @@ replyHiding =
replyHiding.hide reply replyHiding.hide reply
node: (root) -> node: (root) ->
tds = $$('td.doubledash', root) return unless dd = $ 'td.doubldash', root
for td in tds a = $.el 'a',
a = $.el 'a', textContent: '[ - ]'
textContent: '[ - ]' $.bind a, 'click', replyHiding.cb.hide
$.bind a, 'click', replyHiding.cb.hide $.replace dd, a
$.replace td.firstChild, a
reply = td.nextSibling reply = dd.nextSibling
id = reply.id id = reply.id
if id of g.hiddenReplies if id of g.hiddenReplies
replyHiding.hide reply replyHiding.hide reply
show: (e) -> show: (e) ->
div = @parentNode div = @parentNode
@ -788,9 +787,8 @@ qr =
$('iframe[name=iframe]').src = 'about:blank' $('iframe[name=iframe]').src = 'about:blank'
node: (root) -> node: (root) ->
quotes = $$ 'a.quotejs:not(:first-child)', root quote = $ 'a.quotejs:not(:first-child)', root
for quote in quotes $.bind quote, 'click', qr.cb.quote
$.bind quote, 'click', qr.cb.quote
submit: (e) -> submit: (e) ->
form = this form = this
@ -1292,10 +1290,9 @@ anonymize =
g.callbacks.push anonymize.cb.node g.callbacks.push anonymize.cb.node
cb: cb:
node: (root) -> node: (root) ->
names = $$ 'span.postername, span.commentpostername', root name = $$ 'span.postername, span.commentpostername', root
for name in names name.innerHTML = 'Anonymous'
name.innerHTML = 'Anonymous' if trip = $ 'span.postertrip', root
for trip in $$ 'span.postertrip', root
if trip.parentNode.nodeName is 'A' if trip.parentNode.nodeName is 'A'
$.remove trip.parentNode $.remove trip.parentNode
else else
@ -1308,7 +1305,7 @@ sauce =
node: (root) -> node: (root) ->
prefixes = (s for s in ($.config('flavors').split '\n') when s[0] != '#') prefixes = (s for s in ($.config('flavors').split '\n') when s[0] != '#')
names = (prefix.match(/(\w+)\./)[1] for prefix in prefixes) names = (prefix.match(/(\w+)\./)[1] for prefix in prefixes)
for span in $$ 'span.filesize', root if span = $ 'span.filesize', root
suffix = $('a', span).href suffix = $('a', span).href
for prefix, i in prefixes for prefix, i in prefixes
link = $.el 'a', link = $.el 'a',
@ -1351,7 +1348,8 @@ quoteBacklink =
init: -> init: ->
g.callbacks.push quoteBacklink.node g.callbacks.push quoteBacklink.node
node: (root) -> node: (root) ->
{id} = $ 'td[id]', root #better coffee-script way of doing this?
id = root.id or $('td[id]', root).id
quotes = {} quotes = {}
for quote in $$ 'a.quotelink', root for quote in $$ 'a.quotelink', root
qid = quote.textContent[2..] #FIXME cross-board links qid = quote.textContent[2..] #FIXME cross-board links
@ -1423,13 +1421,12 @@ quickReport =
g.callbacks.push quickReport.cb.node g.callbacks.push quickReport.cb.node
cb: cb:
node: (root) -> node: (root) ->
arr = $$ 'span[id^=no]', root span = $ 'span[id^=no]', root
for el in arr a = $.el 'a',
a = $.el 'a', innerHTML: '[&nbsp;!&nbsp;]'
innerHTML: '[&nbsp;!&nbsp;]' $.bind a, 'click', quickReport.cb.report
$.bind a, 'click', quickReport.cb.report $.after span, a
$.after el, a $.after span, $.tn(' ')
$.after el, $.tn(' ')
report: (e) -> report: (e) ->
quickReport.report this quickReport.report this
report: (target) -> report: (target) ->
@ -1447,7 +1444,7 @@ unread =
cb: cb:
node: (root) -> node: (root) ->
unread.replies = unread.replies.concat $$ 'td[id]', root unread.replies.push root
unread.updateTitle() unread.updateTitle()
Favicon.update() Favicon.update()
@ -1538,10 +1535,10 @@ imageHover =
g.callbacks.push imageHover.cb.node g.callbacks.push imageHover.cb.node
cb: cb:
node: (root) -> node: (root) ->
for thumb in $$ 'img[md5]', root return unless thumb = $ 'img[md5]', root
$.bind thumb, 'mouseover', imageHover.cb.mouseover $.bind thumb, 'mouseover', imageHover.cb.mouseover
$.bind thumb, 'mousemove', ui.hover $.bind thumb, 'mousemove', ui.hover
$.bind thumb, 'mouseout', ui.hoverend $.bind thumb, 'mouseout', ui.hoverend
mouseover: (e) -> mouseover: (e) ->
el = $ '#iHover' el = $ '#iHover'
el.src = null el.src = null
@ -1574,10 +1571,10 @@ imgExpand =
cb: cb:
node: (root) -> node: (root) ->
for thumb in $$ 'img[md5]', root return unless thumb = $ 'img[md5]', root
a = thumb.parentNode a = thumb.parentNode
$.bind a, 'click', imgExpand.cb.toggle $.bind a, 'click', imgExpand.cb.toggle
if imgExpand.on then imgExpand.toggle a if imgExpand.on then imgExpand.toggle a
toggle: (e) -> toggle: (e) ->
return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0 return if e.shiftKey or e.altKey or e.ctrlKey or e.button isnt 0
e.preventDefault() e.preventDefault()
@ -1810,7 +1807,13 @@ main =
if $.config 'Comment Expansion' if $.config 'Comment Expansion'
expandComment.init() expandComment.init()
callback() for callback in g.callbacks for op in $$ 'div.op'
for callback in g.callbacks
callback op
for reply in $$ 'td[id]'
table = reply.parentNode.parentNode.parentNode
for callback in g.callbacks
callback table
$.bind d.body, 'DOMNodeInserted', nodeInserted $.bind d.body, 'DOMNodeInserted', nodeInserted
options.init() options.init()