From c696916e60dfcaf53fd2e4c835dad73e08446553 Mon Sep 17 00:00:00 2001 From: Nicolas Stepien Date: Tue, 6 Mar 2012 15:29:37 +0100 Subject: [PATCH] Disable auto-posting if you're writing during the last 5 seconds of the cooldown. Close #205. --- 4chan_x.user.js | 5 ++++- script.coffee | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index d16cc2cbf..546047447 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1843,7 +1843,10 @@ for (_k = 0, _len3 = _ref3.length; _k < _len3; _k++) { event = _ref3[_k]; $.on(input, event, function() { - return qr.selected[this.name] = this.value; + qr.selected[this.name] = this.value; + if (qr.cooldown.auto && qr.selected === qr.replies[0] && parseInt(qr.status.input.value.match(/\d+/)) < 6) { + return qr.cooldown.auto = false; + } }); } } diff --git a/script.coffee b/script.coffee index 72daadcfd..182781b53 100644 --- a/script.coffee +++ b/script.coffee @@ -1491,7 +1491,12 @@ qr = for name in ['name', 'email', 'sub', 'com'] input = $ "[name=#{name}]", qr.el for event in ['textInput', 'keyup', 'change', 'paste'] - $.on input, event, -> qr.selected[@name] = @value + $.on input, event, -> + qr.selected[@name] = @value + # Disable auto-posting if you're typing in the first reply + # during the last 5 seconds of the cooldown. + if qr.cooldown.auto and qr.selected is qr.replies[0] and parseInt(qr.status.input.value.match /\d+/) < 6 + qr.cooldown.auto = false # sync between tabs $.sync 'qr.persona', (persona) -> return unless qr.el.hidden