add ?cooldown on index, rm sage from cooldown

This commit is contained in:
James Campos 2011-08-09 05:00:52 -07:00
parent 01592ae8d7
commit b2c789a46c
2 changed files with 7 additions and 38 deletions

View File

@ -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;

View File

@ -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