From b6ed1fbf0f731e8d8140d09831f3245f495e2b73 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Sun, 24 Jul 2011 07:40:23 +0200 Subject: [PATCH] Use conf, shave two lines, ircScroll -> scroll --- 4chan_x.user.js | 15 +++++++-------- script.coffee | 10 ++++------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index c4e40a48b..8703e2f78 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1593,7 +1593,9 @@ updater.cb.autoUpdate.call(input); } } else if (input.name === 'Interval') { - $.bind(input, 'change', updater.cb.interval); + $.bind(input, 'change', function() { + return conf['Interval'] = this.value = parseInt(this.value) || conf['Interval']; + }); $.bind(input, 'change', $.cb.value); } else if (input.type === 'button') { $.bind(input, 'click', updater.updateNow); @@ -1615,17 +1617,14 @@ } }, autoUpdate: function() { - if (this.checked) { + if (conf['Auto Update This']) { return updater.intervalID = window.setInterval(updater.timeout, 1000); } else { return window.clearInterval(updater.intervalID); } }, - interval: function() { - return conf['Interval'] = this.value = parseInt(this.value) || conf['Interval']; - }, update: function() { - var arr, body, br, id, input, ircScroll, replies, reply, _i, _len, _ref, _ref2; + var arr, body, br, id, input, replies, reply, scroll, _i, _len, _ref, _ref2; if (this.status === 404) { updater.timer.textContent = ''; updater.count.textContent = 404; @@ -1652,7 +1651,7 @@ while ((reply = replies.pop()) && (reply.id > id)) { arr.push(reply.parentNode.parentNode.parentNode); } - ircScroll = conf['Scrolling'] && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20); + scroll = conf['Scrolling'] && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20); updater.timer.textContent = '-' + conf['Interval']; if (conf['Verbose']) { updater.count.textContent = '+' + arr.length; @@ -1665,7 +1664,7 @@ while (reply = arr.pop()) { $.before(br, reply); } - if (ircScroll) { + if (scroll) { return scrollTo(0, d.body.scrollHeight); } } diff --git a/script.coffee b/script.coffee index ed082509e..7d2dcdc11 100644 --- a/script.coffee +++ b/script.coffee @@ -1297,7 +1297,7 @@ updater = $.bind input, 'click', updater.cb.autoUpdate updater.cb.autoUpdate.call input else if input.name is 'Interval' - $.bind input, 'change', updater.cb.interval + $.bind input, 'change', -> conf['Interval'] = @value = parseInt(@value) or conf['Interval'] $.bind input, 'change', $.cb.value else if input.type is 'button' $.bind input, 'click', updater.updateNow @@ -1315,12 +1315,10 @@ updater = textContent: 'Thread Updater' $.hide updater.timer autoUpdate: -> - if @checked + if conf['Auto Update This'] updater.intervalID = window.setInterval updater.timeout, 1000 else window.clearInterval updater.intervalID - interval: -> - conf['Interval'] = @value = parseInt(@value) or conf['Interval'] update: -> if @status is 404 updater.timer.textContent = '' @@ -1345,7 +1343,7 @@ updater = while (reply = replies.pop()) and (reply.id > id) arr.push reply.parentNode.parentNode.parentNode #table - ircScroll = conf['Scrolling'] && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20) + scroll = conf['Scrolling'] && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20) updater.timer.textContent = '-' + conf['Interval'] if conf['Verbose'] @@ -1358,7 +1356,7 @@ updater = #XXX add replies in correct order so backlinks resolve while reply = arr.pop() $.before br, reply - if ircScroll + if scroll scrollTo 0, d.body.scrollHeight timeout: ->