{un,}bind -> {off,on}

This commit is contained in:
James Campos 2011-11-04 21:09:39 -07:00
parent a28ac1f44c
commit 8638a5bfab
2 changed files with 152 additions and 152 deletions

View File

@ -403,10 +403,10 @@
} }
return el; return el;
}, },
bind: function(el, eventType, handler) { on: function(el, eventType, handler) {
return el.addEventListener(eventType, handler, false); return el.addEventListener(eventType, handler, false);
}, },
unbind: function(el, eventType, handler) { off: function(el, eventType, handler) {
return el.removeEventListener(eventType, handler, false); return el.removeEventListener(eventType, handler, false);
}, },
isDST: function() { isDST: function() {
@ -612,7 +612,7 @@
_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];
_results.push($.bind(a, 'click', expandComment.expand)); _results.push($.on(a, 'click', expandComment.expand));
} }
return _results; return _results;
}, },
@ -658,12 +658,12 @@
quote.innerHTML += '&nbsp;(OP)'; quote.innerHTML += '&nbsp;(OP)';
} }
if (conf['Quote Preview']) { if (conf['Quote Preview']) {
$.bind(quote, 'mouseover', quotePreview.mouseover); $.on(quote, 'mouseover', quotePreview.mouseover);
$.bind(quote, 'mousemove', ui.hover); $.on(quote, 'mousemove', ui.hover);
$.bind(quote, 'mouseout', quotePreview.mouseout); $.on(quote, 'mouseout', quotePreview.mouseout);
} }
if (conf['Quote Inline']) { if (conf['Quote Inline']) {
$.bind(quote, 'click', quoteInline.toggle); $.on(quote, 'click', quoteInline.toggle);
} }
} }
return $.replace(a.parentNode.parentNode, bq); return $.replace(a.parentNode.parentNode, bq);
@ -680,7 +680,7 @@
textContent: "+ " + span.textContent, textContent: "+ " + span.textContent,
className: 'omittedposts' className: 'omittedposts'
}); });
$.bind(a, 'click', expandThread.cb.toggle); $.on(a, 'click', expandThread.cb.toggle);
_results.push($.replace(span, a)); _results.push($.replace(span, a));
} }
return _results; return _results;
@ -738,7 +738,7 @@
var body, br, href, link, next, quote, reply, table, tables, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _results; var body, br, href, link, next, quote, reply, table, tables, _i, _j, _k, _len, _len2, _len3, _ref, _ref2, _results;
if (req.status !== 200) { if (req.status !== 200) {
a.textContent = "" + req.status + " " + req.statusText; a.textContent = "" + req.status + " " + req.statusText;
$.unbind(a, 'click', expandThread.cb.toggle); $.off(a, 'click', expandThread.cb.toggle);
return; return;
} }
a.textContent = a.textContent.replace('X Loading...', '-'); a.textContent = a.textContent.replace('X Loading...', '-');
@ -786,7 +786,7 @@
a = $.el('a', { a = $.el('a', {
textContent: '[ - ]' textContent: '[ - ]'
}); });
$.bind(a, 'click', replyHiding.cb.hide); $.on(a, 'click', replyHiding.cb.hide);
$.replace(dd.firstChild, a); $.replace(dd.firstChild, a);
reply = dd.nextSibling; reply = dd.nextSibling;
id = reply.id; id = reply.id;
@ -831,7 +831,7 @@
a = $.el('a', { a = $.el('a', {
textContent: "[ + ] " + name + " " + trip textContent: "[ + ] " + name + " " + trip
}); });
$.bind(a, 'click', replyHiding.cb.show); $.on(a, 'click', replyHiding.cb.show);
div = $.el('div', { div = $.el('div', {
className: 'stub' className: 'stub'
}); });
@ -860,7 +860,7 @@
node = _ref[_i]; node = _ref[_i];
node.removeAttribute('accesskey'); node.removeAttribute('accesskey');
} }
return $.bind(d, 'keydown', keybinds.keydown); return $.on(d, 'keydown', keybinds.keydown);
}, },
keydown: function(e) { keydown: function(e) {
var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3; var o, range, selEnd, selStart, ta, thread, valEnd, valMid, valStart, value, _ref, _ref2, _ref3;
@ -1139,8 +1139,8 @@
next = $.el('a', { next = $.el('a', {
textContent: '▼' textContent: '▼'
}); });
$.bind(prev, 'click', nav.prev); $.on(prev, 'click', nav.prev);
$.bind(next, 'click', nav.next); $.on(next, 'click', nav.next);
$.add(span, prev, $.tn(' '), next); $.add(span, prev, $.tn(' '), next);
return $.add(d.body, span); return $.add(d.body, span);
}, },
@ -1210,13 +1210,13 @@
a = $.el('a', { a = $.el('a', {
textContent: '4chan X' textContent: '4chan X'
}); });
$.bind(a, 'click', options.dialog); $.on(a, 'click', options.dialog);
$.replace(home, a); $.replace(home, a);
home = $('#navbotr a'); home = $('#navbotr a');
a = $.el('a', { a = $.el('a', {
textContent: '4chan X' textContent: '4chan X'
}); });
$.bind(a, 'click', options.dialog); $.on(a, 'click', options.dialog);
return $.replace(home, a); return $.replace(home, a);
}, },
dialog: function() { dialog: function() {
@ -1312,7 +1312,7 @@
li = $.el('li', { li = $.el('li', {
innerHTML: "<label><input type=checkbox name='" + key + "' " + checked + ">" + key + "</label><span class=description>: " + description + "</span>" innerHTML: "<label><input type=checkbox name='" + key + "' " + checked + ">" + key + "</label><span class=description>: " + description + "</span>"
}); });
$.bind($('input', li), 'click', $.cb.checked); $.on($('input', li), 'click', $.cb.checked);
$.add(ul, li); $.add(ul, li);
} }
$.add($('#main', dialog), ul); $.add($('#main', dialog), ul);
@ -1322,32 +1322,32 @@
li = $.el('li', { li = $.el('li', {
innerHTML: "<button>hidden: " + hiddenNum + "</button> <span class=description>: Forget all hidden posts. Useful if you accidentally hide a post and have `Show Stubs` disabled." innerHTML: "<button>hidden: " + hiddenNum + "</button> <span class=description>: Forget all hidden posts. Useful if you accidentally hide a post and have `Show Stubs` disabled."
}); });
$.bind($('button', li), 'click', options.clearHidden); $.on($('button', li), 'click', options.clearHidden);
$.add($('ul:nth-child(2)', dialog), li); $.add($('ul:nth-child(2)', dialog), li);
_ref2 = $$('textarea', dialog); _ref2 = $$('textarea', dialog);
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
ta = _ref2[_i]; ta = _ref2[_i];
ta.textContent = conf[ta.name]; ta.textContent = conf[ta.name];
$.bind(ta, 'change', $.cb.value); $.on(ta, 'change', $.cb.value);
} }
(back = $('[name=backlink]', dialog)).value = conf['backlink']; (back = $('[name=backlink]', dialog)).value = conf['backlink'];
(time = $('[name=time]', dialog)).value = conf['time']; (time = $('[name=time]', dialog)).value = conf['time'];
$.bind(back, 'keyup', options.backlink); $.on(back, 'keyup', options.backlink);
$.bind(time, 'keyup', options.time); $.on(time, 'keyup', options.time);
_ref3 = $$('#keybinds input', dialog); _ref3 = $$('#keybinds input', dialog);
for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) { for (_j = 0, _len2 = _ref3.length; _j < _len2; _j++) {
input = _ref3[_j]; input = _ref3[_j];
input.type = 'text'; input.type = 'text';
input.value = conf[input.name]; input.value = conf[input.name];
$.bind(input, 'keydown', options.keybind); $.on(input, 'keydown', options.keybind);
} }
overlay = $.el('div', { overlay = $.el('div', {
id: 'overlay' id: 'overlay'
}); });
$.bind(overlay, 'click', function() { $.on(overlay, 'click', function() {
return $.rm(overlay); return $.rm(overlay);
}); });
$.bind(dialog, 'click', function(e) { $.on(dialog, 'click', function(e) {
return e.stopPropagation(); return e.stopPropagation();
}); });
$.add(overlay, dialog); $.add(overlay, dialog);
@ -1393,7 +1393,7 @@
g.callbacks.push(function(root) { g.callbacks.push(function(root) {
var quote; var quote;
quote = $('.quotejs + a', root); quote = $('.quotejs + a', root);
return $.bind(quote, 'click', QR.quote); return $.on(quote, 'click', QR.quote);
}); });
$.add(d.body, $.el('iframe', { $.add(d.body, $.el('iframe', {
name: 'iframe', name: 'iframe',
@ -1401,7 +1401,7 @@
})); }));
$('#recaptcha_response_field').id = ''; $('#recaptcha_response_field').id = '';
holder = $('#recaptcha_challenge_field_holder'); holder = $('#recaptcha_challenge_field_holder');
$.bind(holder, 'DOMNodeInserted', QR.captchaNode); $.on(holder, 'DOMNodeInserted', QR.captchaNode);
QR.captchaNode({ QR.captchaNode({
target: holder.firstChild target: holder.firstChild
}); });
@ -1425,7 +1425,7 @@
} }
} }
if (conf['Cooldown']) { if (conf['Cooldown']) {
return $.bind(window, 'storage', function(e) { return $.on(window, 'storage', function(e) {
if (e.key === ("" + NAMESPACE + "cooldown/" + g.BOARD)) { if (e.key === ("" + NAMESPACE + "cooldown/" + g.BOARD)) {
return QR.cooldown(); return QR.cooldown();
} }
@ -1438,7 +1438,7 @@
box = $.el('li', { box = $.el('li', {
innerHTML: "<img><a class=x>X</a>" innerHTML: "<img><a class=x>X</a>"
}); });
$.bind($('.x', box), 'click', QR.rmThumb); $.on($('.x', box), 'click', QR.rmThumb);
$.add(box, file); $.add(box, file);
$.add(files, box); $.add(files, box);
QR.stats(); QR.stats();
@ -1552,7 +1552,7 @@
name: 'upfile', name: 'upfile',
accept: QR.accept accept: QR.accept
}); });
$.bind(input, 'change', QR.change); $.on(input, 'change', QR.change);
if (old) { if (old) {
return $.replace(old, file); return $.replace(old, file);
} else { } else {
@ -1571,9 +1571,9 @@
QR.cooldown(); QR.cooldown();
} }
QR.foo(); QR.foo();
$.bind($('.close', qr), 'click', QR.close); $.on($('.close', qr), 'click', QR.close);
$.bind($('form', qr), 'submit', QR.submit); $.on($('form', qr), 'submit', QR.submit);
$.bind($('#recaptcha_response_field', qr), 'keydown', QR.keydown); $.on($('#recaptcha_response_field', qr), 'keydown', QR.keydown);
QR.captchaImg(); QR.captchaImg();
QR.stats(); QR.stats();
$.add(d.body, qr); $.add(d.body, qr);
@ -1735,9 +1735,9 @@
}, },
sys: function() { sys: function() {
var recaptcha; var recaptcha;
$.unbind(d, 'DOMContentLoaded', QR.sys); $.off(d, 'DOMContentLoaded', QR.sys);
if (recaptcha = $('#recaptcha_response_field')) { if (recaptcha = $('#recaptcha_response_field')) {
$.bind(recaptcha, 'keydown', QR.keydown); $.on(recaptcha, 'keydown', QR.keydown);
return; return;
} }
/* /*
@ -1816,7 +1816,7 @@
a = $.el('a', { a = $.el('a', {
textContent: '[ - ]' textContent: '[ - ]'
}); });
$.bind(a, 'click', threadHiding.cb.hide); $.on(a, 'click', threadHiding.cb.hide);
$.prepend(op, a); $.prepend(op, a);
_results.push(op.id in hiddenThreads ? threadHiding.hideHide(thread) : void 0); _results.push(op.id in hiddenThreads ? threadHiding.hideHide(thread) : void 0);
} }
@ -1864,7 +1864,7 @@
a = $.el('a', { a = $.el('a', {
textContent: "[ + ] " + name + trip + " (" + text + ")" textContent: "[ + ] " + name + trip + " (" + text + ")"
}); });
$.bind(a, 'click', threadHiding.cb.show); $.on(a, 'click', threadHiding.cb.show);
div = $.el('div', { div = $.el('div', {
className: 'block' className: 'block'
}); });
@ -1898,10 +1898,10 @@
if (conf['Scroll BG']) { if (conf['Scroll BG']) {
updater.focus = true; updater.focus = true;
} else { } else {
$.bind(window, 'focus', (function() { $.on(window, 'focus', (function() {
return updater.focus = true; return updater.focus = true;
})); }));
$.bind(window, 'blur', (function() { $.on(window, 'blur', (function() {
return updater.focus = false; return updater.focus = false;
})); }));
} }
@ -1923,24 +1923,24 @@
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
input = _ref[_i]; input = _ref[_i];
if (input.type === 'checkbox') { if (input.type === 'checkbox') {
$.bind(input, 'click', $.cb.checked); $.on(input, 'click', $.cb.checked);
$.bind(input, 'click', function() { $.on(input, 'click', function() {
return conf[this.name] = this.checked; return conf[this.name] = this.checked;
}); });
if (input.name === 'Verbose') { if (input.name === 'Verbose') {
$.bind(input, 'click', updater.cb.verbose); $.on(input, 'click', updater.cb.verbose);
updater.cb.verbose.call(input); updater.cb.verbose.call(input);
} else if (input.name === 'Auto Update This') { } else if (input.name === 'Auto Update This') {
$.bind(input, 'click', updater.cb.autoUpdate); $.on(input, 'click', updater.cb.autoUpdate);
updater.cb.autoUpdate.call(input); updater.cb.autoUpdate.call(input);
} }
} else if (input.name === 'Interval') { } else if (input.name === 'Interval') {
$.bind(input, 'change', function() { $.on(input, 'change', function() {
return conf['Interval'] = this.value = parseInt(this.value) || conf['Interval']; return conf['Interval'] = this.value = parseInt(this.value) || conf['Interval'];
}); });
$.bind(input, 'change', $.cb.value); $.on(input, 'change', $.cb.value);
} else if (input.type === 'button') { } else if (input.type === 'button') {
$.bind(input, 'click', updater.update); $.on(input, 'click', updater.update);
} }
} }
return $.add(d.body, dialog); return $.add(d.body, dialog);
@ -2055,11 +2055,11 @@
favicon = $.el('img', { favicon = $.el('img', {
className: 'favicon' className: 'favicon'
}); });
$.bind(favicon, 'click', watcher.cb.toggle); $.on(favicon, 'click', watcher.cb.toggle);
$.before(input, favicon); $.before(input, favicon);
} }
watcher.refresh(); watcher.refresh();
return $.bind(window, 'storage', function(e) { return $.on(window, 'storage', function(e) {
if (e.key === ("" + NAMESPACE + "watched")) { if (e.key === ("" + NAMESPACE + "watched")) {
return watcher.refresh(); return watcher.refresh();
} }
@ -2081,7 +2081,7 @@
x = $.el('a', { x = $.el('a', {
textContent: 'X' textContent: 'X'
}); });
$.bind(x, 'click', watcher.cb.x); $.on(x, 'click', watcher.cb.x);
link = $.el('a', props); link = $.el('a', props);
$.add(div, x, $.tn(' '), link); $.add(div, x, $.tn(' '), link);
$.add(watcher.dialog, div); $.add(watcher.dialog, div);
@ -2356,12 +2356,12 @@
} }
link = a.cloneNode(true); link = a.cloneNode(true);
if (conf['Quote Preview']) { if (conf['Quote Preview']) {
$.bind(link, 'mouseover', quotePreview.mouseover); $.on(link, 'mouseover', quotePreview.mouseover);
$.bind(link, 'mousemove', ui.hover); $.on(link, 'mousemove', ui.hover);
$.bind(link, 'mouseout', quotePreview.mouseout); $.on(link, 'mouseout', quotePreview.mouseout);
} }
if (conf['Quote Inline']) { if (conf['Quote Inline']) {
$.bind(link, 'click', quoteInline.toggle); $.on(link, 'click', quoteInline.toggle);
} }
if (!((container = $('.container', el)) && container.parentNode === el)) { if (!((container = $('.container', el)) && container.parentNode === el)) {
container = $.el('span', { container = $.el('span', {
@ -2388,7 +2388,7 @@
continue; continue;
} }
quote.removeAttribute('onclick'); quote.removeAttribute('onclick');
_results.push($.bind(quote, 'click', quoteInline.toggle)); _results.push($.on(quote, 'click', quoteInline.toggle));
} }
return _results; return _results;
}); });
@ -2508,9 +2508,9 @@
if (!quote.hash) { if (!quote.hash) {
continue; continue;
} }
$.bind(quote, 'mouseover', quotePreview.mouseover); $.on(quote, 'mouseover', quotePreview.mouseover);
$.bind(quote, 'mousemove', ui.hover); $.on(quote, 'mousemove', ui.hover);
_results.push($.bind(quote, 'mouseout', quotePreview.mouseout)); _results.push($.on(quote, 'mouseout', quotePreview.mouseout));
} }
return _results; return _results;
}); });
@ -2614,7 +2614,7 @@
$.after(span, a); $.after(span, a);
$.after(span, $.tn(' ')); $.after(span, $.tn(' '));
} }
return $.bind(a, 'click', reportButton.report); return $.on(a, 'click', reportButton.report);
}); });
}, },
report: function() { report: function() {
@ -2655,7 +2655,7 @@
init: function() { init: function() {
unread.replies = []; unread.replies = [];
d.title = '(0) ' + d.title; d.title = '(0) ' + d.title;
$.bind(window, 'scroll', unread.scroll); $.on(window, 'scroll', unread.scroll);
return g.callbacks.push(unread.node); return g.callbacks.push(unread.node);
}, },
node: function(root) { node: function(root) {
@ -2770,9 +2770,9 @@
if (!(thumb = $('img[md5]', root))) { if (!(thumb = $('img[md5]', root))) {
return; return;
} }
$.bind(thumb, 'mouseover', imgHover.mouseover); $.on(thumb, 'mouseover', imgHover.mouseover);
$.bind(thumb, 'mousemove', ui.hover); $.on(thumb, 'mousemove', ui.hover);
return $.bind(thumb, 'mouseout', ui.hoverend); return $.on(thumb, 'mouseout', ui.hoverend);
}); });
}, },
mouseover: function() { mouseover: function() {
@ -2796,7 +2796,7 @@
label = $.el('label', { label = $.el('label', {
innerHTML: 'Preload Images<input type=checkbox id=imagePreload>' innerHTML: 'Preload Images<input type=checkbox id=imagePreload>'
}); });
$.bind($('input', label), 'click', imgPreloading.click); $.on($('input', label), 'click', imgPreloading.click);
$.add(controls, label); $.add(controls, label);
return g.callbacks.push(imgPreloading.node); return g.callbacks.push(imgPreloading.node);
}, },
@ -2850,7 +2850,7 @@
return; return;
} }
a = thumb.parentNode; a = thumb.parentNode;
$.bind(a, 'click', imgExpand.cb.toggle); $.on(a, 'click', imgExpand.cb.toggle);
if (imgExpand.on && root.className !== 'inline') { if (imgExpand.on && root.className !== 'inline') {
return imgExpand.expand(a.firstChild); return imgExpand.expand(a.firstChild);
} }
@ -2902,13 +2902,13 @@
form = $('body > form'); form = $('body > form');
form.className = klass; form.className = klass;
if (/\bfitheight\b/.test(form.className)) { if (/\bfitheight\b/.test(form.className)) {
$.bind(window, 'resize', imgExpand.resize); $.on(window, 'resize', imgExpand.resize);
if (!imgExpand.style) { if (!imgExpand.style) {
imgExpand.style = $.addStyle(''); imgExpand.style = $.addStyle('');
} }
return imgExpand.resize(); return imgExpand.resize();
} else if (imgExpand.style) { } else if (imgExpand.style) {
return $.unbind(window, 'resize', imgExpand.resize); return $.off(window, 'resize', imgExpand.resize);
} }
} }
}, },
@ -2936,7 +2936,7 @@
_ref = filesize.textContent.match(/(\d+)x/), _ = _ref[0], max = _ref[1]; _ref = filesize.textContent.match(/(\d+)x/), _ = _ref[0], max = _ref[1];
img.style.maxWidth = "-moz-calc(" + max + "px)"; img.style.maxWidth = "-moz-calc(" + max + "px)";
} }
$.bind(img, 'error', imgExpand.error); $.on(img, 'error', imgExpand.error);
thumb.hidden = true; thumb.hidden = true;
return $.add(a, img); return $.add(a, img);
}, },
@ -2977,9 +2977,9 @@
} }
select = $('select', controls); select = $('select', controls);
imgExpand.cb.typeChange.call(select); imgExpand.cb.typeChange.call(select);
$.bind(select, 'change', $.cb.value); $.on(select, 'change', $.cb.value);
$.bind(select, 'change', imgExpand.cb.typeChange); $.on(select, 'change', imgExpand.cb.typeChange);
$.bind($('input', controls), 'click', imgExpand.cb.all); $.on($('input', controls), 'click', imgExpand.cb.all);
form = $('body > form'); form = $('body > form');
return $.prepend(form, controls); return $.prepend(form, controls);
}, },
@ -3003,13 +3003,13 @@
</div>' </div>'
}); });
$.add(d.body, dialog); $.add(d.body, dialog);
return $.bind(window, 'click', firstRun.close); return $.on(window, 'click', firstRun.close);
}, },
close: function() { close: function() {
$.set('firstrun', true); $.set('firstrun', true);
$.rm($('style.firstrun', d.head)); $.rm($('style.firstrun', d.head));
$.rm($('#overlay')); $.rm($('#overlay'));
return $.unbind(window, 'click', firstRun.close); return $.off(window, 'click', firstRun.close);
} }
}; };
Main = { Main = {
@ -3019,11 +3019,11 @@
if (d.body) { if (d.body) {
QR.sys(); QR.sys();
} else { } else {
$.bind(d, 'DOMContentLoaded', QR.sys); $.on(d, 'DOMContentLoaded', QR.sys);
} }
return; return;
} }
$.bind(window, 'message', Main.message); $.on(window, 'message', Main.message);
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') {
@ -3098,12 +3098,12 @@
if (d.body) { if (d.body) {
return Main.onLoad(); return Main.onLoad();
} else { } else {
return $.bind(d, 'DOMContentLoaded', Main.onLoad); return $.on(d, 'DOMContentLoaded', Main.onLoad);
} }
}, },
onLoad: function() { onLoad: function() {
var nodes; var nodes;
$.unbind(d, 'DOMContentLoaded', Main.onLoad); $.off(d, 'DOMContentLoaded', Main.onLoad);
if (conf['404 Redirect'] && d.title === '4chan - 404' && /^\d+$/.test(g.THREAD_ID)) { if (conf['404 Redirect'] && d.title === '4chan - 404' && /^\d+$/.test(g.THREAD_ID)) {
redirect(); redirect();
return; return;
@ -3170,7 +3170,7 @@
return alert(err); return alert(err);
} }
}); });
$.bind($('form[name=delform]'), 'DOMNodeInserted', Main.node); $.on($('form[name=delform]'), 'DOMNodeInserted', Main.node);
options.init(); options.init();
if (!$.get('firstrun')) { if (!$.get('firstrun')) {
return firstRun.init(); return firstRun.init();

View File

@ -279,9 +279,9 @@ $.extend $,
el = d.createElement tag el = d.createElement tag
$.extend el, properties if properties $.extend el, properties if properties
el el
bind: (el, eventType, handler) -> on: (el, eventType, handler) ->
el.addEventListener eventType, handler, false el.addEventListener eventType, handler, false
unbind: (el, eventType, handler) -> off: (el, eventType, handler) ->
el.removeEventListener eventType, handler, false el.removeEventListener eventType, handler, false
isDST: -> isDST: ->
# XXX this should check for DST in NY # XXX this should check for DST in NY
@ -437,7 +437,7 @@ strikethroughQuotes =
expandComment = expandComment =
init: -> init: ->
for a in $$ '.abbr a' for a in $$ '.abbr a'
$.bind a, 'click', expandComment.expand $.on a, 'click', expandComment.expand
expand: (e) -> expand: (e) ->
e.preventDefault() e.preventDefault()
[_, threadID, replyID] = @href.match /(\d+)#(\d+)/ [_, threadID, replyID] = @href.match /(\d+)#(\d+)/
@ -468,11 +468,11 @@ expandComment =
if quote.hash[1..] is threadID if quote.hash[1..] is threadID
quote.innerHTML += '&nbsp;(OP)' quote.innerHTML += '&nbsp;(OP)'
if conf['Quote Preview'] if conf['Quote Preview']
$.bind quote, 'mouseover', quotePreview.mouseover $.on quote, 'mouseover', quotePreview.mouseover
$.bind quote, 'mousemove', ui.hover $.on quote, 'mousemove', ui.hover
$.bind quote, 'mouseout', quotePreview.mouseout $.on quote, 'mouseout', quotePreview.mouseout
if conf['Quote Inline'] if conf['Quote Inline']
$.bind quote, 'click', quoteInline.toggle $.on quote, 'click', quoteInline.toggle
$.replace a.parentNode.parentNode, bq $.replace a.parentNode.parentNode, bq
expandThread = expandThread =
@ -481,7 +481,7 @@ expandThread =
a = $.el 'a', a = $.el 'a',
textContent: "+ #{span.textContent}" textContent: "+ #{span.textContent}"
className: 'omittedposts' className: 'omittedposts'
$.bind a, 'click', expandThread.cb.toggle $.on a, 'click', expandThread.cb.toggle
$.replace span, a $.replace span, a
cb: cb:
@ -522,7 +522,7 @@ expandThread =
parse: (req, pathname, thread, a) -> parse: (req, pathname, thread, a) ->
if req.status isnt 200 if req.status isnt 200
a.textContent = "#{req.status} #{req.statusText}" a.textContent = "#{req.status} #{req.statusText}"
$.unbind a, 'click', expandThread.cb.toggle $.off a, 'click', expandThread.cb.toggle
return return
a.textContent = a.textContent.replace 'X Loading...', '-' a.textContent = a.textContent.replace 'X Loading...', '-'
@ -556,7 +556,7 @@ replyHiding =
dd.className = 'replyhider' dd.className = 'replyhider'
a = $.el 'a', a = $.el 'a',
textContent: '[ - ]' textContent: '[ - ]'
$.bind a, 'click', replyHiding.cb.hide $.on a, 'click', replyHiding.cb.hide
$.replace dd.firstChild, a $.replace dd.firstChild, a
reply = dd.nextSibling reply = dd.nextSibling
@ -595,7 +595,7 @@ replyHiding =
trip = $('.postertrip', reply)?.textContent or '' trip = $('.postertrip', reply)?.textContent or ''
a = $.el 'a', a = $.el 'a',
textContent: "[ + ] #{name} #{trip}" textContent: "[ + ] #{name} #{trip}"
$.bind a, 'click', replyHiding.cb.show $.on a, 'click', replyHiding.cb.show
div = $.el 'div', div = $.el 'div',
className: 'stub' className: 'stub'
@ -616,7 +616,7 @@ keybinds =
init: -> init: ->
for node in $$ '[accesskey]' for node in $$ '[accesskey]'
node.removeAttribute 'accesskey' node.removeAttribute 'accesskey'
$.bind d, 'keydown', keybinds.keydown $.on d, 'keydown', keybinds.keydown
keydown: (e) -> keydown: (e) ->
updater.focus = true updater.focus = true
@ -791,8 +791,8 @@ nav =
next = $.el 'a', next = $.el 'a',
textContent: '' textContent: ''
$.bind prev, 'click', nav.prev $.on prev, 'click', nav.prev
$.bind next, 'click', nav.next $.on next, 'click', nav.next
$.add span, prev, $.tn(' '), next $.add span, prev, $.tn(' '), next
$.add d.body, span $.add d.body, span
@ -856,12 +856,12 @@ options =
home = $ '#navtopr a' home = $ '#navtopr a'
a = $.el 'a', a = $.el 'a',
textContent: '4chan X' textContent: '4chan X'
$.bind a, 'click', options.dialog $.on a, 'click', options.dialog
$.replace home, a $.replace home, a
home = $ '#navbotr a' home = $ '#navbotr a'
a = $.el 'a', a = $.el 'a',
textContent: '4chan X' textContent: '4chan X'
$.bind a, 'click', options.dialog $.on a, 'click', options.dialog
$.replace home, a $.replace home, a
dialog: -> dialog: ->
@ -953,7 +953,7 @@ options =
description = arr[1] description = arr[1]
li = $.el 'li', li = $.el 'li',
innerHTML: "<label><input type=checkbox name='#{key}' #{checked}>#{key}</label><span class=description>: #{description}</span>" innerHTML: "<label><input type=checkbox name='#{key}' #{checked}>#{key}</label><span class=description>: #{description}</span>"
$.bind $('input', li), 'click', $.cb.checked $.on $('input', li), 'click', $.cb.checked
$.add ul, li $.add ul, li
$.add $('#main', dialog), ul $.add $('#main', dialog), ul
@ -961,29 +961,29 @@ options =
hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length hiddenNum = Object.keys(g.hiddenReplies).length + Object.keys(hiddenThreads).length
li = $.el 'li', li = $.el 'li',
innerHTML: "<button>hidden: #{hiddenNum}</button> <span class=description>: Forget all hidden posts. Useful if you accidentally hide a post and have `Show Stubs` disabled." innerHTML: "<button>hidden: #{hiddenNum}</button> <span class=description>: Forget all hidden posts. Useful if you accidentally hide a post and have `Show Stubs` disabled."
$.bind $('button', li), 'click', options.clearHidden $.on $('button', li), 'click', options.clearHidden
$.add $('ul:nth-child(2)', dialog), li $.add $('ul:nth-child(2)', dialog), li
#filter & sauce #filter & sauce
for ta in $$ 'textarea', dialog for ta in $$ 'textarea', dialog
ta.textContent = conf[ta.name] ta.textContent = conf[ta.name]
$.bind ta, 'change', $.cb.value $.on ta, 'change', $.cb.value
#rice #rice
(back = $ '[name=backlink]', dialog).value = conf['backlink'] (back = $ '[name=backlink]', dialog).value = conf['backlink']
(time = $ '[name=time]', dialog).value = conf['time'] (time = $ '[name=time]', dialog).value = conf['time']
$.bind back, 'keyup', options.backlink $.on back, 'keyup', options.backlink
$.bind time, 'keyup', options.time $.on time, 'keyup', options.time
#keybinds #keybinds
for input in $$ '#keybinds input', dialog for input in $$ '#keybinds input', dialog
input.type = 'text' input.type = 'text'
input.value = conf[input.name] input.value = conf[input.name]
$.bind input, 'keydown', options.keybind $.on input, 'keydown', options.keybind
overlay = $.el 'div', id: 'overlay' overlay = $.el 'div', id: 'overlay'
$.bind overlay, 'click', -> $.rm overlay $.on overlay, 'click', -> $.rm overlay
$.bind dialog, 'click', (e) -> e.stopPropagation() $.on dialog, 'click', (e) -> e.stopPropagation()
$.add overlay, dialog $.add overlay, dialog
$.add d.body, overlay $.add d.body, overlay
@ -1024,14 +1024,14 @@ QR =
return unless $('form[name=post]') and $('#recaptcha_response_field') return unless $('form[name=post]') and $('#recaptcha_response_field')
g.callbacks.push (root) -> g.callbacks.push (root) ->
quote = $ '.quotejs + a', root quote = $ '.quotejs + a', root
$.bind quote, 'click', QR.quote $.on quote, 'click', QR.quote
$.add d.body, $.el 'iframe', $.add d.body, $.el 'iframe',
name: 'iframe' name: 'iframe'
hidden: true hidden: true
# nuke id so qr's field focuses on recaptcha reload, instead of normal form's # nuke id so qr's field focuses on recaptcha reload, instead of normal form's
$('#recaptcha_response_field').id = '' $('#recaptcha_response_field').id = ''
holder = $ '#recaptcha_challenge_field_holder' holder = $ '#recaptcha_challenge_field_holder'
$.bind holder, 'DOMNodeInserted', QR.captchaNode $.on holder, 'DOMNodeInserted', QR.captchaNode
QR.captchaNode target: holder.firstChild QR.captchaNode target: holder.firstChild
QR.accept = $('.rules').textContent.match(/: (.+) /)[1].replace /\w+/g, (type) -> QR.accept = $('.rules').textContent.match(/: (.+) /)[1].replace /\w+/g, (type) ->
switch type switch type
@ -1049,12 +1049,12 @@ QR =
if conf['Auto Hide QR'] if conf['Auto Hide QR']
$('#autohide', QR.qr).checked = true $('#autohide', QR.qr).checked = true
if conf['Cooldown'] if conf['Cooldown']
$.bind window, 'storage', (e) -> QR.cooldown() if e.key is "#{NAMESPACE}cooldown/#{g.BOARD}" $.on window, 'storage', (e) -> QR.cooldown() if e.key is "#{NAMESPACE}cooldown/#{g.BOARD}"
attach: (file) -> attach: (file) ->
files = $ '#files', QR.qr files = $ '#files', QR.qr
box = $.el 'li', box = $.el 'li',
innerHTML: "<img><a class=x>X</a>" innerHTML: "<img><a class=x>X</a>"
$.bind $('.x', box), 'click', QR.rmThumb $.on $('.x', box), 'click', QR.rmThumb
$.add box, file $.add box, file
$.add files, box $.add files, box
QR.stats() QR.stats()
@ -1134,7 +1134,7 @@ QR =
type: 'file' type: 'file'
name: 'upfile' name: 'upfile'
accept: QR.accept accept: QR.accept
$.bind input, 'change', QR.change $.on input, 'change', QR.change
if old if old
$.replace old, file $.replace old, file
else else
@ -1179,9 +1179,9 @@ QR =
QR.reset() QR.reset()
QR.cooldown() if conf['Cooldown'] QR.cooldown() if conf['Cooldown']
QR.foo() QR.foo()
$.bind $('.close', qr), 'click', QR.close $.on $('.close', qr), 'click', QR.close
$.bind $('form', qr), 'submit', QR.submit $.on $('form', qr), 'submit', QR.submit
$.bind $('#recaptcha_response_field', qr), 'keydown', QR.keydown $.on $('#recaptcha_response_field', qr), 'keydown', QR.keydown
QR.captchaImg() QR.captchaImg()
QR.stats() QR.stats()
$.add d.body, qr $.add d.body, qr
@ -1295,9 +1295,9 @@ QR =
if $('img.favicon', op).src is Favicon.empty if $('img.favicon', op).src is Favicon.empty
watcher.watch op, id watcher.watch op, id
sys: -> sys: ->
$.unbind d, 'DOMContentLoaded', QR.sys $.off d, 'DOMContentLoaded', QR.sys
if recaptcha = $ '#recaptcha_response_field' #post reporting if recaptcha = $ '#recaptcha_response_field' #post reporting
$.bind recaptcha, 'keydown', QR.keydown $.on recaptcha, 'keydown', QR.keydown
return return
### ###
http://code.google.com/p/chromium/issues/detail?id=20773 http://code.google.com/p/chromium/issues/detail?id=20773
@ -1357,7 +1357,7 @@ threadHiding =
op = thread.firstChild op = thread.firstChild
a = $.el 'a', a = $.el 'a',
textContent: '[ - ]' textContent: '[ - ]'
$.bind a, 'click', threadHiding.cb.hide $.on a, 'click', threadHiding.cb.hide
$.prepend op, a $.prepend op, a
if op.id of hiddenThreads if op.id of hiddenThreads
@ -1399,7 +1399,7 @@ threadHiding =
a = $.el 'a', a = $.el 'a',
textContent: "[ + ] #{name}#{trip} (#{text})" textContent: "[ + ] #{name}#{trip} (#{text})"
$.bind a, 'click', threadHiding.cb.show $.on a, 'click', threadHiding.cb.show
div = $.el 'div', div = $.el 'div',
className: 'block' className: 'block'
@ -1431,8 +1431,8 @@ updater =
if conf['Scroll BG'] if conf['Scroll BG']
updater.focus = true updater.focus = true
else else
$.bind window, 'focus', (-> updater.focus = true) $.on window, 'focus', (-> updater.focus = true)
$.bind window, 'blur', (-> updater.focus = false) $.on window, 'blur', (-> updater.focus = false)
html = "<div class=move><span id=count></span> <span id=timer>-#{conf['Interval']}</span></div>" html = "<div class=move><span id=count></span> <span id=timer>-#{conf['Interval']}</span></div>"
{checkbox} = config.updater {checkbox} = config.updater
for name of checkbox for name of checkbox
@ -1454,19 +1454,19 @@ updater =
for input in $$ 'input', dialog for input in $$ 'input', dialog
if input.type is 'checkbox' if input.type is 'checkbox'
$.bind input, 'click', $.cb.checked $.on input, 'click', $.cb.checked
$.bind input, 'click', -> conf[@name] = @checked $.on input, 'click', -> conf[@name] = @checked
if input.name is 'Verbose' if input.name is 'Verbose'
$.bind input, 'click', updater.cb.verbose $.on input, 'click', updater.cb.verbose
updater.cb.verbose.call input updater.cb.verbose.call input
else if input.name is 'Auto Update This' else if input.name is 'Auto Update This'
$.bind input, 'click', updater.cb.autoUpdate $.on input, 'click', updater.cb.autoUpdate
updater.cb.autoUpdate.call input updater.cb.autoUpdate.call input
else if input.name is 'Interval' else if input.name is 'Interval'
$.bind input, 'change', -> conf['Interval'] = @value = parseInt(@value) or conf['Interval'] $.on input, 'change', -> conf['Interval'] = @value = parseInt(@value) or conf['Interval']
$.bind input, 'change', $.cb.value $.on input, 'change', $.cb.value
else if input.type is 'button' else if input.type is 'button'
$.bind input, 'click', updater.update $.on input, 'click', updater.update
$.add d.body, dialog $.add d.body, dialog
@ -1563,13 +1563,13 @@ watcher =
for input in inputs for input in inputs
favicon = $.el 'img', favicon = $.el 'img',
className: 'favicon' className: 'favicon'
$.bind favicon, 'click', watcher.cb.toggle $.on favicon, 'click', watcher.cb.toggle
$.before input, favicon $.before input, favicon
#populate watcher, display watch buttons #populate watcher, display watch buttons
watcher.refresh() watcher.refresh()
$.bind window, 'storage', (e) -> watcher.refresh() if e.key is "#{NAMESPACE}watched" $.on window, 'storage', (e) -> watcher.refresh() if e.key is "#{NAMESPACE}watched"
refresh: -> refresh: ->
watched = $.get 'watched', {} watched = $.get 'watched', {}
@ -1580,7 +1580,7 @@ watcher =
div = $.el 'div' div = $.el 'div'
x = $.el 'a', x = $.el 'a',
textContent: 'X' textContent: 'X'
$.bind x, 'click', watcher.cb.x $.on x, 'click', watcher.cb.x
link = $.el 'a', props link = $.el 'a', props
$.add div, x, $.tn(' '), link $.add div, x, $.tn(' '), link
@ -1775,11 +1775,11 @@ quoteBacklink =
continue if el.className is 'op' and !conf['OP Backlinks'] continue if el.className is 'op' and !conf['OP Backlinks']
link = a.cloneNode true link = a.cloneNode true
if conf['Quote Preview'] if conf['Quote Preview']
$.bind link, 'mouseover', quotePreview.mouseover $.on link, 'mouseover', quotePreview.mouseover
$.bind link, 'mousemove', ui.hover $.on link, 'mousemove', ui.hover
$.bind link, 'mouseout', quotePreview.mouseout $.on link, 'mouseout', quotePreview.mouseout
if conf['Quote Inline'] if conf['Quote Inline']
$.bind link, 'click', quoteInline.toggle $.on link, 'click', quoteInline.toggle
unless (container = $ '.container', el) and container.parentNode is el unless (container = $ '.container', el) and container.parentNode is el
container = $.el 'span', className: 'container' container = $.el 'span', className: 'container'
root = $('.reportbutton', el) or $('span[id]', el) root = $('.reportbutton', el) or $('span[id]', el)
@ -1792,7 +1792,7 @@ quoteInline =
for quote in $$ '.quotelink, .backlink', root for quote in $$ '.quotelink, .backlink', root
continue unless quote.hash continue unless quote.hash
quote.removeAttribute 'onclick' quote.removeAttribute 'onclick'
$.bind quote, 'click', quoteInline.toggle $.on quote, 'click', quoteInline.toggle
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()
@ -1871,9 +1871,9 @@ quotePreview =
g.callbacks.push (root) -> g.callbacks.push (root) ->
for quote in $$ '.quotelink, .backlink', root for quote in $$ '.quotelink, .backlink', root
continue unless quote.hash continue unless quote.hash
$.bind quote, 'mouseover', quotePreview.mouseover $.on quote, 'mouseover', quotePreview.mouseover
$.bind quote, 'mousemove', ui.hover $.on quote, 'mousemove', ui.hover
$.bind quote, 'mouseout', quotePreview.mouseout $.on quote, 'mouseout', quotePreview.mouseout
mouseover: (e) -> mouseover: (e) ->
qp = ui.el = $.el 'div', qp = ui.el = $.el 'div',
id: 'qp' id: 'qp'
@ -1936,7 +1936,7 @@ reportButton =
innerHTML: '[&nbsp;!&nbsp;]' innerHTML: '[&nbsp;!&nbsp;]'
$.after span, a $.after span, a
$.after span, $.tn(' ') $.after span, $.tn(' ')
$.bind a, 'click', reportButton.report $.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 = "#{NAMESPACE}popup" id = "#{NAMESPACE}popup"
@ -1966,7 +1966,7 @@ unread =
init: -> init: ->
unread.replies = [] unread.replies = []
d.title = '(0) ' + d.title d.title = '(0) ' + d.title
$.bind window, 'scroll', unread.scroll $.on window, 'scroll', unread.scroll
g.callbacks.push unread.node g.callbacks.push unread.node
node: (root) -> node: (root) ->
@ -2045,9 +2045,9 @@ imgHover =
init: -> init: ->
g.callbacks.push (root) -> g.callbacks.push (root) ->
return unless thumb = $ 'img[md5]', root return unless thumb = $ 'img[md5]', root
$.bind thumb, 'mouseover', imgHover.mouseover $.on thumb, 'mouseover', imgHover.mouseover
$.bind thumb, 'mousemove', ui.hover $.on thumb, 'mousemove', ui.hover
$.bind thumb, 'mouseout', ui.hoverend $.on thumb, 'mouseout', ui.hoverend
mouseover: -> mouseover: ->
ui.el = $.el 'img' ui.el = $.el 'img'
id: 'iHover' id: 'iHover'
@ -2064,7 +2064,7 @@ imgPreloading =
label = $.el 'label', label = $.el 'label',
innerHTML: 'Preload Images<input type=checkbox id=imagePreload>' innerHTML: 'Preload Images<input type=checkbox id=imagePreload>'
$.bind $('input', label), 'click', imgPreloading.click $.on $('input', label), 'click', imgPreloading.click
$.add controls, label $.add controls, label
g.callbacks.push imgPreloading.node g.callbacks.push imgPreloading.node
@ -2095,7 +2095,7 @@ imgExpand =
node: (root) -> node: (root) ->
return unless thumb = $ 'img[md5]', root return unless thumb = $ 'img[md5]', root
a = thumb.parentNode a = thumb.parentNode
$.bind a, 'click', imgExpand.cb.toggle $.on a, 'click', imgExpand.cb.toggle
if imgExpand.on and root.className isnt 'inline' then imgExpand.expand a.firstChild if imgExpand.on and root.className isnt 'inline' then imgExpand.expand a.firstChild
cb: cb:
toggle: (e) -> toggle: (e) ->
@ -2123,12 +2123,12 @@ imgExpand =
form = $('body > form') form = $('body > form')
form.className = klass form.className = klass
if /\bfitheight\b/.test form.className if /\bfitheight\b/.test form.className
$.bind window, 'resize', imgExpand.resize $.on window, 'resize', imgExpand.resize
unless imgExpand.style unless imgExpand.style
imgExpand.style = $.addStyle '' imgExpand.style = $.addStyle ''
imgExpand.resize() imgExpand.resize()
else if imgExpand.style else if imgExpand.style
$.unbind window, 'resize', imgExpand.resize $.off window, 'resize', imgExpand.resize
toggle: (a) -> toggle: (a) ->
thumb = a.firstChild thumb = a.firstChild
@ -2149,7 +2149,7 @@ imgExpand =
filesize = $ '.filesize', a.parentNode filesize = $ '.filesize', a.parentNode
[_, max] = filesize.textContent.match /(\d+)x/ [_, max] = filesize.textContent.match /(\d+)x/
img.style.maxWidth = "-moz-calc(#{max}px)" img.style.maxWidth = "-moz-calc(#{max}px)"
$.bind img, 'error', imgExpand.error $.on img, 'error', imgExpand.error
thumb.hidden = true thumb.hidden = true
$.add a, img $.add a, img
@ -2178,9 +2178,9 @@ imgExpand =
break break
select = $ 'select', controls select = $ 'select', controls
imgExpand.cb.typeChange.call select imgExpand.cb.typeChange.call select
$.bind select, 'change', $.cb.value $.on select, 'change', $.cb.value
$.bind select, 'change', imgExpand.cb.typeChange $.on select, 'change', imgExpand.cb.typeChange
$.bind $('input', controls), 'click', imgExpand.cb.all $.on $('input', controls), 'click', imgExpand.cb.all
form = $ 'body > form' form = $ 'body > form'
$.prepend form, controls $.prepend form, controls
@ -2258,13 +2258,13 @@ firstRun =
</div>' </div>'
$.add d.body, dialog $.add d.body, dialog
$.bind window, 'click', firstRun.close $.on window, 'click', firstRun.close
close: -> close: ->
$.set 'firstrun', true $.set 'firstrun', true
$.rm $ 'style.firstrun', d.head $.rm $ 'style.firstrun', d.head
$.rm $ '#overlay' $.rm $ '#overlay'
$.unbind window, 'click', firstRun.close $.off window, 'click', firstRun.close
Main = Main =
init: -> init: ->
@ -2272,10 +2272,10 @@ Main =
if d.body if d.body
QR.sys() QR.sys()
else else
$.bind d, 'DOMContentLoaded', QR.sys $.on d, 'DOMContentLoaded', QR.sys
return return
$.bind window, 'message', Main.message $.on window, 'message', Main.message
pathname = location.pathname.substring(1).split('/') pathname = location.pathname.substring(1).split('/')
[g.BOARD, temp] = pathname [g.BOARD, temp] = pathname
@ -2353,10 +2353,10 @@ Main =
if d.body if d.body
Main.onLoad() Main.onLoad()
else else
$.bind d, 'DOMContentLoaded', Main.onLoad $.on d, 'DOMContentLoaded', Main.onLoad
onLoad: -> onLoad: ->
$.unbind d, 'DOMContentLoaded', Main.onLoad $.off d, 'DOMContentLoaded', Main.onLoad
if conf['404 Redirect'] and d.title is '4chan - 404' and /^\d+$/.test g.THREAD_ID if conf['404 Redirect'] and d.title is '4chan - 404' and /^\d+$/.test g.THREAD_ID
redirect() redirect()
return return
@ -2422,7 +2422,7 @@ Main =
nodes.forEach callback nodes.forEach callback
catch err catch err
alert err alert err
$.bind $('form[name=delform]'), 'DOMNodeInserted', Main.node $.on $('form[name=delform]'), 'DOMNodeInserted', Main.node
options.init() options.init()
unless $.get 'firstrun' unless $.get 'firstrun'