Merge branch 'master' into QR

This commit is contained in:
James Campos 2011-09-04 22:50:39 -07:00
commit 7cc74db296
2 changed files with 95 additions and 102 deletions

View File

@ -311,14 +311,17 @@
script = $.el('script', { script = $.el('script', {
textContent: "(" + code + ")()" textContent: "(" + code + ")()"
}); });
$.append(d.head, script); $.add(d.head, script);
return $.rm(script); return $.rm(script);
}, },
xhr: function(url, cb) { ajax: function(url, cb, type) {
var r; var r;
if (type == null) {
type = 'get';
}
r = new XMLHttpRequest(); r = new XMLHttpRequest();
r.onload = cb; r.onload = cb;
r.open('get', url, true); r.open(type, url, true);
r.send(); r.send();
return r; return r;
}, },
@ -331,7 +334,7 @@
return req.callbacks.push(cb); return req.callbacks.push(cb);
} }
} else { } else {
req = $.xhr(url, (function() { req = $.ajax(url, (function() {
var cb, _i, _len, _ref, _results; var cb, _i, _len, _ref, _results;
_ref = this.callbacks; _ref = this.callbacks;
_results = []; _results = [];
@ -360,7 +363,7 @@
style = $.el('style', { style = $.el('style', {
textContent: css textContent: css
}); });
$.append(d.head, style); $.add(d.head, style);
return style; return style;
}, },
x: function(path, root) { x: function(path, root) {
@ -375,12 +378,6 @@
replace: function(root, el) { replace: function(root, el) {
return root.parentNode.replaceChild(el, root); return root.parentNode.replaceChild(el, root);
}, },
hide: function(el) {
return el.hidden = true;
},
show: function(el) {
return el.hidden = false;
},
addClass: function(el, className) { addClass: function(el, className) {
return el.classList.add(className); return el.classList.add(className);
}, },
@ -390,7 +387,7 @@
rm: function(el) { rm: function(el) {
return el.parentNode.removeChild(el); return el.parentNode.removeChild(el);
}, },
append: function() { add: function() {
var child, children, parent, _i, _len, _results; var child, children, parent, _i, _len, _results;
parent = arguments[0], children = 2 <= arguments.length ? __slice.call(arguments, 1) : []; parent = arguments[0], children = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
_results = []; _results = [];
@ -728,7 +725,7 @@
hide: function(reply) { hide: function(reply) {
var a, div, id, name, table, trip, _ref; var a, div, id, name, table, trip, _ref;
table = reply.parentNode.parentNode.parentNode; table = reply.parentNode.parentNode.parentNode;
$.hide(table); table.hidden = true;
if (conf['Show Stubs']) { if (conf['Show Stubs']) {
name = $('span.commentpostername', reply).textContent; name = $('span.commentpostername', reply).textContent;
trip = ((_ref = $('span.postertrip', reply)) != null ? _ref.textContent : void 0) || ''; trip = ((_ref = $('span.postertrip', reply)) != null ? _ref.textContent : void 0) || '';
@ -739,7 +736,7 @@
div = $.el('div', { div = $.el('div', {
className: 'stub' className: 'stub'
}); });
$.append(div, a); $.add(div, a);
$.before(table, div); $.before(table, div);
} }
id = reply.id; id = reply.id;
@ -748,7 +745,7 @@
}, },
show: function(table) { show: function(table) {
var id; var id;
$.show(table); table.hidden = false;
id = $('td[id]', table).id; id = $('td[id]', table).id;
delete g.hiddenReplies[id]; delete g.hiddenReplies[id];
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies); return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
@ -997,8 +994,8 @@
}); });
$.bind(prev, 'click', nav.prev); $.bind(prev, 'click', nav.prev);
$.bind(next, 'click', nav.next); $.bind(next, 'click', nav.next);
$.append(span, prev, $.tn(' '), next); $.add(span, prev, $.tn(' '), next);
return $.append(d.body, span); return $.add(d.body, span);
}, },
prev: function() { prev: function() {
return nav.scroll(-1); return nav.scroll(-1);
@ -1099,15 +1096,15 @@
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); $.bind($('input', li), 'click', $.cb.checked);
$.append(ul, li); $.add(ul, li);
} }
$.append(main, ul); $.add(main, ul);
} }
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); $.bind($('button', li), 'click', options.clearHidden);
$.append($('ul:nth-child(2)', dialog), li); $.add($('ul:nth-child(2)', dialog), li);
$.bind($('#flavors', dialog), 'change', $.cb.value); $.bind($('#flavors', dialog), 'change', $.cb.value);
$.bind($('input[name=time]', dialog), 'keyup', options.time); $.bind($('input[name=time]', dialog), 'keyup', options.time);
$.bind($('input[name=backlink]', dialog), 'keyup', options.backlink); $.bind($('input[name=backlink]', dialog), 'keyup', options.backlink);
@ -1126,8 +1123,8 @@
overlay = $.el('div', { overlay = $.el('div', {
id: 'overlay' id: 'overlay'
}); });
$.append(overlay, dialog); $.add(overlay, dialog);
$.append(d.body, overlay); $.add(d.body, overlay);
options.time.call($('input[name=time]', dialog)); options.time.call($('input[name=time]', dialog));
options.backlink.call($('input[name=backlink]', dialog)); options.backlink.call($('input[name=backlink]', dialog));
$.bind(overlay, 'click', function() { $.bind(overlay, 'click', function() {
@ -1606,7 +1603,7 @@
name: 'iframe', name: 'iframe',
hidden: true hidden: true
}); });
$.append(d.body, iframe); $.add(d.body, iframe);
return $('#recaptcha_response_field').id = ''; return $('#recaptcha_response_field').id = '';
}, },
attach: function() { attach: function() {
@ -1618,7 +1615,7 @@
$.bind(fileDiv.lastChild, 'click', (function() { $.bind(fileDiv.lastChild, 'click', (function() {
return $.rm(this.parentNode); return $.rm(this.parentNode);
})); }));
return $.append($('#files', qr.el), fileDiv); return $.add($('#files', qr.el), fileDiv);
}, },
attachNext: function() { attachNext: function() {
var file, fileDiv, oldFile; var file, fileDiv, oldFile;
@ -1689,7 +1686,7 @@
$.bind($('img', qr.el), 'click', Recaptcha.reload); $.bind($('img', qr.el), 'click', Recaptcha.reload);
$.bind($('#dummy', qr.el), 'keydown', Recaptcha.listener); $.bind($('#dummy', qr.el), 'keydown', Recaptcha.listener);
$.bind($('#dummy', qr.el), 'keydown', qr.captchaKeydown); $.bind($('#dummy', qr.el), 'keydown', qr.captchaKeydown);
return $.append(d.body, qr.el); return $.add(d.body, qr.el);
}, },
message: function(e) { message: function(e) {
var data, duration, fileCount; var data, duration, fileCount;
@ -1922,10 +1919,10 @@
}); });
$.before(node, op); $.before(node, op);
while (node.nodeName !== 'BLOCKQUOTE') { while (node.nodeName !== 'BLOCKQUOTE') {
$.append(op, node); $.add(op, node);
node = op.nextSibling; node = op.nextSibling;
} }
$.append(op, node); $.add(op, node);
op.id = $('input[name]', op).name; op.id = $('input[name]', op).name;
return op; return op;
}, },
@ -1940,7 +1937,7 @@
}); });
$.before(node, div); $.before(node, div);
while (node.nodeName !== 'HR') { while (node.nodeName !== 'HR') {
$.append(div, node); $.add(div, node);
node = div.nextSibling; node = div.nextSibling;
} }
node = node.nextElementSibling; node = node.nextElementSibling;
@ -2013,20 +2010,20 @@
div = $.el('div', { div = $.el('div', {
className: 'block' className: 'block'
}); });
$.append(div, a); $.add(div, a);
$.append(thread, div); $.add(thread, div);
return $.addClass(thread, 'stub'); return $.addClass(thread, 'stub');
} else { } else {
$.hide(thread); thread.hidden = true;
return $.hide(thread.nextSibling); return thread.nextSibling.hidden = true;
} }
}, },
show: function(thread) { show: function(thread) {
var hiddenThreads, id; var hiddenThreads, id;
$.rm($('div.block', thread)); $.rm($('div.block', thread));
$.removeClass(thread, 'stub'); $.removeClass(thread, 'stub');
$.show(thread); thread.hidden = false;
$.show(thread.nextSibling); thread.nextSibling.hidden = false;
id = thread.firstChild.id; id = thread.firstChild.id;
hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {}); hiddenThreads = $.get("hiddenThreads/" + g.BOARD + "/", {});
delete hiddenThreads[id]; delete hiddenThreads[id];
@ -2088,19 +2085,19 @@
$.bind(input, 'click', updater.updateNow); $.bind(input, 'click', updater.updateNow);
} }
} }
return $.append(d.body, dialog); return $.add(d.body, dialog);
}, },
cb: { cb: {
verbose: function() { verbose: function() {
if (conf['Verbose']) { if (conf['Verbose']) {
updater.count.textContent = '+0'; updater.count.textContent = '+0';
return $.show(updater.timer); return updater.timer.hidden = false;
} else { } else {
$.extend(updater.count, { $.extend(updater.count, {
className: '', className: '',
textContent: 'Thread Updater' textContent: 'Thread Updater'
}); });
return $.hide(updater.timer); return updater.timer.hidden = true;
} }
}, },
autoUpdate: function() { autoUpdate: function() {
@ -2181,7 +2178,7 @@
} }
url = location.pathname + '?' + Date.now(); url = location.pathname + '?' + Date.now();
cb = updater.cb.update; cb = updater.cb.update;
return updater.request = $.xhr(url, cb); return updater.request = $.ajax(url, cb);
} }
}; };
watcher = { watcher = {
@ -2192,7 +2189,7 @@
top: '50px', top: '50px',
left: '0px' left: '0px'
}, html); }, html);
$.append(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];
@ -2234,8 +2231,8 @@
}); });
$.bind(x, 'click', watcher.cb.x); $.bind(x, 'click', watcher.cb.x);
link = $.el('a', props); link = $.el('a', props);
$.append(div, x, $.tn(' '), link); $.add(div, x, $.tn(' '), link);
$.append(watcher.dialog, div); $.add(watcher.dialog, div);
} }
} }
watchedBoard = watched[g.BOARD] || {}; watchedBoard = watched[g.BOARD] || {};
@ -2345,7 +2342,7 @@
href: prefix + suffix, href: prefix + suffix,
target: '_blank' target: '_blank'
}); });
_results.push($.append(span, $.tn(' '), link)); _results.push($.add(span, $.tn(' '), link));
} }
return _results; return _results;
} }
@ -2530,7 +2527,7 @@
root = $('.reportbutton', el) || $('span[id^=no]', el); root = $('.reportbutton', el) || $('span[id^=no]', el);
$.after(root, container); $.after(root, container);
} }
_results.push($.append(container, $.tn(' '), link)); _results.push($.add(container, $.tn(' '), link));
} }
return _results; return _results;
}); });
@ -2567,7 +2564,7 @@
for (_i = 0, _len = _ref.length; _i < _len; _i++) { for (_i = 0, _len = _ref.length; _i < _len; _i++) {
inlined = _ref[_i]; inlined = _ref[_i];
if (hidden = $.id(inlined.name)) { if (hidden = $.id(inlined.name)) {
$.show($.x('ancestor::table[1]', hidden)); $.x('ancestor::table[1]', hidden).hidden = false;
} }
} }
return; return;
@ -2580,7 +2577,7 @@
return; return;
} }
$.after(this.parentNode, inline); $.after(this.parentNode, inline);
$.hide($.x('ancestor::table[1]', el)); $.x('ancestor::table[1]', el).hidden = true;
} else { } else {
$.after(root, inline); $.after(root, inline);
} }
@ -2670,7 +2667,7 @@
id: 'qp', id: 'qp',
className: 'replyhl' className: 'replyhl'
}); });
$.append(d.body, qp); $.add(d.body, qp);
id = this.hash.slice(1); id = this.hash.slice(1);
if (el = $.id(id)) { if (el = $.id(id)) {
qp.innerHTML = el.innerHTML; qp.innerHTML = el.innerHTML;
@ -2787,7 +2784,7 @@
dialog.className = 'dialog'; dialog.className = 'dialog';
threadStats.postcountEl = $('#postcount', dialog); threadStats.postcountEl = $('#postcount', dialog);
threadStats.imagecountEl = $('#imagecount', dialog); threadStats.imagecountEl = $('#imagecount', dialog);
$.append(d.body, dialog); $.add(d.body, dialog);
return g.callbacks.push(threadStats.node); return g.callbacks.push(threadStats.node);
}, },
node: function(root) { node: function(root) {
@ -2966,7 +2963,7 @@
id: 'iHover', id: 'iHover',
src: this.parentNode.href src: this.parentNode.href
}); });
return $.append(d.body, ui.el); return $.add(d.body, ui.el);
} }
}; };
imgPreloading = { imgPreloading = {
@ -3072,12 +3069,12 @@
} }
}, },
contract: function(thumb) { contract: function(thumb) {
$.show(thumb); thumb.hidden = false;
return $.rm(thumb.nextSibling); return $.rm(thumb.nextSibling);
}, },
expand: function(thumb) { expand: function(thumb) {
var a, filesize, img, max, _, _ref2; var a, filesize, img, max, _, _ref2;
$.hide(thumb); thumb.hidden = true;
a = thumb.parentNode; a = thumb.parentNode;
img = $.el('img', { img = $.el('img', {
src: a.href src: a.href
@ -3087,7 +3084,7 @@
_ref2 = filesize.textContent.match(/(\d+)x/), _ = _ref2[0], max = _ref2[1]; _ref2 = filesize.textContent.match(/(\d+)x/), _ = _ref2[0], max = _ref2[1];
img.style.maxWidth = "-moz-calc(" + max + "px)"; img.style.maxWidth = "-moz-calc(" + max + "px)";
} }
return $.append(a, img); return $.add(a, img);
}, },
dialog: function() { dialog: function() {
var controls, delform, imageType, option, select, _i, _len, _ref2; var controls, delform, imageType, option, select, _i, _len, _ref2;
@ -3126,7 +3123,7 @@
className: 'firstrun', className: 'firstrun',
innerHTML: " <div id=options> <div class='reply dialog'> <p>Click the <strong>4chan X</strong> buttons for options; they are at the top and bottom of the page.</p> <p>Updater options are in the updater dialog in replies at the bottom-right corner of the window.</p> <p>If you don't see the buttons, try disabling your userstyles.</p> </div> </div>" innerHTML: " <div id=options> <div class='reply dialog'> <p>Click the <strong>4chan X</strong> buttons for options; they are at the top and bottom of the page.</p> <p>Updater options are in the updater dialog in replies at the bottom-right corner of the window.</p> <p>If you don't see the buttons, try disabling your userstyles.</p> </div> </div>"
}); });
$.append(d.body, dialog); $.add(d.body, dialog);
return $.bind(window, 'click', firstRun.close); return $.bind(window, 'click', firstRun.close);
}, },
close: function() { close: function() {

View File

@ -217,12 +217,12 @@ $.extend $,
globalEval: (code) -> globalEval: (code) ->
script = $.el 'script', script = $.el 'script',
textContent: "(#{code})()" textContent: "(#{code})()"
$.append d.head, script $.add d.head, script
$.rm script $.rm script
xhr: (url, cb) -> ajax: (url, cb, type='get') ->
r = new XMLHttpRequest() r = new XMLHttpRequest()
r.onload = cb r.onload = cb
r.open 'get', url, true r.open type, url, true
r.send() r.send()
r r
cache: (url, cb) -> cache: (url, cb) ->
@ -232,7 +232,7 @@ $.extend $,
else else
req.callbacks.push cb req.callbacks.push cb
else else
req = $.xhr url, (-> cb.call @ for cb in @callbacks) req = $.ajax url, (-> cb.call @ for cb in @callbacks)
req.callbacks = [cb] req.callbacks = [cb]
$.cache.requests[url] = req $.cache.requests[url] = req
cb: cb:
@ -245,7 +245,7 @@ $.extend $,
addStyle: (css) -> addStyle: (css) ->
style = $.el 'style', style = $.el 'style',
textContent: css textContent: css
$.append d.head, style $.add d.head, style
style style
x: (path, root=d.body) -> x: (path, root=d.body) ->
d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null). d.evaluate(path, root, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).
@ -254,17 +254,13 @@ $.extend $,
d.createTextNode s d.createTextNode s
replace: (root, el) -> replace: (root, el) ->
root.parentNode.replaceChild el, root root.parentNode.replaceChild el, root
hide: (el) ->
el.hidden = true
show: (el) ->
el.hidden = false
addClass: (el, className) -> addClass: (el, className) ->
el.classList.add className el.classList.add className
removeClass: (el, className) -> removeClass: (el, className) ->
el.classList.remove className el.classList.remove className
rm: (el) -> rm: (el) ->
el.parentNode.removeChild el el.parentNode.removeChild el
append: (parent, children...) -> add: (parent, children...) ->
for child in children for child in children
parent.appendChild child parent.appendChild child
prepend: (parent, child) -> prepend: (parent, child) ->
@ -517,7 +513,7 @@ replyHiding =
hide: (reply) -> hide: (reply) ->
table = reply.parentNode.parentNode.parentNode table = reply.parentNode.parentNode.parentNode
$.hide table table.hidden = true
if conf['Show Stubs'] if conf['Show Stubs']
name = $('span.commentpostername', reply).textContent name = $('span.commentpostername', reply).textContent
@ -528,7 +524,7 @@ replyHiding =
div = $.el 'div', div = $.el 'div',
className: 'stub' className: 'stub'
$.append div, a $.add div, a
$.before table, div $.before table, div
id = reply.id id = reply.id
@ -536,7 +532,7 @@ replyHiding =
$.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies $.set "hiddenReplies/#{g.BOARD}/", g.hiddenReplies
show: (table) -> show: (table) ->
$.show table table.hidden = false
id = $('td[id]', table).id id = $('td[id]', table).id
delete g.hiddenReplies[id] delete g.hiddenReplies[id]
@ -719,8 +715,8 @@ nav =
$.bind prev, 'click', nav.prev $.bind prev, 'click', nav.prev
$.bind next, 'click', nav.next $.bind next, 'click', nav.next
$.append span, prev, $.tn(' '), next $.add span, prev, $.tn(' '), next
$.append d.body, span $.add d.body, span
prev: -> prev: ->
nav.scroll -1 nav.scroll -1
@ -872,13 +868,13 @@ options =
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 $.bind $('input', li), 'click', $.cb.checked
$.append ul, li $.add ul, li
$.append main, ul $.add main, ul
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 $.bind $('button', li), 'click', options.clearHidden
$.append $('ul:nth-child(2)', dialog), li $.add $('ul:nth-child(2)', dialog), li
$.bind $('#flavors', dialog), 'change', $.cb.value $.bind $('#flavors', dialog), 'change', $.cb.value
$.bind $('input[name=time]', dialog), 'keyup', options.time $.bind $('input[name=time]', dialog), 'keyup', options.time
@ -894,8 +890,8 @@ options =
https://bugzilla.mozilla.org/show_bug.cgi?id=579776 https://bugzilla.mozilla.org/show_bug.cgi?id=579776
### ###
overlay = $.el 'div', id: 'overlay' overlay = $.el 'div', id: 'overlay'
$.append overlay, dialog $.add overlay, dialog
$.append d.body, overlay $.add d.body, overlay
options.time.call $('input[name=time]', dialog) options.time.call $('input[name=time]', dialog)
options.backlink.call $('input[name=backlink]', dialog) options.backlink.call $('input[name=backlink]', dialog)
@ -1269,7 +1265,7 @@ qr =
iframe = $.el 'iframe', iframe = $.el 'iframe',
name: 'iframe' name: 'iframe'
hidden: true hidden: true
$.append d.body, iframe $.add d.body, iframe
#hack - nuke id so it doesn't grab focus when reloading #hack - nuke id so it doesn't grab focus when reloading
$('#recaptcha_response_field').id = '' $('#recaptcha_response_field').id = ''
@ -1278,7 +1274,7 @@ qr =
fileDiv = $.el 'div', innerHTML: "<input type=file name=upfile accept='#{qr.acceptFiles}'><a>X</a>" fileDiv = $.el 'div', innerHTML: "<input type=file name=upfile accept='#{qr.acceptFiles}'><a>X</a>"
$.bind fileDiv.firstChild, 'change', qr.validateFileSize $.bind fileDiv.firstChild, 'change', qr.validateFileSize
$.bind fileDiv.lastChild, 'click', (-> $.rm @parentNode) $.bind fileDiv.lastChild, 'click', (-> $.rm @parentNode)
$.append $('#files', qr.el), fileDiv $.add $('#files', qr.el), fileDiv
attachNext: -> attachNext: ->
fileDiv = $.rm $('#files div', qr.el) fileDiv = $.rm $('#files div', qr.el)
@ -1364,7 +1360,7 @@ qr =
$.bind $('#dummy', qr.el), 'keydown', Recaptcha.listener $.bind $('#dummy', qr.el), 'keydown', Recaptcha.listener
$.bind $('#dummy', qr.el), 'keydown', qr.captchaKeydown $.bind $('#dummy', qr.el), 'keydown', qr.captchaKeydown
$.append d.body, qr.el $.add d.body, qr.el
message: (e) -> message: (e) ->
$('iframe[name=iframe]').src = 'about:blank' $('iframe[name=iframe]').src = 'about:blank'
@ -1556,9 +1552,9 @@ threading =
className: 'op' className: 'op'
$.before node, op $.before node, op
while node.nodeName isnt 'BLOCKQUOTE' while node.nodeName isnt 'BLOCKQUOTE'
$.append op, node $.add op, node
node = op.nextSibling node = op.nextSibling
$.append op, node #add the blockquote $.add op, node #add the blockquote
op.id = $('input[name]', op).name op.id = $('input[name]', op).name
op op
@ -1572,7 +1568,7 @@ threading =
$.before node, div $.before node, div
while node.nodeName isnt 'HR' while node.nodeName isnt 'HR'
$.append div, node $.add div, node
node = div.nextSibling node = div.nextSibling
node = node.nextElementSibling #skip text node node = node.nextElementSibling #skip text node
@ -1634,18 +1630,18 @@ threadHiding =
div = $.el 'div', div = $.el 'div',
className: 'block' className: 'block'
$.append div, a $.add div, a
$.append thread, div $.add thread, div
$.addClass thread, 'stub' $.addClass thread, 'stub'
else else
$.hide thread thread.hidden = true
$.hide thread.nextSibling thread.nextSibling.hidden = true
show: (thread) -> show: (thread) ->
$.rm $ 'div.block', thread $.rm $ 'div.block', thread
$.removeClass thread, 'stub' $.removeClass thread, 'stub'
$.show thread thread.hidden = false
$.show thread.nextSibling thread.nextSibling.hidden = false
id = thread.firstChild.id id = thread.firstChild.id
@ -1696,18 +1692,18 @@ updater =
else if input.type is 'button' else if input.type is 'button'
$.bind input, 'click', updater.updateNow $.bind input, 'click', updater.updateNow
$.append d.body, dialog $.add d.body, dialog
cb: cb:
verbose: -> verbose: ->
if conf['Verbose'] if conf['Verbose']
updater.count.textContent = '+0' updater.count.textContent = '+0'
$.show updater.timer updater.timer.hidden = false
else else
$.extend updater.count, $.extend updater.count,
className: '' className: ''
textContent: 'Thread Updater' textContent: 'Thread Updater'
$.hide updater.timer updater.timer.hidden = true
autoUpdate: -> autoUpdate: ->
if @checked if @checked
updater.timeoutID = setTimeout updater.timeout, 1000 updater.timeoutID = setTimeout updater.timeout, 1000
@ -1777,13 +1773,13 @@ updater =
updater.request?.abort() updater.request?.abort()
url = location.pathname + '?' + Date.now() # fool the cache url = location.pathname + '?' + Date.now() # fool the cache
cb = updater.cb.update cb = updater.cb.update
updater.request = $.xhr url, cb updater.request = $.ajax url, cb
watcher = watcher =
init: -> init: ->
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
$.append d.body, watcher.dialog $.add d.body, watcher.dialog
#add watch buttons #add watch buttons
inputs = $$ '.op input' inputs = $$ '.op input'
@ -1816,8 +1812,8 @@ watcher =
$.bind x, 'click', watcher.cb.x $.bind x, 'click', watcher.cb.x
link = $.el 'a', props link = $.el 'a', props
$.append div, x, $.tn(' '), link $.add div, x, $.tn(' '), link
$.append watcher.dialog, div $.add watcher.dialog, div
watchedBoard = watched[g.BOARD] or {} watchedBoard = watched[g.BOARD] or {}
for favicon in $$ 'img.favicon' for favicon in $$ 'img.favicon'
@ -1884,7 +1880,7 @@ sauce =
textContent: sauce.names[i] textContent: sauce.names[i]
href: prefix + suffix href: prefix + suffix
target: '_blank' target: '_blank'
$.append span, $.tn(' '), link $.add span, $.tn(' '), link
revealSpoilers = revealSpoilers =
init: -> init: ->
@ -2006,7 +2002,7 @@ quoteBacklink =
container = $.el 'span', className: 'container' container = $.el 'span', className: 'container'
root = $('.reportbutton', el) or $('span[id^=no]', el) root = $('.reportbutton', el) or $('span[id^=no]', el)
$.after root, container $.after root, container
$.append container, $.tn(' '), link $.add container, $.tn(' '), link
quoteInline = quoteInline =
init: -> init: ->
@ -2025,7 +2021,7 @@ quoteInline =
$.removeClass @, 'inlined' $.removeClass @, 'inlined'
for inlined in $$ 'input', table for inlined in $$ 'input', table
if hidden = $.id inlined.name if hidden = $.id inlined.name
$.show $.x 'ancestor::table[1]', hidden $.x('ancestor::table[1]', hidden).hidden = false
return return
root = if @parentNode.nodeName is 'FONT' then @parentNode else if @nextSibling then @nextSibling else @ root = if @parentNode.nodeName is 'FONT' then @parentNode else if @nextSibling then @nextSibling else @
if el = $.id id if el = $.id id
@ -2033,7 +2029,7 @@ quoteInline =
if @className is 'backlink' if @className is 'backlink'
return if $("a.backlink[href='##{id}']", el) return if $("a.backlink[href='##{id}']", el)
$.after @parentNode, inline $.after @parentNode, inline
$.hide $.x 'ancestor::table[1]', el $.x('ancestor::table[1]', el).hidden = true
else else
$.after root, inline $.after root, inline
else else
@ -2090,7 +2086,7 @@ quotePreview =
qp = ui.el = $.el 'div', qp = ui.el = $.el 'div',
id: 'qp' id: 'qp'
className: 'replyhl' className: 'replyhl'
$.append d.body, qp $.add d.body, qp
id = @hash[1..] id = @hash[1..]
if el = $.id id if el = $.id id
@ -2164,7 +2160,7 @@ threadStats =
dialog.className = 'dialog' dialog.className = 'dialog'
threadStats.postcountEl = $ '#postcount', dialog threadStats.postcountEl = $ '#postcount', dialog
threadStats.imagecountEl = $ '#imagecount', dialog threadStats.imagecountEl = $ '#imagecount', dialog
$.append d.body, dialog $.add d.body, dialog
g.callbacks.push threadStats.node g.callbacks.push threadStats.node
node: (root) -> node: (root) ->
return if root.className return if root.className
@ -2274,7 +2270,7 @@ imgHover =
ui.el = $.el 'img' ui.el = $.el 'img'
id: 'iHover' id: 'iHover'
src: @parentNode.href src: @parentNode.href
$.append d.body, ui.el $.add d.body, ui.el
imgPreloading = imgPreloading =
init: -> init: ->
@ -2340,11 +2336,11 @@ imgExpand =
imgExpand.expand thumb imgExpand.expand thumb
contract: (thumb) -> contract: (thumb) ->
$.show thumb thumb.hidden = false
$.rm thumb.nextSibling $.rm thumb.nextSibling
expand: (thumb) -> expand: (thumb) ->
$.hide thumb thumb.hidden = true
a = thumb.parentNode a = thumb.parentNode
img = $.el 'img', img = $.el 'img',
src: a.href src: a.href
@ -2352,7 +2348,7 @@ imgExpand =
filesize = $ 'span.filesize', a.parentNode filesize = $ 'span.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)"
$.append a, img $.add a, img
dialog: -> dialog: ->
controls = $.el 'div', controls = $.el 'div',
@ -2447,7 +2443,7 @@ firstRun =
<p>If you don't see the buttons, try disabling your userstyles.</p> <p>If you don't see the buttons, try disabling your userstyles.</p>
</div> </div>
</div>" </div>"
$.append d.body, dialog $.add d.body, dialog
$.bind window, 'click', firstRun.close $.bind window, 'click', firstRun.close