信仰指数:修订间差异
来自SOKA CAFE
小 |
|||
第1行: | 第1行: | ||
{{全屏| | {{全屏| | ||
<html> | <html> | ||
<style> | <style> | ||
/* | /* | ||
第216行: | 第215行: | ||
<div class="input-group"> | <div class="input-group"> | ||
<label for="username">请输入您的名字:</label> | <label for="faith-index-username">请输入您的名字:</label> | ||
<input type="text" id="faith-index-username" placeholder="输入名字..." autocomplete="off"> | <input type="text" id="faith-index-username" placeholder="输入名字..." autocomplete="off"> | ||
</div> | </div> | ||
第249行: | 第248行: | ||
<!-- JavaScript logic for the application --> | <!-- JavaScript logic for the application --> | ||
<script> | <script> | ||
// Use a standard DOMContentLoaded event to ensure the HTML is loaded before running the script | |||
document.addEventListener('DOMContentLoaded', function() { | |||
const analyzeBtn = document.getElementById('faith-index-analyzeBtn'); | |||
const usernameInput = document.getElementById('faith-index-username'); | |||
if (analyzeBtn && usernameInput) { | |||
analyzeBtn.addEventListener('click', function() { | analyzeBtn.addEventListener('click', function() { | ||
const username = usernameInput.value.trim(); | const username = usernameInput.value.trim(); | ||
第260行: | 第260行: | ||
if (!username) { | if (!username) { | ||
showError('请输入您的名字!'); | showError('请输入您的名字!'); | ||
resultDiv.style.display = 'none'; | if(resultDiv) resultDiv.style.display = 'none'; | ||
return; | return; | ||
} | } | ||
第276行: | 第276行: | ||
document.getElementById('faith-index-scoreDisplay').textContent = score + '%'; | document.getElementById('faith-index-scoreDisplay').textContent = score + '%'; | ||
document.getElementById('faith-index-comment').textContent = comment; | document.getElementById('faith-index-comment').textContent = comment; | ||
resultDiv.style.display = 'block'; | if(resultDiv) resultDiv.style.display = 'block'; | ||
// Use a timeout to ensure the CSS transition for the meter fill is visible | // Use a timeout to ensure the CSS transition for the meter fill is visible | ||
setTimeout(() => { | setTimeout(() => { | ||
document.getElementById('faith-index-meterFill').style.width = score + '%'; | const meterFill = document.getElementById('faith-index-meterFill'); | ||
if(meterFill) meterFill.style.width = score + '%'; | |||
}, 100); | }, 100); | ||
}); | }); | ||
// | // Add event listener for the 'Enter' key | ||
function | usernameInput.addEventListener('keypress', function(e) { | ||
if (e.key === 'Enter') { | |||
if ( | analyzeBtn.click(); | ||
} | } | ||
}); | |||
} | |||
function calculateFaithIndex(username) { | |||
let hash = 0; | |||
if (username.length === 0) return 0; | |||
for (let i = 0; i < username.length; i++) { | |||
const char = username.charCodeAt(i); | |||
hash = ((hash << 5) - hash) + char; | |||
hash = hash & hash; // Convert to 32bit integer | |||
} | } | ||
return Math.abs(hash) % 101; | |||
} | |||
function getFaithComment(score) { | |||
if (score <= 20) { | |||
return "信仰指数较低,信心还需磨练。请多参加活动,加强学习,在广布的道路上继续精进!"; | |||
} else if (score <= 40) { | |||
return "作为一名初信者,你的信心正在萌芽。坚持每日的实践,你将见证不可思议的功德!"; | |||
} else if (score <= 60) { | |||
return "信心坚定,是广布的有力实践者。你的存在本身就是胜利的证明,请继续鼓励身边的同志!"; | |||
} else if (score <= 80) { | |||
return "不愧是池田门生,信心强盛如狮子王!你的祈愿必将实现,继续作为常胜的先驱奋斗吧!"; | |||
} else { | |||
return "了不起!你拥有佛的生命,是人间革命的先锋。你的生命正在闪耀着最尊贵的光芒!"; | |||
} | } | ||
} | |||
function showError(message) { | |||
const errorMsg = document.getElementById('faith-index-errorMsg'); | |||
if (errorMsg) { | |||
errorMsg.textContent = message; | errorMsg.textContent = message; | ||
errorMsg.style.display = 'block'; | errorMsg.style.display = 'block'; | ||
} | } | ||
} | |||
function hideError() { | |||
const errorMsg = document.getElementById('faith-index-errorMsg'); | |||
if (errorMsg) { | |||
errorMsg.style.display = 'none'; | errorMsg.style.display = 'none'; | ||
} | } | ||
} | |||
}); | |||
</script> | </script> | ||
</html> | </html> | ||
}} | }} |
2025年10月12日 (日) 16:25的版本
信仰指数测试
测测你的信仰有多虔诚
测试结果
姓名:
0%
0-20
21-40
41-60
61-80
81-100