Tiny improvements: use classList, simpler selectors, simpler xpath.

This commit is contained in:
Nicolas Stepien 2011-10-11 15:15:28 +02:00
parent 2e43059f3e
commit 0828f8ed3f
2 changed files with 10 additions and 10 deletions

View File

@ -2316,10 +2316,10 @@
quoteBacklink.funk = Function('id', "return'" + format + "'");
return g.callbacks.push(function(root) {
var container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results;
if (/inline/.test(root.className)) {
if (root.classList.contains('inline')) {
return;
}
id = root.id || $('td[id]', root).id;
id = $('input', root).name;
quotes = {};
_ref = $$('.quotelink', root);
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
@ -2354,7 +2354,7 @@
container = $.el('span', {
className: 'container'
});
root = $('.reportbutton', el) || $('span[id^=no]', el);
root = $('.reportbutton', el) || $('span[id]', el);
$.after(root, container);
}
_results.push($.add(container, $.tn(' '), link));
@ -2516,8 +2516,8 @@
if (conf['Quote Highlighting']) {
$.addClass(el, 'qphl');
}
if (/backlink/.test(this.className)) {
replyID = $.x('ancestor::*[@id][1]', this).id.match(/\d+/)[0];
if (this.classList.contains('backlink')) {
replyID = $.x('preceding::input', this).name;
_ref = $$('.quotelink', qp);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {

View File

@ -1739,9 +1739,9 @@ quoteBacklink =
format = conf['backlink'].replace /%id/, "' + id + '"
quoteBacklink.funk = Function 'id', "return'#{format}'"
g.callbacks.push (root) ->
return if /inline/.test root.className
return if root.classList.contains 'inline'
# op or reply
id = root.id or $('td[id]', root).id
id = $('input', root).name
quotes = {}
for quote in $$ '.quotelink', root
#don't process >>>/b/
@ -1764,7 +1764,7 @@ quoteBacklink =
$.bind link, 'click', quoteInline.toggle
unless (container = $ '.container', el) and container.parentNode is el
container = $.el 'span', className: 'container'
root = $('.reportbutton', el) or $('span[id^=no]', el)
root = $('.reportbutton', el) or $('span[id]', el)
$.after root, container
$.add container, $.tn(' '), link
@ -1866,8 +1866,8 @@ quotePreview =
if el = $.id id
qp.innerHTML = el.innerHTML
$.addClass el, 'qphl' if conf['Quote Highlighting']
if /backlink/.test @className
replyID = $.x('ancestor::*[@id][1]', @).id.match(/\d+/)[0]
if @classList.contains 'backlink'
replyID = $.x('preceding::input', @).name
for quote in $$ '.quotelink', qp
if quote.hash[1..] is replyID
quote.className = 'forwardlink'