Separate node callbacks from features' inits for profiling purposes.

This commit is contained in:
Nicolas Stepien 2012-02-10 19:59:24 +01:00
parent 658a969bc3
commit d1cf993e14
2 changed files with 311 additions and 283 deletions

View File

@ -612,18 +612,19 @@
strikethroughQuotes = { strikethroughQuotes = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var el, quote, _i, _len, _ref; },
if (root.className === 'inline') return; node: function(root) {
_ref = $$('.quotelink', root); var el, quote, _i, _len, _ref;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { if (root.className === 'inline') return;
quote = _ref[_i]; _ref = $$('.quotelink', root);
if ((el = $.id(quote.hash.slice(1))) && el.parentNode.parentNode.parentNode.hidden) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
$.addClass(quote, 'filtered'); quote = _ref[_i];
if (conf['Recursive Filtering']) root.hidden = true; if ((el = $.id(quote.hash.slice(1))) && el.parentNode.parentNode.parentNode.hidden) {
} $.addClass(quote, 'filtered');
if (conf['Recursive Filtering']) root.hidden = true;
} }
}); }
} }
}; };
@ -794,20 +795,21 @@
replyHiding = { replyHiding = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var a, dd, id, reply; },
if (!(dd = $('.doubledash', root))) return; node: function(root) {
dd.className = 'replyhider'; var a, dd, id, reply;
a = $.el('a', { if (!(dd = $('.doubledash', root))) return;
textContent: '[ - ]', dd.className = 'replyhider';
href: 'javascript:;' a = $.el('a', {
}); textContent: '[ - ]',
$.on(a, 'click', replyHiding.cb.hide); href: 'javascript:;'
$.replace(dd.firstChild, a);
reply = dd.nextSibling;
id = reply.id;
if (id in g.hiddenReplies) return replyHiding.hide(reply);
}); });
$.on(a, 'click', replyHiding.cb.hide);
$.replace(dd.firstChild, a);
reply = dd.nextSibling;
id = reply.id;
if (id in g.hiddenReplies) return replyHiding.hide(reply);
}, },
cb: { cb: {
hide: function() { hide: function() {
@ -1202,9 +1204,7 @@
form = d.forms[0]; form = d.forms[0];
$.before(form, link); $.before(form, link);
} }
g.callbacks.push(function(root) { g.callbacks.push(this.node);
return $.on($('.quotejs + .quotejs', root), 'click', qr.quote);
});
iframe = $.el('iframe', { iframe = $.el('iframe', {
id: 'iframe', id: 'iframe',
hidden: true, hidden: true,
@ -1235,6 +1235,9 @@
$.on(d, 'dragend', qr.drag); $.on(d, 'dragend', qr.drag);
return window.location = 'javascript:void(Recaptcha.focus_response_field=function(){})'; return window.location = 'javascript:void(Recaptcha.focus_response_field=function(){})';
}, },
node: function(root) {
return $.on($('.quotejs + .quotejs', root), 'click', qr.quote);
},
open: function() { open: function() {
if (qr.el) { if (qr.el) {
qr.el.hidden = false; qr.el.hidden = false;
@ -2570,18 +2573,19 @@
anonymize = { anonymize = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var name, trip; },
name = $('.commentpostername, .postername', root); node: function(root) {
name.textContent = 'Anonymous'; var name, trip;
if (trip = $('.postertrip', root)) { name = $('.commentpostername, .postername', root);
if (trip.parentNode.nodeName === 'A') { name.textContent = 'Anonymous';
return $.rm(trip.parentNode); if (trip = $('.postertrip', root)) {
} else { if (trip.parentNode.nodeName === 'A') {
return $.rm(trip); return $.rm(trip.parentNode);
} } else {
return $.rm(trip);
} }
}); }
} }
}; };
@ -2627,16 +2631,17 @@
revealSpoilers = { revealSpoilers = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var board, img, imgID, _, _ref; },
if (!(img = $('img[alt^=Spoiler]', root)) || root.className === 'inline') { node: function(root) {
return; var board, img, imgID, _, _ref;
} if (!(img = $('img[alt^=Spoiler]', root)) || root.className === 'inline') {
img.removeAttribute('height'); return;
img.removeAttribute('width'); }
_ref = img.parentNode.href.match(/(\w+)\/src\/(\d+)/), _ = _ref[0], board = _ref[1], imgID = _ref[2]; img.removeAttribute('height');
return img.src = "http://0.thumbs.4chan.org/" + board + "/thumb/" + imgID + "s.jpg"; img.removeAttribute('width');
}); _ref = img.parentNode.href.match(/(\w+)\/src\/(\d+)/), _ = _ref[0], board = _ref[1], imgID = _ref[2];
return img.src = "http://0.thumbs.4chan.org/" + board + "/thumb/" + imgID + "s.jpg";
} }
}; };
@ -2656,7 +2661,7 @@
hour = chanOffset + Number(hour); hour = chanOffset + Number(hour);
return new Date(year, month, day, hour, min); return new Date(year, month, day, hour, min);
}; };
return g.callbacks.push(Time.node); return g.callbacks.push(this.node);
}, },
node: function(root) { node: function(root) {
var node, time; var node, time;
@ -2769,61 +2774,63 @@
var format; var format;
format = conf['backlink'].replace(/%id/g, "' + id + '"); format = conf['backlink'].replace(/%id/g, "' + id + '");
quoteBacklink.funk = Function('id', "return '" + format + "'"); quoteBacklink.funk = Function('id', "return '" + format + "'");
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var a, container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results; },
if (/\binline\b/.test(root.className)) return; node: function(root) {
quotes = {}; var a, container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results;
_ref = $$('.quotelink', root); if (/\binline\b/.test(root.className)) return;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { quotes = {};
quote = _ref[_i]; _ref = $$('.quotelink', root);
if (qid = quote.hash.slice(1)) quotes[qid] = true; for (_i = 0, _len = _ref.length; _i < _len; _i++) {
} quote = _ref[_i];
id = $('input', root).name; if (qid = quote.hash.slice(1)) quotes[qid] = true;
a = $.el('a', { }
href: "#" + id, id = $('input', root).name;
className: root.hidden ? 'filtered backlink' : 'backlink', a = $.el('a', {
textContent: quoteBacklink.funk(id) href: "#" + id,
}); className: root.hidden ? 'filtered backlink' : 'backlink',
_results = []; textContent: quoteBacklink.funk(id)
for (qid in quotes) {
if (!(el = $.id(qid)) || el.className === 'op' && !conf['OP Backlinks']) {
continue;
}
link = a.cloneNode(true);
if (conf['Quote Preview']) {
$.on(link, 'mouseover', quotePreview.mouseover);
$.on(link, 'mousemove', ui.hover);
$.on(link, 'mouseout', quotePreview.mouseout);
}
if (conf['Quote Inline']) $.on(link, 'click', quoteInline.toggle);
if (!((container = $('.container', el)) && container.parentNode === el)) {
container = $.el('span', {
className: 'container'
});
root = $('.reportbutton', el) || $('span[id]', el);
$.after(root, container);
}
_results.push($.add(container, $.tn(' '), link));
}
return _results;
}); });
_results = [];
for (qid in quotes) {
if (!(el = $.id(qid)) || el.className === 'op' && !conf['OP Backlinks']) {
continue;
}
link = a.cloneNode(true);
if (conf['Quote Preview']) {
$.on(link, 'mouseover', quotePreview.mouseover);
$.on(link, 'mousemove', ui.hover);
$.on(link, 'mouseout', quotePreview.mouseout);
}
if (conf['Quote Inline']) $.on(link, 'click', quoteInline.toggle);
if (!((container = $('.container', el)) && container.parentNode === el)) {
container = $.el('span', {
className: 'container'
});
root = $('.reportbutton', el) || $('span[id]', el);
$.after(root, container);
}
_results.push($.add(container, $.tn(' '), link));
}
return _results;
} }
}; };
quoteInline = { quoteInline = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var quote, _i, _len, _ref, _results; },
_ref = $$('.quotelink, .backlink', root); node: function(root) {
_results = []; var quote, _i, _len, _ref, _results;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { _ref = $$('.quotelink, .backlink', root);
quote = _ref[_i]; _results = [];
if (!quote.hash) continue; for (_i = 0, _len = _ref.length; _i < _len; _i++) {
quote.removeAttribute('onclick'); quote = _ref[_i];
_results.push($.on(quote, 'click', quoteInline.toggle)); if (!quote.hash) continue;
} quote.removeAttribute('onclick');
return _results; _results.push($.on(quote, 'click', quoteInline.toggle));
}); }
return _results;
}, },
toggle: function(e) { toggle: function(e) {
var id; var id;
@ -2935,19 +2942,20 @@
quotePreview = { quotePreview = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var quote, _i, _len, _ref, _results; },
_ref = $$('.quotelink, .backlink', root); node: function(root) {
_results = []; var quote, _i, _len, _ref, _results;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { _ref = $$('.quotelink, .backlink', root);
quote = _ref[_i]; _results = [];
if (!quote.hash) continue; for (_i = 0, _len = _ref.length; _i < _len; _i++) {
$.on(quote, 'mouseover', quotePreview.mouseover); quote = _ref[_i];
$.on(quote, 'mousemove', ui.hover); if (!quote.hash) continue;
_results.push($.on(quote, 'mouseout', quotePreview.mouseout)); $.on(quote, 'mouseover', quotePreview.mouseover);
} $.on(quote, 'mousemove', ui.hover);
return _results; _results.push($.on(quote, 'mouseout', quotePreview.mouseout));
}); }
return _results;
}, },
mouseover: function(e) { mouseover: function(e) {
var el, id, qp, quote, replyID, threadID, _i, _len, _ref, _results; var el, id, qp, quote, replyID, threadID, _i, _len, _ref, _results;
@ -3018,62 +3026,65 @@
quoteOP = { quoteOP = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var quote, tid, _i, _len, _ref, _results; },
if (root.className === 'inline') return; node: function(root) {
tid = g.THREAD_ID || $.x('ancestor::div[contains(@class,"thread")]/div', root).id; var quote, tid, _i, _len, _ref, _results;
_ref = $$('.quotelink', root); if (root.className === 'inline') return;
_results = []; tid = g.THREAD_ID || $.x('ancestor::div[contains(@class,"thread")]/div', root).id;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { _ref = $$('.quotelink', root);
quote = _ref[_i]; _results = [];
if (quote.hash.slice(1) === tid) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
_results.push(quote.innerHTML += '&nbsp;(OP)'); quote = _ref[_i];
} else { if (quote.hash.slice(1) === tid) {
_results.push(void 0); _results.push(quote.innerHTML += '&nbsp;(OP)');
} } else {
_results.push(void 0);
} }
return _results; }
}); return _results;
} }
}; };
quoteDR = { quoteDR = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var quote, tid, _i, _len, _ref, _results; },
if (root.className === 'inline') return; node: function(root) {
tid = g.THREAD_ID || $.x('ancestor::div[contains(@class,"thread")]/div', root).id; var quote, tid, _i, _len, _ref, _results;
_ref = $$('.quotelink', root); if (root.className === 'inline') return;
_results = []; tid = g.THREAD_ID || $.x('ancestor::div[contains(@class,"thread")]/div', root).id;
for (_i = 0, _len = _ref.length; _i < _len; _i++) { _ref = $$('.quotelink', root);
quote = _ref[_i]; _results = [];
if (quote.pathname.indexOf("res/" + tid) === -1 && !quote.pathname.indexOf("/" + g.BOARD + "/res")) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
_results.push(quote.innerHTML += '&nbsp;(Cross-thread)'); quote = _ref[_i];
} else { if (quote.pathname.indexOf("res/" + tid) === -1 && !quote.pathname.indexOf("/" + g.BOARD + "/res")) {
_results.push(void 0); _results.push(quote.innerHTML += '&nbsp;(Cross-thread)');
} } else {
_results.push(void 0);
} }
return _results; }
}); return _results;
} }
}; };
reportButton = { reportButton = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var a, span; },
if (!(a = $('.reportbutton', root))) { node: function(root) {
span = $('span[id]', root); var a, span;
a = $.el('a', { if (!(a = $('.reportbutton', root))) {
className: 'reportbutton', span = $('span[id]', root);
innerHTML: '[&nbsp;!&nbsp;]', a = $.el('a', {
href: 'javascript:;' className: 'reportbutton',
}); innerHTML: '[&nbsp;!&nbsp;]',
$.after(span, a); href: 'javascript:;'
$.after(span, $.tn(' ')); });
} $.after(span, a);
return $.on(a, 'click', reportButton.report); $.after(span, $.tn(' '));
}); }
return $.on(a, 'click', reportButton.report);
}, },
report: function() { report: function() {
var id, set, url; var id, set, url;
@ -3100,7 +3111,7 @@
return 151; return 151;
} }
})(); })();
return g.callbacks.push(threadStats.node); return g.callbacks.push(this.node);
}, },
node: function(root) { node: function(root) {
var imgcount; var imgcount;
@ -3120,7 +3131,7 @@
this.title = d.title; this.title = d.title;
unread.update(); unread.update();
$.on(window, 'scroll', unread.scroll); $.on(window, 'scroll', unread.scroll);
return g.callbacks.push(unread.node); return g.callbacks.push(this.node);
}, },
replies: [], replies: [],
node: function(root) { node: function(root) {
@ -3257,13 +3268,14 @@
imgHover = { imgHover = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var thumb; },
if (!(thumb = $('img[md5]', root))) return; node: function(root) {
$.on(thumb, 'mouseover', imgHover.mouseover); var thumb;
$.on(thumb, 'mousemove', ui.hover); if (!(thumb = $('img[md5]', root))) return;
return $.on(thumb, 'mouseout', ui.hoverend); $.on(thumb, 'mouseover', imgHover.mouseover);
}); $.on(thumb, 'mousemove', ui.hover);
return $.on(thumb, 'mouseout', ui.hoverend);
}, },
mouseover: function() { mouseover: function() {
ui.el = $.el('img', { ui.el = $.el('img', {
@ -3276,18 +3288,19 @@
imgGif = { imgGif = {
init: function() { init: function() {
return g.callbacks.push(function(root) { return g.callbacks.push(this.node);
var src, thumb; },
if (root.hidden || !(thumb = $('img[md5]', root))) return; node: function(root) {
src = thumb.parentNode.href; var src, thumb;
if (/gif$/.test(src)) return thumb.src = src; if (root.hidden || !(thumb = $('img[md5]', root))) return;
}); src = thumb.parentNode.href;
if (/gif$/.test(src)) return thumb.src = src;
} }
}; };
imgExpand = { imgExpand = {
init: function() { init: function() {
g.callbacks.push(imgExpand.node); g.callbacks.push(this.node);
return imgExpand.dialog(); return imgExpand.dialog();
}, },
node: function(root) { node: function(root) {

View File

@ -455,13 +455,14 @@ filter =
strikethroughQuotes = strikethroughQuotes =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
return if root.className is 'inline' node: (root) ->
for quote in $$ '.quotelink', root return if root.className is 'inline'
if (el = $.id quote.hash[1..]) and el.parentNode.parentNode.parentNode.hidden for quote in $$ '.quotelink', root
$.addClass quote, 'filtered' if (el = $.id quote.hash[1..]) and el.parentNode.parentNode.parentNode.hidden
root.hidden = true if conf['Recursive Filtering'] $.addClass quote, 'filtered'
return root.hidden = true if conf['Recursive Filtering']
return
expandComment = expandComment =
init: -> init: ->
@ -578,19 +579,21 @@ expandThread =
replyHiding = replyHiding =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
return unless dd = $ '.doubledash', root
dd.className = 'replyhider'
a = $.el 'a',
textContent: '[ - ]'
href: 'javascript:;'
$.on a, 'click', replyHiding.cb.hide
$.replace dd.firstChild, a
reply = dd.nextSibling node: (root) ->
id = reply.id return unless dd = $ '.doubledash', root
if id of g.hiddenReplies dd.className = 'replyhider'
replyHiding.hide reply a = $.el 'a',
textContent: '[ - ]'
href: 'javascript:;'
$.on a, 'click', replyHiding.cb.hide
$.replace dd.firstChild, a
reply = dd.nextSibling
id = reply.id
if id of g.hiddenReplies
replyHiding.hide reply
cb: cb:
hide: -> hide: ->
@ -875,8 +878,7 @@ qr =
$('textarea', qr.el).focus() $('textarea', qr.el).focus()
form = d.forms[0] form = d.forms[0]
$.before form, link $.before form, link
g.callbacks.push (root) -> g.callbacks.push @node
$.on $('.quotejs + .quotejs', root), 'click', qr.quote
iframe = $.el 'iframe', iframe = $.el 'iframe',
id: 'iframe' id: 'iframe'
@ -901,6 +903,9 @@ qr =
# prevent original captcha input from being focused on reload # prevent original captcha input from being focused on reload
window.location = 'javascript:void(Recaptcha.focus_response_field=function(){})' window.location = 'javascript:void(Recaptcha.focus_response_field=function(){})'
node: (root) ->
$.on $('.quotejs + .quotejs', root), 'click', qr.quote
open: -> open: ->
if qr.el if qr.el
qr.el.hidden = false qr.el.hidden = false
@ -2047,14 +2052,15 @@ watcher =
anonymize = anonymize =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
name = $ '.commentpostername, .postername', root node: (root) ->
name.textContent = 'Anonymous' name = $ '.commentpostername, .postername', root
if trip = $ '.postertrip', root name.textContent = 'Anonymous'
if trip.parentNode.nodeName is 'A' if trip = $ '.postertrip', root
$.rm trip.parentNode if trip.parentNode.nodeName is 'A'
else $.rm trip.parentNode
$.rm trip else
$.rm trip
sauce = sauce =
init: -> init: ->
@ -2086,12 +2092,13 @@ sauce =
revealSpoilers = revealSpoilers =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
return if not (img = $ 'img[alt^=Spoiler]', root) or root.className is 'inline' node: (root) ->
img.removeAttribute 'height' return if not (img = $ 'img[alt^=Spoiler]', root) or root.className is 'inline'
img.removeAttribute 'width' img.removeAttribute 'height'
[_, board, imgID] = img.parentNode.href.match /(\w+)\/src\/(\d+)/ img.removeAttribute 'width'
img.src = "http://0.thumbs.4chan.org/#{board}/thumb/#{imgID}s.jpg" [_, board, imgID] = img.parentNode.href.match /(\w+)\/src\/(\d+)/
img.src = "http://0.thumbs.4chan.org/#{board}/thumb/#{imgID}s.jpg"
Time = Time =
init: -> init: ->
@ -2114,7 +2121,7 @@ Time =
hour = chanOffset + Number hour hour = chanOffset + Number hour
new Date year, month, day, hour, min new Date year, month, day, hour, min
g.callbacks.push Time.node g.callbacks.push @node
node: (root) -> node: (root) ->
return if root.className is 'inline' return if root.className is 'inline'
node = $('.posttime', root) or $('span[id]', root).previousSibling node = $('.posttime', root) or $('span[id]', root).previousSibling
@ -2187,43 +2194,45 @@ quoteBacklink =
init: -> init: ->
format = conf['backlink'].replace /%id/g, "' + id + '" format = conf['backlink'].replace /%id/g, "' + id + '"
quoteBacklink.funk = Function 'id', "return '#{format}'" quoteBacklink.funk = Function 'id', "return '#{format}'"
g.callbacks.push (root) -> g.callbacks.push @node
return if /\binline\b/.test root.className node: (root) ->
quotes = {} return if /\binline\b/.test root.className
for quote in $$ '.quotelink', root quotes = {}
# Don't process >>>/b/. for quote in $$ '.quotelink', root
if qid = quote.hash[1..] # Don't process >>>/b/.
# Duplicate quotes get overwritten. if qid = quote.hash[1..]
quotes[qid] = true # Duplicate quotes get overwritten.
# OP or reply id. quotes[qid] = true
id = $('input', root).name # OP or reply id.
a = $.el 'a', id = $('input', root).name
href: "##{id}" a = $.el 'a',
className: if root.hidden then 'filtered backlink' else 'backlink' href: "##{id}"
textContent: quoteBacklink.funk id className: if root.hidden then 'filtered backlink' else 'backlink'
for qid of quotes textContent: quoteBacklink.funk id
# Don't backlink the OP. for qid of quotes
continue if !(el = $.id qid) or el.className is 'op' and !conf['OP Backlinks'] # Don't backlink the OP.
link = a.cloneNode true continue if !(el = $.id qid) or el.className is 'op' and !conf['OP Backlinks']
if conf['Quote Preview'] link = a.cloneNode true
$.on link, 'mouseover', quotePreview.mouseover if conf['Quote Preview']
$.on link, 'mousemove', ui.hover $.on link, 'mouseover', quotePreview.mouseover
$.on link, 'mouseout', quotePreview.mouseout $.on link, 'mousemove', ui.hover
if conf['Quote Inline'] $.on link, 'mouseout', quotePreview.mouseout
$.on link, 'click', quoteInline.toggle if conf['Quote Inline']
unless (container = $ '.container', el) and container.parentNode is el $.on link, 'click', quoteInline.toggle
container = $.el 'span', className: 'container' unless (container = $ '.container', el) and container.parentNode is el
root = $('.reportbutton', el) or $('span[id]', el) container = $.el 'span', className: 'container'
$.after root, container root = $('.reportbutton', el) or $('span[id]', el)
$.add container, $.tn(' '), link $.after root, container
$.add container, $.tn(' '), link
quoteInline = quoteInline =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
for quote in $$ '.quotelink, .backlink', root node: (root) ->
continue unless quote.hash for quote in $$ '.quotelink, .backlink', root
quote.removeAttribute 'onclick' continue unless quote.hash
$.on quote, 'click', quoteInline.toggle quote.removeAttribute 'onclick'
$.on quote, 'click', quoteInline.toggle
toggle: (e) -> toggle: (e) ->
return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0 return if e.shiftKey or e.altKey or e.ctrlKey or e.metaKey or e.button isnt 0
e.preventDefault() e.preventDefault()
@ -2303,12 +2312,13 @@ quoteInline =
quotePreview = quotePreview =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
for quote in $$ '.quotelink, .backlink', root node: (root) ->
continue unless quote.hash for quote in $$ '.quotelink, .backlink', root
$.on quote, 'mouseover', quotePreview.mouseover continue unless quote.hash
$.on quote, 'mousemove', ui.hover $.on quote, 'mouseover', quotePreview.mouseover
$.on quote, 'mouseout', quotePreview.mouseout $.on quote, 'mousemove', ui.hover
$.on quote, 'mouseout', quotePreview.mouseout
mouseover: (e) -> mouseover: (e) ->
qp = ui.el = $.el 'div', qp = ui.el = $.el 'div',
id: 'qp' id: 'qp'
@ -2354,35 +2364,38 @@ quotePreview =
quoteOP = quoteOP =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
return if root.className is 'inline' node: (root) ->
tid = g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]/div', root).id return if root.className is 'inline'
for quote in $$ '.quotelink', root tid = g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]/div', root).id
if quote.hash[1..] is tid for quote in $$ '.quotelink', root
quote.innerHTML += '&nbsp;(OP)' if quote.hash[1..] is tid
quote.innerHTML += '&nbsp;(OP)'
quoteDR = quoteDR =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
return if root.className is 'inline' node: (root) ->
tid = g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]/div', root).id return if root.className is 'inline'
for quote in $$ '.quotelink', root tid = g.THREAD_ID or $.x('ancestor::div[contains(@class,"thread")]/div', root).id
#if quote leads to a different thread id and is located on the same board (index 0) for quote in $$ '.quotelink', root
if quote.pathname.indexOf("res/#{tid}") is -1 and !quote.pathname.indexOf "/#{g.BOARD}/res" #if quote leads to a different thread id and is located on the same board (index 0)
quote.innerHTML += '&nbsp;(Cross-thread)' if quote.pathname.indexOf("res/#{tid}") is -1 and !quote.pathname.indexOf "/#{g.BOARD}/res"
quote.innerHTML += '&nbsp;(Cross-thread)'
reportButton = reportButton =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
if not a = $ '.reportbutton', root node: (root) ->
span = $ 'span[id]', root if not a = $ '.reportbutton', root
a = $.el 'a', span = $ 'span[id]', root
className: 'reportbutton' a = $.el 'a',
innerHTML: '[&nbsp;!&nbsp;]' className: 'reportbutton'
href: 'javascript:;' innerHTML: '[&nbsp;!&nbsp;]'
$.after span, a href: 'javascript:;'
$.after span, $.tn(' ') $.after span, a
$.on a, 'click', reportButton.report $.after span, $.tn(' ')
$.on a, 'click', reportButton.report
report: -> report: ->
url = "http://sys.4chan.org/#{g.BOARD}/imgboard.php?mode=report&no=#{$.x('preceding-sibling::input', @).name}" url = "http://sys.4chan.org/#{g.BOARD}/imgboard.php?mode=report&no=#{$.x('preceding-sibling::input', @).name}"
id = Date.now() id = Date.now()
@ -2401,7 +2414,7 @@ threadStats =
251 251
else else
151 151
g.callbacks.push threadStats.node g.callbacks.push @node
node: (root) -> node: (root) ->
return if /\binline\b/.test root.className return if /\binline\b/.test root.className
$.id('postcount').textContent = ++threadStats.posts $.id('postcount').textContent = ++threadStats.posts
@ -2416,7 +2429,7 @@ unread =
@title = d.title @title = d.title
unread.update() unread.update()
$.on window, 'scroll', unread.scroll $.on window, 'scroll', unread.scroll
g.callbacks.push unread.node g.callbacks.push @node
replies: [] replies: []
@ -2527,11 +2540,12 @@ redirect =
imgHover = imgHover =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
return unless thumb = $ 'img[md5]', root node: (root) ->
$.on thumb, 'mouseover', imgHover.mouseover return unless thumb = $ 'img[md5]', root
$.on thumb, 'mousemove', ui.hover $.on thumb, 'mouseover', imgHover.mouseover
$.on thumb, 'mouseout', ui.hoverend $.on thumb, 'mousemove', ui.hover
$.on thumb, 'mouseout', ui.hoverend
mouseover: -> mouseover: ->
ui.el = $.el 'img' ui.el = $.el 'img'
id: 'ihover' id: 'ihover'
@ -2540,15 +2554,16 @@ imgHover =
imgGif = imgGif =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push @node
return if root.hidden or !thumb = $ 'img[md5]', root node: (root) ->
src = thumb.parentNode.href return if root.hidden or !thumb = $ 'img[md5]', root
if /gif$/.test src src = thumb.parentNode.href
thumb.src = src if /gif$/.test src
thumb.src = src
imgExpand = imgExpand =
init: -> init: ->
g.callbacks.push imgExpand.node g.callbacks.push @node
imgExpand.dialog() imgExpand.dialog()
node: (root) -> node: (root) ->