minor cleanup

change from `make` to `n`, drop explicit parens
This commit is contained in:
James Campos 2010-08-25 10:37:04 -07:00
parent 3a331f1547
commit cdd59b046e
2 changed files with 27 additions and 29 deletions

View File

@ -48,12 +48,10 @@ replace = (root, el) ->
root.parentNode.replaceChild(el, root) root.parentNode.replaceChild(el, root)
getTime = -> getTime = ->
Math.floor(new Date().getTime() / 1000) Math.floor(new Date().getTime() / 1000)
make = (tag, obj) -> n = (tag, props) -> #new
el = document.createElement(tag) el = document.createElement tag
if obj if props then (el[key] = val) for key, val of props
for key of obj el
el[key] = obj[key]
return el
slice = (arr, id) -> slice = (arr, id) ->
# the while loop is the only low-level loop left in coffeescript. # the while loop is the only low-level loop left in coffeescript.
# we need to use it to see the index. # we need to use it to see the index.
@ -431,7 +429,7 @@ submit = (e) ->
recaptcha = $('#recaptcha_response_field', this) recaptcha = $('#recaptcha_response_field', this)
if not recaptcha.value if not recaptcha.value
e.preventDefault() e.preventDefault()
span = make 'span', { span = n 'span', {
className: 'error' className: 'error'
textContent: 'You forgot to type in the verification.' textContent: 'You forgot to type in the verification.'
} }
@ -465,19 +463,19 @@ quickReply = (e) ->
div.addEventListener('mousedown', mousedown, true) div.addEventListener('mousedown', mousedown, true)
qr.appendChild(div) qr.appendChild(div)
minimizeB = make('a', { minimizeB = n 'a', {
textContent: '_' textContent: '_'
className: 'pointer' className: 'pointer'
title: 'minimize' title: 'minimize'
}) }
minimizeB.addEventListener('click', minimize, true) minimizeB.addEventListener('click', minimize, true)
div.appendChild(minimizeB) div.appendChild(minimizeB)
div.appendChild(document.createTextNode(' ')) div.appendChild(document.createTextNode(' '))
closeB = make('a', { closeB = n 'a', {
textContent: 'X' textContent: 'X'
className: 'pointer' className: 'pointer'
title: 'close' title: 'close'
}) }
closeB.addEventListener('click', close, true) closeB.addEventListener('click', close, true)
div.appendChild(closeB) div.appendChild(closeB)
@ -491,7 +489,7 @@ quickReply = (e) ->
clone.target = 'iframe' clone.target = 'iframe'
if not REPLY if not REPLY
xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]' xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]'
input = make 'input', { input = n 'input', {
value: x(xpath, this).name value: x(xpath, this).name
type: 'hidden' type: 'hidden'
name: 'resto' name: 'resto'
@ -561,9 +559,9 @@ watcherUpdate = ->
parseResponse = (responseText) -> parseResponse = (responseText) ->
body = make('body', { body = n 'body', {
innerHTML: responseText innerHTML: responseText
}) }
replies = $$('td.reply', body) replies = $$('td.reply', body)
opbq = $('blockquote', body) opbq = $('blockquote', body)
return [replies, opbq] return [replies, opbq]

View File

@ -1,5 +1,5 @@
(function() { (function() {
var $, $$, BOARD, DAY, PAGENUM, REPLY, _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, a, arr, as, autoWatch, b, board, callback, callbacks, clearHidden, close, config, cutoff, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getTime, getValue, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, make, minimize, mousedown, mousemove, mouseup, move, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, position, quickReply, r, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, submit, tag, text, thread, threadF, threads, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs; var $, $$, BOARD, DAY, PAGENUM, REPLY, _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, a, arr, as, autoWatch, b, board, callback, callbacks, clearHidden, close, config, cutoff, delform, down, el, expandComment, expandThread, favEmpty, favNormal, favicon, getTime, getValue, head, hiddenReplies, hiddenThreads, hide, hideReply, hideThread, html, i, i1, id, iframe, iframeLoad, iframeLoop, img, inAfter, inBefore, input, inputs, l, l1, lastChecked, magic, minimize, mousedown, mousemove, mouseup, move, n, nodeInserted, nop, now, omitted, onloadComment, onloadThread, options, optionsSave, parseResponse, position, quickReply, r, remove, replace, replyNav, report, show, showReply, showThread, slice, span, stopPropagation, submit, tag, text, thread, threadF, threads, up, watch, watchX, watched, watcher, watcherUpdate, x, xhrs;
var __hasProp = Object.prototype.hasOwnProperty; var __hasProp = Object.prototype.hasOwnProperty;
config = { config = {
'Thread Hiding': true, 'Thread Hiding': true,
@ -61,15 +61,15 @@
getTime = function() { getTime = function() {
return Math.floor(new Date().getTime() / 1000); return Math.floor(new Date().getTime() / 1000);
}; };
make = function(tag, obj) { n = function(tag, props) {
var _a, _b, el, key; var _a, el, key, val;
el = document.createElement(tag); el = document.createElement(tag);
if (obj) { if (props) {
_b = obj; _a = props;
for (key in _b) { for (key in _a) {
if (!__hasProp.call(_b, key)) continue; if (!__hasProp.call(_a, key)) continue;
_a = _b[key]; val = _a[key];
el[key] = obj[key]; (el[key] = val);
} }
} }
return el; return el;
@ -340,7 +340,7 @@
return GM_setValue("hiddenThreads/" + (BOARD) + "/", JSON.stringify(hiddenThreads)); return GM_setValue("hiddenThreads/" + (BOARD) + "/", JSON.stringify(hiddenThreads));
}; };
hideThread = function(div) { hideThread = function(div) {
var _c, a, n, name, p, span, text, trip; var _c, a, name, p, span, text, trip;
if (p = this.parentNode) { if (p = this.parentNode) {
div = p; div = p;
hiddenThreads.push({ hiddenThreads.push({
@ -470,7 +470,7 @@
recaptcha = $('#recaptcha_response_field', this); recaptcha = $('#recaptcha_response_field', this);
if (!recaptcha.value) { if (!recaptcha.value) {
e.preventDefault(); e.preventDefault();
span = make('span', { span = n('span', {
className: 'error', className: 'error',
textContent: 'You forgot to type in the verification.' textContent: 'You forgot to type in the verification.'
}); });
@ -499,7 +499,7 @@
div.className = 'move'; div.className = 'move';
div.addEventListener('mousedown', mousedown, true); div.addEventListener('mousedown', mousedown, true);
qr.appendChild(div); qr.appendChild(div);
minimizeB = make('a', { minimizeB = n('a', {
textContent: '_', textContent: '_',
className: 'pointer', className: 'pointer',
title: 'minimize' title: 'minimize'
@ -507,7 +507,7 @@
minimizeB.addEventListener('click', minimize, true); minimizeB.addEventListener('click', minimize, true);
div.appendChild(minimizeB); div.appendChild(minimizeB);
div.appendChild(document.createTextNode(' ')); div.appendChild(document.createTextNode(' '));
closeB = make('a', { closeB = n('a', {
textContent: 'X', textContent: 'X',
className: 'pointer', className: 'pointer',
title: 'close' title: 'close'
@ -527,7 +527,7 @@
clone.target = 'iframe'; clone.target = 'iframe';
if (!REPLY) { if (!REPLY) {
xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]'; xpath = 'preceding::span[@class="postername"][1]/preceding::input[1]';
input = make('input', { input = n('input', {
value: x(xpath, this).name, value: x(xpath, this).name,
type: 'hidden', type: 'hidden',
name: 'resto' name: 'resto'
@ -605,7 +605,7 @@
}; };
parseResponse = function(responseText) { parseResponse = function(responseText) {
var body, opbq, replies; var body, opbq, replies;
body = make('body', { body = n('body', {
innerHTML: responseText innerHTML: responseText
}); });
replies = $$('td.reply', body); replies = $$('td.reply', body);