From b2c789a46c73ec2d6faeb1fcdf8ec869a11235f1 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 9 Aug 2011 05:00:52 -0700 Subject: [PATCH] add ?cooldown on index, rm sage from cooldown --- 4chan_x.user.js | 26 ++++---------------------- script.coffee | 19 +++---------------- 2 files changed, 7 insertions(+), 38 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 488b9ed34..49119e87a 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1158,9 +1158,9 @@ }; cooldown = { init: function() { - var form, input, time, _, _ref; - if (/cooldown/.test(location.search)) { - _ref = location.search.match(/cooldown=(\d+)/), _ = _ref[0], time = _ref[1]; + var form, match, time, _; + if (match = location.search.match(/cooldown=(\d+)/)) { + _ = match[0], time = match[1]; if ($.getValue(g.BOARD + '/cooldown', 0) < time) { $.setValue(g.BOARD + '/cooldown', time); } @@ -1173,26 +1173,8 @@ return cooldown.start(); } }); - if (g.REPLY) { - form = $('.postarea form'); - form.action += '?cooldown'; - input = $('.postarea input[name=email]'); - if (/sage/i.test(input.value)) { - form.action += '?sage'; - } - return $.bind(input, 'keyup', cooldown.sage); - } - }, - sage: function() { - var form; form = $('.postarea form'); - if (/sage/i.test(this.value)) { - if (!/sage/.test(form.action)) { - return form.action += '?sage'; - } - } else { - return form.action = form.action.replace('?sage', ''); - } + return form.action += '?cooldown'; }, start: function() { var submit, _i, _len, _ref; diff --git a/script.coffee b/script.coffee index 236ea9b2f..05bc7fc69 100644 --- a/script.coffee +++ b/script.coffee @@ -923,27 +923,14 @@ options = cooldown = init: -> - if /cooldown/.test location.search - [_, time] = location.search.match /cooldown=(\d+)/ + if match = location.search.match /cooldown=(\d+)/ + [_, time] = match $.setValue g.BOARD+'/cooldown', time if $.getValue(g.BOARD+'/cooldown', 0) < time cooldown.start() if Date.now() < $.getValue g.BOARD+'/cooldown', 0 $.bind window, 'storage', (e) -> cooldown.start() if e.key is "#{NAMESPACE}#{g.BOARD}/cooldown" - if g.REPLY - form = $('.postarea form') - form.action += '?cooldown' - input = $('.postarea input[name=email]') - if /sage/i.test input.value - form.action += '?sage' - $.bind input, 'keyup', cooldown.sage - - sage: -> form = $('.postarea form') - if /sage/i.test @value - unless /sage/.test form.action - form.action += '?sage' - else - form.action = form.action.replace '?sage', '' + form.action += '?cooldown' start: -> cooldown.duration = Math.ceil ($.getValue(g.BOARD+'/cooldown', 0) - Date.now()) / 1000