mv -> $.append

This commit is contained in:
James Campos 2011-03-27 13:41:48 -07:00
parent 4a15b1158f
commit fc9e7ce8df
2 changed files with 35 additions and 39 deletions

View File

@ -56,7 +56,7 @@
*/ */
(function() { (function() {
var $, $$, DAY, a, arr, as, autoWatch, callback, changeCheckbox, changeValue, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, g, getConfig, getThread, hideReply, hideThread, href, html, i, id, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, img, inAfter, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, log, mv, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyNav, report, request, scroll, scrollThread, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, threadF, threads, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, zeroPad, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4; var $, $$, DAY, a, arr, as, autoWatch, callback, changeCheckbox, changeValue, clearHidden, closeQR, config, cooldown, cutoff, d, delform, down, editSauce, el, expand, expandComment, expandThread, g, getConfig, getThread, hideReply, hideThread, href, html, i, id, imageClick, imageExpand, imageExpandClick, imageHover, imageResize, imageThumb, imageToggle, imageType, imageTypeChange, img, inAfter, input, inputs, keyModeInsert, keyModeNormal, keydown, keypress, l1, lastChecked, log, navbotr, navtopr, nodeInserted, now, omitted, onloadComment, onloadThread, option, options, parseResponse, pathname, qr, recaptcha, recaptchaListener, recaptchaReload, redirect, replyNav, report, request, scroll, scrollThread, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, threadF, threads, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, zeroPad, _i, _j, _k, _l, _len, _len2, _len3, _len4, _len5, _len6, _len7, _m, _n, _ref, _ref2, _ref3, _ref4;
var __slice = Array.prototype.slice; var __slice = Array.prototype.slice;
if (typeof console != "undefined" && console !== null) { if (typeof console != "undefined" && console !== null) {
log = console.log; log = console.log;
@ -269,8 +269,15 @@
remove: function(el) { remove: function(el) {
return el.parentNode.removeChild(el); return el.parentNode.removeChild(el);
}, },
append: function(parent, child) { append: function() {
return parent.appendChild(child); var child, children, parent, _i, _len, _results;
parent = arguments[0], children = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
_results = [];
for (_i = 0, _len = children.length; _i < _len; _i++) {
child = children[_i];
_results.push(parent.appendChild(child));
}
return _results;
}, },
before: function(root, el) { before: function(root, el) {
return root.parentNode.insertBefore(el, root); return root.parentNode.insertBefore(el, root);
@ -344,16 +351,6 @@
} }
return _results; return _results;
}; };
mv = function() {
var child, children, parent, _i, _j, _len, _results;
children = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), parent = arguments[_i++];
_results = [];
for (_j = 0, _len = children.length; _j < _len; _j++) {
child = children[_j];
_results.push(parent.appendChild(child));
}
return _results;
};
getConfig = function(name) { getConfig = function(name) {
return GM_getValue(name, config[name][0]); return GM_getValue(name, config[name][0]);
}; };
@ -504,7 +501,7 @@
}); });
$.bind(a, 'click', showReply); $.bind(a, 'click', showReply);
div = $.el('div'); div = $.el('div');
mv(a, div); $.append(div, a);
return $.before(table, div); return $.before(table, div);
} }
}; };
@ -908,7 +905,7 @@
_results2 = []; _results2 = [];
for (_j = 0, _len2 = replies.length; _j < _len2; _j++) { for (_j = 0, _len2 = replies.length; _j < _len2; _j++) {
reply = replies[_j]; reply = replies[_j];
_results2.push(mv($.x('ancestor::table', reply), div)); _results2.push($.append(div, $.x('ancestor::table', reply)));
} }
return _results2; return _results2;
} }
@ -948,7 +945,7 @@
$('a.sauce', div).addEventListener('click', editSauce, true); $('a.sauce', div).addEventListener('click', editSauce, true);
$('textarea', div).addEventListener('change', changeValue, true); $('textarea', div).addEventListener('change', changeValue, true);
$('input[type="button"]', div).addEventListener('click', clearHidden, true); $('input[type="button"]', div).addEventListener('click', clearHidden, true);
return mv(div, d.body); return $.append(d.body, div);
}; };
parseResponse = function(responseText) { parseResponse = function(responseText) {
var body, opbq, replies; var body, opbq, replies;
@ -1277,13 +1274,13 @@
className: 'pointer' className: 'pointer'
}); });
$.bind(a, 'click', hideThread); $.bind(a, 'click', hideThread);
mv(a, div); $.append(div, a);
$.before(current, div); $.before(current, div);
while (!current.clear) { while (!current.clear) {
mv(current, div); $.append(div, current);
current = div.nextSibling; current = div.nextSibling;
} }
mv(current, div); $.append(div, current);
current = div.nextSibling; current = div.nextSibling;
id = $('input[value="delete"]', div).name; id = $('input[value="delete"]', div).name;
div.id = id; div.id = id;
@ -1516,7 +1513,7 @@
textContent: thread.text, textContent: thread.text,
href: "/" + board + "/res/" + thread.id href: "/" + board + "/res/" + thread.id
}); });
mv(a, $.tn(' '), link, $.el('br'), div); $.append(div, a, $.tn(' '), link, $.el('br'));
} }
} }
old = $('#watcher div:last-child'); old = $('#watcher div:last-child');
@ -1806,7 +1803,7 @@
textContent: names[i], textContent: names[i],
href: prefixes[i] + suffix href: prefixes[i] + suffix
}); });
mv($.tn(' '), link, span); $.append(span, $.tn(' '), link);
_results.push(i++); _results.push(i++);
} }
return _results; return _results;
@ -1871,7 +1868,7 @@
top: '50px', top: '50px',
left: '0px' left: '0px'
}, html); }, html);
mv(watcher, d.body); $.append(d.body, watcher);
watcherUpdate(); watcherUpdate();
threads = g.watched[g.BOARD] || []; threads = g.watched[g.BOARD] || [];
inputs = $$('form > input[value="delete"], div > input[value="delete"]'); inputs = $$('form > input[value="delete"], div > input[value="delete"]');
@ -1931,7 +1928,7 @@
className: 'pointer' className: 'pointer'
}); });
$.bind(down, 'click', replyNav); $.bind(down, 'click', replyNav);
mv($.tn(' '), up, $.tn(' '), down, span); $.append(span, $.tn(' '), up, $.tn(' '), down);
_results.push(inAfter(el, span)); _results.push(inAfter(el, span));
} }
return _results; return _results;
@ -2030,7 +2027,7 @@
textContent: textContent, textContent: textContent,
href: href href: href
}); });
mv(up, $.tn(' '), down, span); $.append(span, up, $.tn(' '), down);
$.before(el, span); $.before(el, span);
} }
if (location.hash === '#p0') { if (location.hash === '#p0') {

View File

@ -162,8 +162,9 @@ $.extend $,
el.className = el.className.replace ' ' + className, '' el.className = el.className.replace ' ' + className, ''
remove: (el) -> remove: (el) ->
el.parentNode.removeChild el el.parentNode.removeChild el
append: (parent, child) -> append: (parent, children...) ->
parent.appendChild child for child in children
parent.appendChild child
before: (root, el) -> before: (root, el) ->
root.parentNode.insertBefore el, root root.parentNode.insertBefore el, root
el: (tag, properties) -> el: (tag, properties) ->
@ -227,8 +228,6 @@ $.extend $,
$$ = (selector, root=d.body) -> $$ = (selector, root=d.body) ->
result = root.querySelectorAll selector result = root.querySelectorAll selector
node for node in result node for node in result
mv = (children..., parent) ->
(parent.appendChild child) for child in children
getConfig = (name) -> getConfig = (name) ->
GM_getValue name, config[name][0] GM_getValue name, config[name][0]
inAfter = (root, el) -> inAfter = (root, el) ->
@ -353,7 +352,7 @@ hideReply = (reply) ->
className: 'pointer' className: 'pointer'
$.bind a, 'click', showReply $.bind a, 'click', showReply
div = $.el 'div' div = $.el 'div'
mv a, div $.append div, a
$.before table, div $.before table, div
hideThread = (div) -> hideThread = (div) ->
@ -668,7 +667,7 @@ onloadThread = (responseText, span) ->
else#threading else#threading
div = span.parentNode div = span.parentNode
for reply in replies for reply in replies
mv $.x('ancestor::table', reply), div $.append div, $.x('ancestor::table', reply)
changeCheckbox = -> changeCheckbox = ->
GM_setValue @name, @checked GM_setValue @name, @checked
@ -701,7 +700,7 @@ options = ->
$('a.sauce', div).addEventListener 'click', editSauce, true $('a.sauce', div).addEventListener 'click', editSauce, true
$('textarea', div).addEventListener 'change', changeValue, true $('textarea', div).addEventListener 'change', changeValue, true
$('input[type="button"]', div).addEventListener 'click', clearHidden, true $('input[type="button"]', div).addEventListener 'click', clearHidden, true
mv div, d.body $.append d.body, div
parseResponse = (responseText) -> parseResponse = (responseText) ->
body = $.el 'body', body = $.el 'body',
@ -953,12 +952,12 @@ threadF = (current) ->
textContent: '[ - ]' textContent: '[ - ]'
className: 'pointer' className: 'pointer'
$.bind a, 'click', hideThread $.bind a, 'click', hideThread
mv a, div $.append div, a
$.before current, div $.before current, div
while (!current.clear)#<br clear> while (!current.clear)#<br clear>
mv current, div $.append div, current
current = div.nextSibling current = div.nextSibling
mv current, div $.append div, current
current = div.nextSibling current = div.nextSibling
id = $('input[value="delete"]', div).name id = $('input[value="delete"]', div).name
div.id = id div.id = id
@ -1154,7 +1153,7 @@ watcherUpdate = ->
link = $.el 'a', link = $.el 'a',
textContent: thread.text textContent: thread.text
href: "/#{board}/res/#{thread.id}" href: "/#{board}/res/#{thread.id}"
mv a, $.tn(' '), link, $.el('br'), div $.append div, a, $.tn(' '), link, $.el('br')
old = $('#watcher div:last-child') old = $('#watcher div:last-child')
$.replace(old, div) $.replace(old, div)
@ -1409,7 +1408,7 @@ if getConfig 'Sauce'
link = $.el 'a', link = $.el 'a',
textContent: names[i] textContent: names[i]
href: prefixes[i] + suffix href: prefixes[i] + suffix
mv $.tn(' '), link, span $.append span, $.tn(' '), link
i++ i++
if getConfig 'Reply Hiding' if getConfig 'Reply Hiding'
@ -1446,7 +1445,7 @@ if getConfig 'Thread Watcher'
#create watcher #create watcher
html = '<div class="move">Thread Watcher</div><div></div>' html = '<div class="move">Thread Watcher</div><div></div>'
watcher = ui.dialog 'watcher', top: '50px', left: '0px', html watcher = ui.dialog 'watcher', top: '50px', left: '0px', html
mv watcher, d.body $.append d.body, watcher
watcherUpdate() watcherUpdate()
#add buttons #add buttons
@ -1492,7 +1491,7 @@ if getConfig 'Reply Navigation'
textContent: '' textContent: ''
className: 'pointer' className: 'pointer'
$.bind down, 'click', replyNav $.bind down, 'click', replyNav
mv $.tn(' '), up, $.tn(' '), down, span $.append span, $.tn(' '), up, $.tn(' '), down
inAfter el, span inAfter el, span
if getConfig 'Keybinds' if getConfig 'Keybinds'
@ -1566,7 +1565,7 @@ else #not reply
className: 'pointer' className: 'pointer'
textContent: textContent textContent: textContent
href: href href: href
mv up, $.tn(' '), down, span $.append span, up, $.tn(' '), down
$.before el, span $.before el, span
if location.hash is '#p0' if location.hash is '#p0'
window.location = window.location window.location = window.location