Do the math, once.
This commit is contained in:
parent
296fb027ec
commit
6edb57796d
@ -1021,26 +1021,25 @@
|
||||
};
|
||||
cooldown = {
|
||||
init: function() {
|
||||
var duration;
|
||||
if (0 < (duration = Math.ceil(($.getValue(g.BOARD + '/cooldown', 0) - Date.now()) / 1000))) {
|
||||
cooldown.start(duration);
|
||||
if (Date.now() < $.getValue(g.BOARD + '/cooldown', 0)) {
|
||||
cooldown.start();
|
||||
}
|
||||
return $.bind(window, 'storage', function(e) {
|
||||
if (e.key === ("AEOS.4chan_x." + g.BOARD + "/cooldown")) {
|
||||
return cooldown.start(Math.ceil(($.getValue(g.BOARD + '/cooldown', 0) - Date.now()) / 1000));
|
||||
return cooldown.start();
|
||||
}
|
||||
});
|
||||
},
|
||||
start: function(duration) {
|
||||
start: function() {
|
||||
var submit, _i, _len, _ref;
|
||||
cooldown.duration = Math.ceil(($.getValue(g.BOARD + '/cooldown', 0) - Date.now()) / 1000);
|
||||
_ref = $$('#com_submit');
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
submit = _ref[_i];
|
||||
submit.value = duration;
|
||||
submit.value = cooldown.duration;
|
||||
submit.disabled = true;
|
||||
}
|
||||
cooldown.interval = window.setInterval(cooldown.cb, 1000);
|
||||
return cooldown.duration = duration;
|
||||
return cooldown.interval = window.setInterval(cooldown.cb, 1000);
|
||||
},
|
||||
cb: function() {
|
||||
var submit, _i, _len, _ref;
|
||||
@ -1107,9 +1106,9 @@
|
||||
}
|
||||
}
|
||||
if ($.config('Cooldown')) {
|
||||
duration = qr.sage ? 60 : 30;
|
||||
$.setValue(g.BOARD + '/cooldown', Date.now() + duration * 1000);
|
||||
cooldown.start(duration);
|
||||
duration = qr.sage ? 60000 : 30000;
|
||||
$.setValue(g.BOARD + '/cooldown', Date.now() + duration);
|
||||
cooldown.start();
|
||||
}
|
||||
}
|
||||
Recaptcha.reload();
|
||||
|
||||
@ -780,17 +780,15 @@ options =
|
||||
|
||||
cooldown =
|
||||
init: ->
|
||||
if 0 < duration = Math.ceil ($.getValue(g.BOARD+'/cooldown', 0) - Date.now()) / 1000
|
||||
cooldown.start duration
|
||||
$.bind window, 'storage', (e) -> if e.key is "AEOS.4chan_x.#{g.BOARD}/cooldown"
|
||||
cooldown.start Math.ceil ($.getValue(g.BOARD+'/cooldown', 0) - Date.now()) / 1000
|
||||
cooldown.start() if Date.now() < $.getValue g.BOARD+'/cooldown', 0
|
||||
$.bind window, 'storage', (e) -> cooldown.start() if e.key is "AEOS.4chan_x.#{g.BOARD}/cooldown"
|
||||
|
||||
start: (duration) ->
|
||||
start: ->
|
||||
cooldown.duration = Math.ceil ($.getValue(g.BOARD+'/cooldown', 0) - Date.now()) / 1000
|
||||
for submit in $$ '#com_submit'
|
||||
submit.value = duration
|
||||
submit.value = cooldown.duration
|
||||
submit.disabled = true
|
||||
cooldown.interval = window.setInterval cooldown.cb, 1000
|
||||
cooldown.duration = duration
|
||||
|
||||
cb: ->
|
||||
cooldown.duration--
|
||||
@ -842,9 +840,9 @@ qr =
|
||||
else
|
||||
$.rm dialog
|
||||
if $.config 'Cooldown'
|
||||
duration = if qr.sage then 60 else 30
|
||||
$.setValue g.BOARD+'/cooldown', Date.now() + duration * 1000
|
||||
cooldown.start duration
|
||||
duration = if qr.sage then 60000 else 30000
|
||||
$.setValue g.BOARD+'/cooldown', Date.now() + duration
|
||||
cooldown.start()
|
||||
|
||||
Recaptcha.reload()
|
||||
$('iframe[name=iframe]').src = 'about:blank'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user