Reupload
This commit is contained in:
1 parent
6eb60df5ee
commit
12b3513f29
9 files changed
+3313
No files matched your search
@@ -0,0 +1,28 @@
|
||||
// ============================================================
|
||||
// 🧠 验证码
|
||||
// ============================================================
|
||||
|
||||
function generateCaptcha() {
|
||||
let a = Math.floor(Math.random() * 9) + 1;
|
||||
let b = Math.floor(Math.random() * 9) + 1;
|
||||
let op = ['+', '-'][Math.floor(Math.random() * 2)];
|
||||
if (op === '-' && a < b) { let t = a;
|
||||
a = b;
|
||||
b = t; }
|
||||
let answer = op === '+' ? a + b : a - b;
|
||||
return { question: a + ' ' + op + ' ' + b + ' = ?', answer: answer };
|
||||
}
|
||||
|
||||
function refreshCaptcha(type) {
|
||||
let q = generateCaptcha();
|
||||
if (type === 'reg') {
|
||||
document.getElementById('regCaptchaQuestion').textContent = q.question;
|
||||
document.getElementById('regCaptchaInput').dataset.answer = q.answer;
|
||||
} else if (type === 'post') {
|
||||
document.getElementById('postCaptchaQuestion').textContent = q.question;
|
||||
document.getElementById('postCaptchaInput').dataset.answer = q.answer;
|
||||
} else if (type === 'reply') {
|
||||
document.getElementById('replyCaptchaQuestion').textContent = q.question;
|
||||
document.getElementById('replyCaptchaInput').dataset.answer = q.answer;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user