d.getElementById -> $.id

This commit is contained in:
James Campos 2011-07-31 16:33:48 -07:00
parent 8bc50c1b77
commit 0775acbba3
2 changed files with 19 additions and 14 deletions

View File

@ -292,6 +292,9 @@
return object; return object;
}; };
$.extend($, { $.extend($, {
id: function(id) {
return d.getElementById(id);
},
globalEval: function(code) { globalEval: function(code) {
var script; var script;
script = $.el('script', { script = $.el('script', {
@ -614,7 +617,7 @@
_results = []; _results = [];
for (_i = 0, _len = _ref2.length; _i < _len; _i++) { for (_i = 0, _len = _ref2.length; _i < _len; _i++) {
backlink = _ref2[_i]; backlink = _ref2[_i];
_results.push(!d.getElementById(backlink.hash.slice(1)) ? $.rm(backlink) : void 0); _results.push(!$.id(backlink.hash.slice(1)) ? $.rm(backlink) : void 0);
} }
return _results; return _results;
} }
@ -1287,7 +1290,7 @@
watcher.watch(null, g.THREAD_ID); watcher.watch(null, g.THREAD_ID);
} else { } else {
id = $('input[name=resto]', qr.el).value; id = $('input[name=resto]', qr.el).value;
op = d.getElementById(id); op = $.id(id);
if ($('img.favicon', op).src === Favicon.empty) { if ($('img.favicon', op).src === Favicon.empty) {
watcher.watch(op, id); watcher.watch(op, id);
} }
@ -1997,7 +2000,7 @@
} }
_results = []; _results = [];
for (qid in quotes) { for (qid in quotes) {
if (!(el = d.getElementById(qid))) { if (!(el = $.id(qid))) {
continue; continue;
} }
if (!conf['OP Backlinks'] && el.className === 'op') { if (!conf['OP Backlinks'] && el.className === 'op') {
@ -2072,14 +2075,14 @@
_ref = $$('input', table); _ref = $$('input', table);
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 = d.getElementById(inlined.name)) { if (hidden = $.id(inlined.name)) {
$.show($.x('ancestor::table[1]', hidden)); $.show($.x('ancestor::table[1]', hidden));
} }
} }
return; return;
} }
root = this.parentNode.nodeName === 'FONT' ? this.parentNode : this.nextSibling ? this.nextSibling : this; root = this.parentNode.nodeName === 'FONT' ? this.parentNode : this.nextSibling ? this.nextSibling : this;
if (el = d.getElementById(id)) { if (el = $.id(id)) {
inline = quoteInline.table(id, el.innerHTML); inline = quoteInline.table(id, el.innerHTML);
if (this.className === 'backlink') { if (this.className === 'backlink') {
if ($("a.backlink[href='#" + id + "']", el)) { if ($("a.backlink[href='#" + id + "']", el)) {
@ -2175,7 +2178,7 @@
}); });
$.append(d.body, qp); $.append(d.body, qp);
id = this.hash.slice(1); id = this.hash.slice(1);
if (el = d.getElementById(id)) { if (el = $.id(id)) {
qp.innerHTML = el.innerHTML; qp.innerHTML = el.innerHTML;
if (conf['Quote Highlighting']) { if (conf['Quote Highlighting']) {
$.addClass(el, 'qphl'); $.addClass(el, 'qphl');
@ -2200,7 +2203,7 @@
}, },
mouseout: function() { mouseout: function() {
var el; var el;
if (el = d.getElementById(this.hash.slice(1))) { if (el = $.id(this.hash.slice(1))) {
$.removeClass(el, 'qphl'); $.removeClass(el, 'qphl');
} }
return ui.hoverend(); return ui.hoverend();

View File

@ -200,6 +200,8 @@ $.extend = (object, properties) ->
object object
$.extend $, $.extend $,
id: (id) ->
d.getElementById id
globalEval: (code) -> globalEval: (code) ->
script = $.el 'script', script = $.el 'script',
textContent: "(#{code})()" textContent: "(#{code})()"
@ -430,7 +432,7 @@ expandThread =
while (prev = table.previousSibling) and (prev.nodeName is 'TABLE') while (prev = table.previousSibling) and (prev.nodeName is 'TABLE')
$.rm prev $.rm prev
for backlink in $$ '.op a.backlink' for backlink in $$ '.op a.backlink'
$.rm backlink if !d.getElementById backlink.hash[1..] $.rm backlink if !$.id backlink.hash[1..]
parse: (req, pathname, thread, a) -> parse: (req, pathname, thread, a) ->
@ -1008,7 +1010,7 @@ qr =
watcher.watch null, g.THREAD_ID watcher.watch null, g.THREAD_ID
else else
id = $('input[name=resto]', qr.el).value id = $('input[name=resto]', qr.el).value
op = d.getElementById id op = $.id id
if $('img.favicon', op).src is Favicon.empty if $('img.favicon', op).src is Favicon.empty
watcher.watch op, id watcher.watch op, id
@ -1565,7 +1567,7 @@ quoteBacklink =
#duplicate quotes get overwritten #duplicate quotes get overwritten
quotes[qid] = quote quotes[qid] = quote
for qid of quotes for qid of quotes
continue unless el = d.getElementById qid continue unless el = $.id qid
#don't backlink the op #don't backlink the op
continue if !conf['OP Backlinks'] and el.className is 'op' continue if !conf['OP Backlinks'] and el.className is 'op'
link = $.el 'a', link = $.el 'a',
@ -1613,11 +1615,11 @@ quoteInline =
$.rm table $.rm table
$.removeClass @, 'inlined' $.removeClass @, 'inlined'
for inlined in $$ 'input', table for inlined in $$ 'input', table
if hidden = d.getElementById inlined.name if hidden = $.id inlined.name
$.show $.x 'ancestor::table[1]', hidden $.show $.x 'ancestor::table[1]', hidden
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 = d.getElementById id if el = $.id id
inline = quoteInline.table id, el.innerHTML inline = quoteInline.table id, el.innerHTML
if @className is 'backlink' if @className is 'backlink'
return if $("a.backlink[href='##{id}']", el) return if $("a.backlink[href='##{id}']", el)
@ -1679,7 +1681,7 @@ quotePreview =
$.append d.body, qp $.append d.body, qp
id = @hash[1..] id = @hash[1..]
if el = d.getElementById id if el = $.id id
qp.innerHTML = el.innerHTML qp.innerHTML = el.innerHTML
$.addClass el, 'qphl' if conf['Quote Highlighting'] $.addClass el, 'qphl' if conf['Quote Highlighting']
if /backlink/.test @className if /backlink/.test @className
@ -1692,7 +1694,7 @@ quotePreview =
threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id threadID = @pathname.split('/').pop() or $.x('ancestor::div[@class="thread"]/div', @).id
$.cache @pathname, (-> quotePreview.parse @, id, threadID) $.cache @pathname, (-> quotePreview.parse @, id, threadID)
mouseout: -> mouseout: ->
$.removeClass el, 'qphl' if el = d.getElementById @hash[1..] $.removeClass el, 'qphl' if el = $.id @hash[1..]
ui.hoverend() ui.hoverend()
parse: (req, id, threadID) -> parse: (req, id, threadID) ->
return unless (qp = ui.el) and (qp.innerHTML is "Loading #{id}...") return unless (qp = ui.el) and (qp.innerHTML is "Loading #{id}...")