replace -> $.replace

This commit is contained in:
James Campos 2011-03-27 13:18:52 -07:00
parent 7894495e3e
commit 22c2ab3eae
2 changed files with 18 additions and 18 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, getTime, 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, replace, replyNav, report, request, scroll, scrollThread, showReply, showThread, slice, span, src, start, stopPropagation, temp, text, textContent, threadF, threads, tn, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, x, 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, getTime, 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, tn, tzOffset, ui, up, updateAuto, updateCallback, updateFavicon, updateInterval, updateNow, updateTime, updateTitle, updateVerbose, updaterMake, watch, watchX, watcher, watcherUpdate, x, 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;
@ -242,6 +242,9 @@
return object; return object;
}; };
$.extend($, { $.extend($, {
replace: function(root, el) {
return root.parentNode.replaceChild(el, root);
},
hide: function(el) { hide: function(el) {
return el.style.display = 'none'; return el.style.display = 'none';
}, },
@ -351,9 +354,6 @@
inAfter = function(root, el) { inAfter = function(root, el) {
return root.parentNode.insertBefore(el, root.nextSibling); return root.parentNode.insertBefore(el, root.nextSibling);
}; };
replace = function(root, el) {
return root.parentNode.replaceChild(el, root);
};
slice = function(arr, id) { slice = function(arr, id) {
var i, l, _results; var i, l, _results;
i = 0; i = 0;
@ -1379,7 +1379,7 @@
favicon = $('link[rel="shortcut icon"]', d); favicon = $('link[rel="shortcut icon"]', d);
clone = favicon.cloneNode(true); clone = favicon.cloneNode(true);
clone.href = href; clone.href = href;
return replace(favicon, clone); return $.replace(favicon, clone);
}; };
updateTime = function() { updateTime = function() {
var count, span, time; var count, span, time;
@ -1523,7 +1523,7 @@
} }
} }
old = $('#watcher div:last-child'); old = $('#watcher div:last-child');
return replace(old, div); return $.replace(old, div);
}; };
watchX = function() { watchX = function() {
var board, favicon, id, input, _, _ref; var board, favicon, id, input, _, _ref;
@ -1675,14 +1675,14 @@
className: 'pointer' className: 'pointer'
}); });
$.bind(a, 'click', options); $.bind(a, 'click', options);
replace(navtopr, a); $.replace(navtopr, a);
navbotr = $('#navbotr a'); navbotr = $('#navbotr a');
a = $.el('a', { a = $.el('a', {
textContent: '4chan X', textContent: '4chan X',
className: 'pointer' className: 'pointer'
}); });
$.bind(a, 'click', options); $.bind(a, 'click', options);
replace(navbotr, a); $.replace(navbotr, a);
} else if (getConfig('404 Redirect') && d.title === '4chan - 404') { } else if (getConfig('404 Redirect') && d.title === '4chan - 404') {
redirect(); redirect();
} else { } else {
@ -1830,7 +1830,7 @@
className: 'pointer' className: 'pointer'
}); });
$.bind(a, 'click', hideReply); $.bind(a, 'click', hideReply);
replace(td.firstChild, a); $.replace(td.firstChild, a);
next = td.nextSibling; next = td.nextSibling;
id = next.id; id = next.id;
_results.push((function() { _results.push((function() {
@ -2049,7 +2049,7 @@
textContent: "+ " + span.textContent textContent: "+ " + span.textContent
}); });
$.bind(a, 'click', expandThread); $.bind(a, 'click', expandThread);
replace(span, a); $.replace(span, a);
} }
} }
if (getConfig('Comment Expansion')) { if (getConfig('Comment Expansion')) {

View File

@ -145,6 +145,8 @@ $.extend = (object, properties) ->
object object
$.extend $, $.extend $,
replace: (root, el) ->
root.parentNode.replaceChild el, root
hide: (el) -> hide: (el) ->
el.style.display = 'none' el.style.display = 'none'
show: (el) -> show: (el) ->
@ -228,8 +230,6 @@ getTime = ->
Math.floor(new Date().getTime() / 1000) Math.floor(new Date().getTime() / 1000)
inAfter = (root, el) -> inAfter = (root, el) ->
root.parentNode.insertBefore el, root.nextSibling root.parentNode.insertBefore el, root.nextSibling
replace = (root, el) ->
root.parentNode.replaceChild el, root
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.
@ -1037,7 +1037,7 @@ updateFavicon = ->
favicon = $ 'link[rel="shortcut icon"]', d favicon = $ 'link[rel="shortcut icon"]', d
clone = favicon.cloneNode true clone = favicon.cloneNode true
clone.href = href clone.href = href
replace favicon, clone $.replace favicon, clone
updateTime = -> updateTime = ->
span = $ '#updater #timer' span = $ '#updater #timer'
@ -1158,7 +1158,7 @@ watcherUpdate = ->
href: "/#{board}/res/#{thread.id}" href: "/#{board}/res/#{thread.id}"
mv a, tn(' '), link, $.el('br'), div mv a, tn(' '), link, $.el('br'), div
old = $('#watcher div:last-child') old = $('#watcher div:last-child')
replace(old, div) $.replace(old, div)
watchX = -> watchX = ->
[board, _, id] = @nextElementSibling. [board, _, id] = @nextElementSibling.
@ -1311,13 +1311,13 @@ if navtopr = $ '#navtopr a'
textContent: '4chan X' textContent: '4chan X'
className: 'pointer' className: 'pointer'
$.bind a, 'click', options $.bind a, 'click', options
replace navtopr, a $.replace navtopr, a
navbotr = $ '#navbotr a' navbotr = $ '#navbotr a'
a = $.el 'a', a = $.el 'a',
textContent: '4chan X' textContent: '4chan X'
className: 'pointer' className: 'pointer'
$.bind a, 'click', options $.bind a, 'click', options
replace navbotr, a $.replace navbotr, a
else if getConfig('404 Redirect') and d.title is '4chan - 404' else if getConfig('404 Redirect') and d.title is '4chan - 404'
redirect() redirect()
else else
@ -1422,7 +1422,7 @@ if getConfig 'Reply Hiding'
textContent: '[ - ]' textContent: '[ - ]'
className: 'pointer' className: 'pointer'
$.bind a, 'click', hideReply $.bind a, 'click', hideReply
replace(td.firstChild, a) $.replace(td.firstChild, a)
next = td.nextSibling next = td.nextSibling
id = next.id id = next.id
@ -1580,7 +1580,7 @@ else #not reply
className: 'pointer omittedposts' className: 'pointer omittedposts'
textContent: "+ #{span.textContent}" textContent: "+ #{span.textContent}"
$.bind a, 'click', expandThread $.bind a, 'click', expandThread
replace(span, a) $.replace(span, a)
if getConfig 'Comment Expansion' if getConfig 'Comment Expansion'
as = $$('span.abbr a') as = $$('span.abbr a')