This commit is contained in:
James Campos 2011-09-02 19:55:22 -07:00
parent 71075d4c12
commit 4ec8ca541e
2 changed files with 51 additions and 1 deletions

View File

@ -1288,6 +1288,9 @@
top: '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> ");
if (conf['Cooldown']) {
QR.cooldown;
}
$.bind($('.close', el), 'click', QR.close);
$.bind($('form', el), 'submit', QR.submit);
$.bind($('#recaptcha_response_field', el), 'keydown', QR.keydown);
@ -1323,13 +1326,40 @@
ta.setSelectionRange(i, i);
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) {
var data;
data = e.data;
if (data) {
return $.extend($('a.error', QR.el), JSON.parse(data));
} 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) {

View File

@ -1019,6 +1019,7 @@ QR =
</form>
<a class=error></a>
"
QR.cooldown if conf['Cooldown']
$.bind $('.close', el), 'click', QR.close
$.bind $('form', el), 'submit', QR.submit
$.bind $('#recaptcha_response_field', el), 'keydown', QR.keydown
@ -1045,12 +1046,31 @@ QR =
i = ss + text.length
ta.setSelectionRange i, i
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) ->
{data} = e
if data
$.extend $('a.error', QR.el), JSON.parse data
else
QR.close()
if conf['Cooldown']
cooldown = Date.now() + 30*SECOND
$.set "cooldown/#{g.BOARD}", cooldown
QR.cooldown()
submit: (e) ->
$('.error', qr.el).textContent = ''
if (el = $('#recaptcha_response_field', QR.el)).value