26 řádky
752 B
JavaScript
26 řádky
752 B
JavaScript
|
$(function () {
|
||
|
$("#get-captcha").click(function () {
|
||
|
let btn = $(this);
|
||
|
|
||
|
let board = btn.attr("data-board");
|
||
|
let reply = btn.attr("data-reply");
|
||
|
let req_url = `/captcha?board=${board}&reply=${reply}`;
|
||
|
|
||
|
btn.text("Získat CAPTCHA");
|
||
|
btn.prop("disabled", true);
|
||
|
btn.addClass("loading");
|
||
|
|
||
|
$.get(req_url, function (data, _) {
|
||
|
try {
|
||
|
$("#captcha").replaceWith(`<img id="captcha" src="data:image/png;base64,${data.png}">`);
|
||
|
$("#captcha-id").prop("value", data.id);
|
||
|
} catch {
|
||
|
btn.append(" [Chyba]");
|
||
|
}
|
||
|
|
||
|
btn.prop("disabled", false);
|
||
|
btn.removeClass("loading");
|
||
|
});
|
||
|
});
|
||
|
});
|