From 10dccc6faa8c95b34a96cdfeae6daa335fe9b76d Mon Sep 17 00:00:00 2001 From: Bobby Date: Mon, 5 Sep 2022 19:25:07 -0400 Subject: Added captcha to register page --- static/js/captcha.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 static/js/captcha.js (limited to 'static/js/captcha.js') diff --git a/static/js/captcha.js b/static/js/captcha.js new file mode 100644 index 00000000..93be88da --- /dev/null +++ b/static/js/captcha.js @@ -0,0 +1,15 @@ +const refreshCaptchaButton = document.getElementById('refresh_captcha'); + +refreshCaptchaButton.addEventListener('click', function() { + const refreshCaptchaURl = refreshCaptchaButton.getAttribute('data-refresh-captcha-url'); + + const xhr = new XMLHttpRequest(); + xhr.open('GET', refreshCaptchaURl, true); + xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); + xhr.onload = function() { + const data = JSON.parse(this.responseText); + const captchaImage = document.getElementById('captcha_image'); + captchaImage.src = data['captcha']; + } + xhr.send(); +}); -- cgit v1.2.3