mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-27 17:00:52 +01:00
Add files via upload
This commit is contained in:
parent
e1bc4f1da9
commit
e94f25d4cd
43
js/captcha.js
Normal file
43
js/captcha.js
Normal file
@ -0,0 +1,43 @@
|
||||
var tout;
|
||||
|
||||
function redo_events(provider, extra) {
|
||||
$('.captcha .captcha_text, textarea[id="body"]').off("focus").one("focus", function() { actually_load_captcha(provider, extra); });
|
||||
}
|
||||
|
||||
function actually_load_captcha(provider, extra) {
|
||||
$('.captcha .captcha_text, textarea[id="body"]').off("focus");
|
||||
|
||||
if (tout !== undefined) {
|
||||
clearTimeout(tout);
|
||||
}
|
||||
|
||||
$.getJSON(provider, {mode: 'get', extra: extra}, function(json) {
|
||||
$(".captcha .captcha_cookie").val(json.cookie);
|
||||
$(".captcha .captcha_html").html(json.captchahtml);
|
||||
|
||||
setTimeout(function() {
|
||||
redo_events(provider, extra);
|
||||
}, json.expires_in * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
function load_captcha(provider, extra) {
|
||||
$(function() {
|
||||
$(".captcha>td").html("<input class='captcha_text' type='text' name='captcha_text' size='32' maxlength='6' autocomplete='off'>"+
|
||||
"<input class='captcha_cookie' name='captcha_cookie' type='hidden'>"+
|
||||
"<div class='captcha_html'></div>");
|
||||
|
||||
$("#quick-reply .captcha .captcha_text").prop("placeholder", _("Verification"));
|
||||
|
||||
$(".captcha .captcha_html").on("click", function() { actually_load_captcha(provider, extra); });
|
||||
$(document).on("ajax_after_post", function() { actually_load_captcha(provider, extra); });
|
||||
redo_events(provider, extra);
|
||||
|
||||
$(window).on("quick-reply", function() {
|
||||
redo_events(provider, extra);
|
||||
$("#quick-reply .captcha .captcha_html").html($("form:not(#quick-reply) .captcha .captcha_html").html());
|
||||
$("#quick-reply .captcha .captcha_cookie").val($("form:not(#quick-reply) .captcha .captcha_cookie").html());
|
||||
$("#quick-reply .captcha .captcha_html").on("click", function() { actually_load_captcha(provider, extra); });
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue
Block a user