cooldown
This commit is contained in:
parent
71075d4c12
commit
4ec8ca541e
@ -1288,6 +1288,9 @@
|
|||||||
top: '0',
|
top: '0',
|
||||||
left: '0'
|
left: '0'
|
||||||
}, " <a class=close title=close>X</a><input type=checkbox id=autohide title=autohide> <div class=move><input placeholder=Name name=name form=qr_form>Quick Reply</div> <form enctype=multipart/form-data method=post action=http://sys.4chan.org/" + g.BOARD + "/post target=iframe id=qr_form> <input type=hidden name=resto value=" + g.THREAD_ID + "> <input type=hidden name=mode value=regist> <input type=hidden name=recaptcha_challenge_field id=challenge> <input type=hidden name=recaptcha_response_field id=response> <div><input placeholder=Email name=email></div> <div><input placeholder=Subject name=sub><button>Submit</button></div> <div><textarea placeholder=Comment name=com>" + text + "</textarea></div> <div><img src=http://www.google.com/recaptcha/api/image?c=" + QR.captcha.challenge + "></div> <div><input placeholder=Verification autocomplete=off id=recaptcha_response_field><span id=cl>" + ($.get('captchas', []).length) + " captchas</span></div> <div><input name=upfile type=file></div> <div><input placeholder=Password name=pwd type=password></div> </form> <a class=error></a> ");
|
}, " <a class=close title=close>X</a><input type=checkbox id=autohide title=autohide> <div class=move><input placeholder=Name name=name form=qr_form>Quick Reply</div> <form enctype=multipart/form-data method=post action=http://sys.4chan.org/" + g.BOARD + "/post target=iframe id=qr_form> <input type=hidden name=resto value=" + g.THREAD_ID + "> <input type=hidden name=mode value=regist> <input type=hidden name=recaptcha_challenge_field id=challenge> <input type=hidden name=recaptcha_response_field id=response> <div><input placeholder=Email name=email></div> <div><input placeholder=Subject name=sub><button>Submit</button></div> <div><textarea placeholder=Comment name=com>" + text + "</textarea></div> <div><img src=http://www.google.com/recaptcha/api/image?c=" + QR.captcha.challenge + "></div> <div><input placeholder=Verification autocomplete=off id=recaptcha_response_field><span id=cl>" + ($.get('captchas', []).length) + " captchas</span></div> <div><input name=upfile type=file></div> <div><input placeholder=Password name=pwd type=password></div> </form> <a class=error></a> ");
|
||||||
|
if (conf['Cooldown']) {
|
||||||
|
QR.cooldown;
|
||||||
|
}
|
||||||
$.bind($('.close', el), 'click', QR.close);
|
$.bind($('.close', el), 'click', QR.close);
|
||||||
$.bind($('form', el), 'submit', QR.submit);
|
$.bind($('form', el), 'submit', QR.submit);
|
||||||
$.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown);
|
$.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown);
|
||||||
@ -1323,13 +1326,40 @@
|
|||||||
ta.setSelectionRange(i, i);
|
ta.setSelectionRange(i, i);
|
||||||
return ta.focus();
|
return ta.focus();
|
||||||
},
|
},
|
||||||
|
cooldown: function() {
|
||||||
|
var b, n, now;
|
||||||
|
if (!QR.el) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cooldown = $.get("cooldown/" + g.BOARD, 0);
|
||||||
|
now = Date.now();
|
||||||
|
n = Math.ceil((cooldown - now) / 1000);
|
||||||
|
b = $('button', QR.el);
|
||||||
|
if (n > 0) {
|
||||||
|
setTimeout(QR.cooldown, 1000);
|
||||||
|
return $.extend(b, {
|
||||||
|
textContent: n,
|
||||||
|
disabled: true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return $.extend(b, {
|
||||||
|
textContent: 'Submit',
|
||||||
|
disabled: false
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
receive: function(e) {
|
receive: function(e) {
|
||||||
var data;
|
var data;
|
||||||
data = e.data;
|
data = e.data;
|
||||||
if (data) {
|
if (data) {
|
||||||
return $.extend($('a.error', QR.el), JSON.parse(data));
|
return $.extend($('a.error', QR.el), JSON.parse(data));
|
||||||
} else {
|
} else {
|
||||||
return QR.close();
|
QR.close();
|
||||||
|
if (conf['Cooldown']) {
|
||||||
|
cooldown = Date.now() + 30 * SECOND;
|
||||||
|
$.set("cooldown/" + g.BOARD, cooldown);
|
||||||
|
return QR.cooldown();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
submit: function(e) {
|
submit: function(e) {
|
||||||
|
|||||||
@ -1019,6 +1019,7 @@ QR =
|
|||||||
</form>
|
</form>
|
||||||
<a class=error></a>
|
<a class=error></a>
|
||||||
"
|
"
|
||||||
|
QR.cooldown if conf['Cooldown']
|
||||||
$.bind $('.close', el), 'click', QR.close
|
$.bind $('.close', el), 'click', QR.close
|
||||||
$.bind $('form', el), 'submit', QR.submit
|
$.bind $('form', el), 'submit', QR.submit
|
||||||
$.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown
|
$.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown
|
||||||
@ -1045,12 +1046,31 @@ QR =
|
|||||||
i = ss + text.length
|
i = ss + text.length
|
||||||
ta.setSelectionRange i, i
|
ta.setSelectionRange i, i
|
||||||
ta.focus()
|
ta.focus()
|
||||||
|
cooldown: ->
|
||||||
|
return unless QR.el
|
||||||
|
cooldown = $.get "cooldown/#{g.BOARD}", 0
|
||||||
|
now = Date.now()
|
||||||
|
n = Math.ceil (cooldown - now) / 1000
|
||||||
|
b = $ 'button', QR.el
|
||||||
|
if n > 0
|
||||||
|
setTimeout QR.cooldown, 1000
|
||||||
|
$.extend b,
|
||||||
|
textContent: n
|
||||||
|
disabled: true
|
||||||
|
else
|
||||||
|
$.extend b,
|
||||||
|
textContent: 'Submit'
|
||||||
|
disabled: false
|
||||||
receive: (e) ->
|
receive: (e) ->
|
||||||
{data} = e
|
{data} = e
|
||||||
if data
|
if data
|
||||||
$.extend $('a.error', QR.el), JSON.parse data
|
$.extend $('a.error', QR.el), JSON.parse data
|
||||||
else
|
else
|
||||||
QR.close()
|
QR.close()
|
||||||
|
if conf['Cooldown']
|
||||||
|
cooldown = Date.now() + 30*SECOND
|
||||||
|
$.set "cooldown/#{g.BOARD}", cooldown
|
||||||
|
QR.cooldown()
|
||||||
submit: (e) ->
|
submit: (e) ->
|
||||||
$('.error', qr.el).textContent = ''
|
$('.error', qr.el).textContent = ''
|
||||||
if (el = $('#recaptcha_response_field', QR.el)).value
|
if (el = $('#recaptcha_response_field', QR.el)).value
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user