nekrochan/static/js/captcha.js

26 řádky
732 B
JavaScript
Surový Normální zobrazení Historie

2024-03-16 11:20:50 +00:00
$(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.attr("disabled", true);
btn.addClass("loading");
$.get(req_url, function (data, _) {
try {
$("#captcha-id").attr("value", data.id);
$("#captcha").html(`<img src="data:image/png;base64,${data.png}">`);
} catch {
btn.append(" [Chyba]");
}
btn.attr("disabled", false);
btn.removeClass("loading");
});
});
});