rm cooldown
This commit is contained in:
parent
106fc313af
commit
fb710dbf51
@ -60,7 +60,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, QR, SECOND, Time, anonymize, conf, config, cooldown, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref;
|
var $, $$, DAY, Favicon, HOUR, MINUTE, NAMESPACE, QR, SECOND, Time, anonymize, conf, config, d, expandComment, expandThread, firstRun, g, getTitle, imgExpand, imgGif, imgHover, imgPreloading, key, keybinds, log, main, nav, nodeInserted, options, quoteBacklink, quoteInline, quoteOP, quotePreview, redirect, replyHiding, reportButton, revealSpoilers, sauce, threadHiding, threadStats, threading, titlePost, ui, unread, updater, val, watcher, _ref;
|
||||||
var __slice = Array.prototype.slice;
|
var __slice = Array.prototype.slice;
|
||||||
config = {
|
config = {
|
||||||
main: {
|
main: {
|
||||||
@ -1209,62 +1209,6 @@
|
|||||||
return $('#backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789');
|
return $('#backlinkPreview').textContent = conf['backlink'].replace(/%id/, '123456789');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
cooldown = {
|
|
||||||
init: function() {
|
|
||||||
var match, time, _;
|
|
||||||
if (match = location.search.match(/cooldown=(\d+)/)) {
|
|
||||||
_ = match[0], time = match[1];
|
|
||||||
if ($.get(g.BOARD + '/cooldown', 0) < time) {
|
|
||||||
$.set(g.BOARD + '/cooldown', time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (Date.now() < $.get(g.BOARD + '/cooldown', 0)) {
|
|
||||||
cooldown.start();
|
|
||||||
}
|
|
||||||
$.bind(window, 'storage', function(e) {
|
|
||||||
if (e.key === ("" + NAMESPACE + g.BOARD + "/cooldown")) {
|
|
||||||
return cooldown.start();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (g.REPLY) {
|
|
||||||
return $('.postarea form').action += '?cooldown';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
start: function() {
|
|
||||||
var submit, _i, _len, _ref;
|
|
||||||
cooldown.duration = Math.ceil(($.get(g.BOARD + '/cooldown', 0) - Date.now()) / 1000);
|
|
||||||
if (!(cooldown.duration > 0)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_ref = $$('#com_submit');
|
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
||||||
submit = _ref[_i];
|
|
||||||
submit.value = cooldown.duration;
|
|
||||||
submit.disabled = true;
|
|
||||||
}
|
|
||||||
return setTimeout(cooldown.cb, 1000);
|
|
||||||
},
|
|
||||||
cb: function() {
|
|
||||||
var submit, submits, _i, _j, _len, _len2, _results;
|
|
||||||
submits = $$('#com_submit');
|
|
||||||
if (--cooldown.duration) {
|
|
||||||
setTimeout(cooldown.cb, 1000);
|
|
||||||
_results = [];
|
|
||||||
for (_i = 0, _len = submits.length; _i < _len; _i++) {
|
|
||||||
submit = submits[_i];
|
|
||||||
_results.push(submit.value = cooldown.duration);
|
|
||||||
}
|
|
||||||
return _results;
|
|
||||||
} else {
|
|
||||||
for (_j = 0, _len2 = submits.length; _j < _len2; _j++) {
|
|
||||||
submit = submits[_j];
|
|
||||||
submit.disabled = false;
|
|
||||||
submit.value = 'Submit';
|
|
||||||
}
|
|
||||||
return qr.autoPost();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
QR = {
|
QR = {
|
||||||
init: function() {
|
init: function() {
|
||||||
var holder;
|
var holder;
|
||||||
@ -1303,9 +1247,16 @@
|
|||||||
QR.dialog();
|
QR.dialog();
|
||||||
$('textarea', QR.qr).blur();
|
$('textarea', QR.qr).blur();
|
||||||
if (conf['Auto Hide QR']) {
|
if (conf['Auto Hide QR']) {
|
||||||
return $('#autohide', QR.qr).checked = true;
|
$('#autohide', QR.qr).checked = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (conf['Cooldown']) {
|
||||||
|
return $.bind(window, 'storage', function(e) {
|
||||||
|
if (e.key === ("" + NAMESPACE + "cooldown/" + g.BOARD)) {
|
||||||
|
return QR.cooldown();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
attach: function() {
|
attach: function() {
|
||||||
var div, file, files;
|
var div, file, files;
|
||||||
@ -1393,7 +1344,7 @@
|
|||||||
return QR.qr = null;
|
return QR.qr = null;
|
||||||
},
|
},
|
||||||
cooldown: function() {
|
cooldown: function() {
|
||||||
var b, n, now;
|
var b, cooldown, n, now;
|
||||||
if (!(g.REPLY && QR.qr)) {
|
if (!(g.REPLY && QR.qr)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1495,7 +1446,7 @@
|
|||||||
return (_base = $('[name=resto]', qr)).value || (_base.value = tid);
|
return (_base = $('[name=resto]', qr)).value || (_base.value = tid);
|
||||||
},
|
},
|
||||||
receive: function(e) {
|
receive: function(e) {
|
||||||
var data, qr, row, tc, _ref, _ref2;
|
var cooldown, data, qr, row, tc, _ref, _ref2;
|
||||||
$('iframe[name=iframe]').src = 'about:blank';
|
$('iframe[name=iframe]').src = 'about:blank';
|
||||||
qr = QR.qr;
|
qr = QR.qr;
|
||||||
row = (_ref = $('#files input[form]', qr)) != null ? _ref.parentNode : void 0;
|
row = (_ref = $('#files input[form]', qr)) != null ? _ref.parentNode : void 0;
|
||||||
|
|||||||
@ -929,36 +929,6 @@ options =
|
|||||||
conf['backlink'] = @value
|
conf['backlink'] = @value
|
||||||
$('#backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789'
|
$('#backlinkPreview').textContent = conf['backlink'].replace /%id/, '123456789'
|
||||||
|
|
||||||
cooldown =
|
|
||||||
#TODO merge into qr
|
|
||||||
init: ->
|
|
||||||
if match = location.search.match /cooldown=(\d+)/
|
|
||||||
[_, time] = match
|
|
||||||
$.set g.BOARD+'/cooldown', time if $.get(g.BOARD+'/cooldown', 0) < time
|
|
||||||
cooldown.start() if Date.now() < $.get g.BOARD+'/cooldown', 0
|
|
||||||
$.bind window, 'storage', (e) -> cooldown.start() if e.key is "#{NAMESPACE}#{g.BOARD}/cooldown"
|
|
||||||
$('.postarea form').action += '?cooldown' if g.REPLY
|
|
||||||
|
|
||||||
start: ->
|
|
||||||
cooldown.duration = Math.ceil ($.get(g.BOARD+'/cooldown', 0) - Date.now()) / 1000
|
|
||||||
return unless cooldown.duration > 0
|
|
||||||
for submit in $$ '#com_submit'
|
|
||||||
submit.value = cooldown.duration
|
|
||||||
submit.disabled = true
|
|
||||||
setTimeout cooldown.cb, 1000
|
|
||||||
|
|
||||||
cb: ->
|
|
||||||
submits = $$ '#com_submit'
|
|
||||||
if --cooldown.duration
|
|
||||||
setTimeout cooldown.cb, 1000
|
|
||||||
for submit in submits
|
|
||||||
submit.value = cooldown.duration
|
|
||||||
else
|
|
||||||
for submit in submits
|
|
||||||
submit.disabled = false
|
|
||||||
submit.value = 'Submit'
|
|
||||||
qr.autoPost()
|
|
||||||
|
|
||||||
QR =
|
QR =
|
||||||
#TODO create new thread
|
#TODO create new thread
|
||||||
#captcha caching for report form
|
#captcha caching for report form
|
||||||
@ -994,6 +964,8 @@ QR =
|
|||||||
$('textarea', QR.qr).blur()
|
$('textarea', QR.qr).blur()
|
||||||
if conf['Auto Hide QR']
|
if conf['Auto Hide QR']
|
||||||
$('#autohide', QR.qr).checked = true
|
$('#autohide', QR.qr).checked = true
|
||||||
|
if conf['Cooldown']
|
||||||
|
$.bind window, 'storage', (e) -> QR.cooldown() if e.key is "#{NAMESPACE}cooldown/#{g.BOARD}"
|
||||||
attach: ->
|
attach: ->
|
||||||
#$('#autopost', QR.qr).checked = true
|
#$('#autopost', QR.qr).checked = true
|
||||||
files = $ '#files', QR.qr
|
files = $ '#files', QR.qr
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user