信仰指数:修订间差异

来自SOKA CAFE
こばと
こばと留言 | 贡献 (修改)
こばと
こばと留言 | 贡献 (修改)
第1行: 第1行:
{{全屏|
{{全屏|
<html>
<html>
<!-- CSS Styles for the application -->
<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>
    (function() {
// Use a standard DOMContentLoaded event to ensure the HTML is loaded before running the script
        // We wrap the entire script in a function to avoid global scope conflicts.
document.addEventListener('DOMContentLoaded', function() {
        const analyzeBtn = document.getElementById('faith-index-analyzeBtn');
    const analyzeBtn = document.getElementById('faith-index-analyzeBtn');
        const usernameInput = document.getElementById('faith-index-username');
    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);
         });
         });
          
          
         // Deterministic algorithm to calculate faith index (0-100)
         // Add event listener for the 'Enter' key
         function calculateFaithIndex(username) {
         usernameInput.addEventListener('keypress', function(e) {
            let hash = 0;
             if (e.key === 'Enter') {
             if (username.length === 0) return 0;
                 analyzeBtn.click();
            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
             }
             }
            // Map the hash to a range of 0-100
        });
             return Math.abs(hash) % 101;
    }
   
    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;
        // Generate a comment based on the score
    }
        function getFaithComment(score) {
   
            if (score <= 20) {
    function getFaithComment(score) {
                return "信仰指数较低,信心还需磨练。请多参加活动,加强学习,在广布的道路上继续精进!";
        if (score <= 20) {
            } else if (score <= 40) {
            return "信仰指数较低,信心还需磨练。请多参加活动,加强学习,在广布的道路上继续精进!";
                return "作为一名初信者,你的信心正在萌芽。坚持每日的实践,你将见证不可思议的功德!";
        } else if (score <= 40) {
            } else if (score <= 60) {
            return "作为一名初信者,你的信心正在萌芽。坚持每日的实践,你将见证不可思议的功德!";
                return "信心坚定,是广布的有力实践者。你的存在本身就是胜利的证明,请继续鼓励身边的同志!";
        } else if (score <= 60) {
            } else if (score <= 80) {
            return "信心坚定,是广布的有力实践者。你的存在本身就是胜利的证明,请继续鼓励身边的同志!";
                return "不愧是池田门生,信心强盛如狮子王!你的祈愿必将实现,继续作为常胜的先驱奋斗吧!";
        } else if (score <= 80) {
            } else {
            return "不愧是池田门生,信心强盛如狮子王!你的祈愿必将实现,继续作为常胜的先驱奋斗吧!";
                return "了不起!你拥有佛的生命,是人间革命的先锋。你的生命正在闪耀着最尊贵的光芒!";
        } else {
            }
            return "了不起!你拥有佛的生命,是人间革命的先锋。你的生命正在闪耀着最尊贵的光芒!";
         }
         }
       
    }
        // Function to show an error message
   
        function showError(message) {
    function showError(message) {
            const errorMsg = document.getElementById('faith-index-errorMsg');
        const errorMsg = document.getElementById('faith-index-errorMsg');
        if (errorMsg) {
             errorMsg.textContent = message;
             errorMsg.textContent = message;
             errorMsg.style.display = 'block';
             errorMsg.style.display = 'block';
         }
         }
    }


        // Function to hide the error message
    function hideError() {
        function hideError() {
        const errorMsg = document.getElementById('faith-index-errorMsg');
            const errorMsg = document.getElementById('faith-index-errorMsg');
        if (errorMsg) {
             errorMsg.style.display = 'none';
             errorMsg.style.display = 'none';
         }
         }
       
    }
        // Add event listener for the 'Enter' key
});
        usernameInput.addEventListener('keypress', function(e) {
            if (e.key === 'Enter') {
                analyzeBtn.click();
            }
        });
    })();
</script>
</script>
</html>
</html>
}}
}}

2025年10月12日 (日) 16:25的版本

返回主页

信仰指数测试

测测你的信仰有多虔诚

测试结果

姓名:

0%
0-20 21-40 41-60 61-80 81-100