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

View File

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