Add automatic and manual reloading of captchas

This commit is contained in:
discomrade 2021-05-05 15:17:34 -02:00
parent 11bab0a9ad
commit f0b3c0fcb6
4 changed files with 15 additions and 3 deletions

View file

@ -286,6 +286,17 @@ function dopost(form) {
return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != "");
}
function reloadCaptcha() {
// Reload captcha images (date reduces chance of caching)
// If no securimage captcha is enabled, no elements will be found
captchaImgs = document.querySelectorAll('[id=captcha-img]');
for (var i = 0; i < captchaImgs.length; ++i)
captchaImgs[i].src = "/captcha.php?"+Date.now();
captchas = document.querySelectorAll('[id=captcha]');
for (var i = 0; i < captchas.length; ++i)
captchas[i].value = "";
}
function citeReply(id, with_link) {
var textarea = document.getElementById('body');

View file

@ -102,8 +102,8 @@
Captcha
</th>
<td>
<img src="{{ config.root }}/captcha.php"><br />
<input type="text" name="captcha" size="25" maxlength="10" autocomplete="off">
<img name="captcha-img" id="captcha-img" src="/captcha.php" onClick="this.src='/captcha.php?'+Date.now();document.getElementById('captcha').value = '';"><br />
<input type="text" name="captcha" id="captcha" size="25" maxlength="10" autocomplete="off">
</td>
</tr>
{% endif %}