diff --git a/4chan_x.user.js b/4chan_x.user.js index fc30af38b..2238bd7e9 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -935,7 +935,7 @@ nav.prev(); break; case conf.update: - updater.updateNow(); + updater.update(); break; case conf.watch: watcher.toggle(thread); @@ -1951,7 +1951,7 @@ }); $.bind(input, 'change', $.cb.value); } else if (input.type === 'button') { - $.bind(input, 'click', updater.updateNow); + $.bind(input, 'click', updater.update); } } return $.add(d.body, dialog); @@ -2023,25 +2023,24 @@ }, timeout: function() { var n; - n = Number(updater.timer.textContent); - ++n; - if (n === 10) { - updater.count.textContent = 'retry'; - updater.count.className = ''; - n = 0; - } - updater.timer.textContent = n; + updater.timeoutID = setTimeout(updater.timeout, 1000); + n = 1 + Number(updater.timer.textContent); if (n === 0) { - updater.update(); + return updater.update(); + } else if (n === 10) { + return updater.retry(); + } else { + return updater.timer.textContent = n; } - return updater.timeoutID = setTimeout(updater.timeout, 1000); }, - updateNow: function() { - updater.timer.textContent = 0; + retry: function() { + updater.count.textContent = 'retry'; + updater.count.className = ''; return updater.update(); }, update: function() { var cb, url, _ref; + updater.timer.textContent = 0; if ((_ref = updater.request) != null) { _ref.abort(); } diff --git a/script.coffee b/script.coffee index 0bee99690..6ec3bde6e 100644 --- a/script.coffee +++ b/script.coffee @@ -663,7 +663,7 @@ keybinds = when conf.previousThread nav.prev() when conf.update - updater.updateNow() + updater.update() when conf.watch watcher.toggle thread when conf.hide @@ -1465,7 +1465,7 @@ updater = $.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 + $.bind input, 'click', updater.update $.add d.body, dialog @@ -1525,26 +1525,23 @@ updater = scrollTo 0, d.body.scrollHeight timeout: -> - n = Number updater.timer.textContent - ++n - - if n is 10 - updater.count.textContent = 'retry' - updater.count.className = '' - n = 0 - - updater.timer.textContent = n + updater.timeoutID = setTimeout updater.timeout, 1000 + n = 1 + Number updater.timer.textContent if n is 0 updater.update() + else if n is 10 + updater.retry() + else + updater.timer.textContent = n - updater.timeoutID = setTimeout updater.timeout, 1000 - - updateNow: -> - updater.timer.textContent = 0 + retry: -> + updater.count.textContent = 'retry' + updater.count.className = '' updater.update() update: -> + updater.timer.textContent = 0 updater.request?.abort() url = location.pathname + '?' + Date.now() # fool the cache cb = updater.cb.update