From 944f70a64a443ad71cc234b3e7c0e8c505f1cdb9 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 22 Jul 2011 04:15:00 +0200 Subject: [PATCH] Less IO; msoueout -> mouseout. --- 4chan_x.user.js | 23 ++++++++++++++--------- script.coffee | 22 ++++++++++++++-------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index fe768f8e0..113888ce1 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1563,6 +1563,8 @@ init: function() { var autoUpT, checked, conf, dialog, html, input, interva, name, title, updNow, verbose, _i, _len, _ref; updater.interval = $.config('Interval'); + updater.ircUpd = $.config('IRC Updating'); + updater.verbose = $.config('Verbose'); html = "
-" + updater.interval + "
"; conf = config.updater.checkbox; for (name in conf) { @@ -1648,7 +1650,7 @@ arr.push(reply.parentNode.parentNode.parentNode); } updater.timer.textContent = '-' + updater.interval; - if ($.config('Verbose')) { + if (updater.verbose) { updater.count.textContent = '+' + arr.length; if (arr.length === 0) { updater.count.className = ''; @@ -1659,7 +1661,7 @@ while (reply = arr.pop()) { $.before(br, reply); } - if ($.config('IRC Updating')) { + if (updater.ircUpd) { return scrollTo(0, d.body.scrollHeight); } } @@ -1976,14 +1978,16 @@ }; quoteBacklink = { init: function() { + quoteBacklink.opbl = !$.config('OP Backlinks'); + quoteBacklink.qp = $.config('Quote Preview'); + quoteBacklink.qi = $.config('Quote Inline'); return g.callbacks.push(function(root) { - var container, el, id, link, opbl, qid, quote, quotes, _i, _len, _ref, _results; + var container, el, id, link, qid, quote, quotes, _i, _len, _ref, _results; if (/inline/.test(root.className)) { return; } id = root.id || $('td[id]', root).id; quotes = {}; - opbl = !$.config('OP Backlinks'); _ref = $$('a.quotelink', root); for (_i = 0, _len = _ref.length; _i < _len; _i++) { quote = _ref[_i]; @@ -1997,7 +2001,7 @@ if (!(el = d.getElementById(qid))) { continue; } - if (opbl && el.className === 'op') { + if (quoteBacklink.opbl && el.className === 'op') { continue; } link = $.el('a', { @@ -2005,12 +2009,12 @@ className: 'backlink', textContent: ">>" + id }); - if ($.config('Quote Preview')) { + if (quoteBacklink.qp) { $.bind(link, 'mouseover', quotePreview.mouseover); $.bind(link, 'mousemove', ui.hover); $.bind(link, 'mouseout', quotePreview.mouseout); } - if ($.config('Quote Inline')) { + if (quoteBacklink.qi) { $.bind(link, 'click', quoteInline.toggle); } if (!(container = $('.container', el))) { @@ -2129,6 +2133,7 @@ }; quotePreview = { init: function() { + quotePreview.hl = $.config('Quote Highlighting'); return g.callbacks.push(function(root) { var quote, _i, _len, _ref, _results; _ref = $$('a.quotelink, a.backlink', root); @@ -2141,7 +2146,7 @@ $.bind(quote, 'mouseover', quotePreview.mouseover); $.bind(quote, 'mousemove', ui.hover); $.bind(quote, 'mouseout', quotePreview.mouseout); - _results.push($.bind(quote, 'msoueout', ui.hoverend)); + _results.push($.bind(quote, 'mouseout', ui.hoverend)); } return _results; }); @@ -2156,7 +2161,7 @@ id = this.hash.slice(1); if (el = d.getElementById(id)) { qp.innerHTML = el.innerHTML; - if ($.config('Quote Highlighting')) { + if (quotePreview.hl) { $.addClass(el, 'qphl'); } if (/backlink/.test(this.className)) { diff --git a/script.coffee b/script.coffee index 67502882e..b7190b6b6 100644 --- a/script.coffee +++ b/script.coffee @@ -1267,6 +1267,9 @@ threadHiding = updater = init: -> updater.interval = $.config 'Interval' + updater.ircUpd = $.config 'IRC Updating' + updater.verbose = $.config 'Verbose' + html = "
-#{updater.interval}
" conf = config.updater.checkbox for name of conf @@ -1345,7 +1348,7 @@ updater = arr.push reply.parentNode.parentNode.parentNode #table updater.timer.textContent = '-' + updater.interval - if $.config 'Verbose' + if updater.verbose updater.count.textContent = '+' + arr.length if arr.length is 0 updater.count.className = '' @@ -1355,7 +1358,7 @@ updater = #XXX add replies in correct order so backlinks resolve while reply = arr.pop() $.before br, reply - if $.config 'IRC Updating' + if updater.ircUpd scrollTo 0, d.body.scrollHeight timeout: -> @@ -1560,12 +1563,14 @@ titlePost = quoteBacklink = init: -> + quoteBacklink.opbl = ! $.config 'OP Backlinks' + quoteBacklink.qp = $.config 'Quote Preview' + quoteBacklink.qi = $.config 'Quote Inline' g.callbacks.push (root) -> return if /inline/.test root.className # op or reply id = root.id or $('td[id]', root).id quotes = {} - opbl = ! $.config 'OP Backlinks' for quote in $$ 'a.quotelink', root #don't process >>>/b/ continue unless qid = quote.hash[1..] @@ -1574,16 +1579,16 @@ quoteBacklink = for qid of quotes continue unless el = d.getElementById qid #don't backlink the op - continue if opbl and el.className is 'op' + continue if quoteBacklink.opbl and el.className is 'op' link = $.el 'a', href: "##{id}" className: 'backlink' textContent: ">>#{id}" - if $.config 'Quote Preview' + if quoteBacklink.qp $.bind link, 'mouseover', quotePreview.mouseover $.bind link, 'mousemove', ui.hover $.bind link, 'mouseout', quotePreview.mouseout - if $.config 'Quote Inline' + if quoteBacklink.qi $.bind link, 'click', quoteInline.toggle unless container = $ '.container', el container = $.el 'span', className: 'container' @@ -1657,13 +1662,14 @@ quoteInline = quotePreview = init: -> + quotePreview.hl = $.config 'Quote Highlighting' g.callbacks.push (root) -> for quote in $$ 'a.quotelink, a.backlink', root continue unless quote.hash $.bind quote, 'mouseover', quotePreview.mouseover $.bind quote, 'mousemove', ui.hover $.bind quote, 'mouseout', quotePreview.mouseout - $.bind quote, 'msoueout', ui.hoverend + $.bind quote, 'mouseout', ui.hoverend mouseover: (e) -> qp = ui.el = $.el 'div', id: 'qp' @@ -1673,7 +1679,7 @@ quotePreview = id = @hash[1..] if el = d.getElementById id qp.innerHTML = el.innerHTML - $.addClass el, 'qphl' if $.config 'Quote Highlighting' + $.addClass el, 'qphl' if quotePreview.hl if /backlink/.test @className replyID = $.x('ancestor::*[@id][1]', @).id.match(/\d+/)[0] for quote in $$ 'a.quotelink', qp