From d1cfa987aed702beb21767f800a83e2895605df7 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Fri, 8 Jun 2012 21:10:37 +0200 Subject: [PATCH] Only allow the updater's interval value to be greater than 0. Set it to 1 otherwise. --- 4chan_x.user.js | 11 +++++++---- script.coffee | 8 +++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 9f587efb7..f5c3244e9 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -2447,10 +2447,7 @@ Conf[input.name] = input.checked; } } else if (input.name === 'Interval') { - $.on(input, 'input', function() { - this.value = parseInt(this.value, 10) || Conf['Interval']; - return $.cb.value.call(this); - }); + $.on(input, 'input', this.cb.interval); } else if (input.type === 'button') { $.on(input, 'click', this.update); } @@ -2460,6 +2457,12 @@ return this.lastModified = 0; }, cb: { + interval: function() { + var val; + val = parseInt(this.value, 10); + this.value = val > 0 ? val : 1; + return $.cb.value.call(this); + }, verbose: function() { if (Conf['Verbose']) { Updater.count.textContent = '+0'; diff --git a/script.coffee b/script.coffee index 23f984b36..a0ed7751b 100644 --- a/script.coffee +++ b/script.coffee @@ -1907,9 +1907,7 @@ Updater = # Required for the QR's update after posting. Conf[input.name] = input.checked else if input.name is 'Interval' - $.on input, 'input', -> - @value = parseInt(@value, 10) or Conf['Interval'] - $.cb.value.call @ + $.on input, 'input', @cb.interval else if input.type is 'button' $.on input, 'click', @update @@ -1919,6 +1917,10 @@ Updater = @lastModified = 0 cb: + interval: -> + val = parseInt @value, 10 + @value = if val > 0 then val else 1 + $.cb.value.call @ verbose: -> if Conf['Verbose'] Updater.count.textContent = '+0'