信仰指数:修订间差异

来自SOKA CAFE
第1行: 第1行:
{{全屏|
{{全屏|
<html>
<!-- CSS Styles for the application -->
<head>
<style>
     <meta charset="UTF-8">
     /*
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
      The container styling is slightly adjusted to work better in a wiki context.
     <title>信仰指数测试</title>
      Using a class name like 'faith-index-container' avoids potential conflicts
     <style>
      with MediaWiki's own styles.
        * {
     */
            margin: 0;
     .faith-index-body {
            padding: 0;
        background: linear-gradient(135deg, #0052a5 0%, #f9e300 50%, #d40000 100%);
            box-sizing: border-box;
        min-height: 90vh; /* Use vh for viewport height */
            font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
        display: flex;
        }
        justify-content: center;
       
        align-items: center;
        body {
        padding: 20px;
            /* Changed background to blue, yellow, and red gradient */
         font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
            background: linear-gradient(135deg, #0052a5 0%, #f9e300 50%, #d40000 100%);
    }
            min-height: 100vh;
   
            display: flex;
    .faith-index-container {
            justify-content: center;
        background: rgba(255, 255, 255, 0.25);
            align-items: center;
        backdrop-filter: blur(12px);
            padding: 20px;
        border-radius: 20px;
         }
        padding: 40px;
       
        width: 100%;
        .container {
        max-width: 500px;
            background: rgba(255, 255, 255, 0.25);
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            backdrop-filter: blur(12px);
        border: 1px solid rgba(255, 255, 255, 0.4);
            border-radius: 20px;
        text-align: center;
            padding: 40px;
         margin: 0 auto; /* Center the container */
            width: 100%;
    }
            max-width: 500px;
   
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    .faith-index-container h1 {
            border: 1px solid rgba(255, 255, 255, 0.4);
        color: #2c3e50;
            text-align: center;
        margin-bottom: 10px;
         }
        font-size: 2.2rem;
       
        font-weight: 600;
        h1 {
    }
            color: #2c3e50;
   
            margin-bottom: 10px;
    .faith-index-container .subtitle {
            font-size: 2.2rem;
        color: #34495e;
            font-weight: 600;
        margin-bottom: 30px;
        }
        font-size: 1rem;
       
    }
        .subtitle {
   
            color: #34495e;
    .faith-index-container .input-group {
            margin-bottom: 30px;
        margin-bottom: 25px;
            font-size: 1rem;
        text-align: left;
        }
    }
       
   
        .input-group {
    .faith-index-container label {
            margin-bottom: 25px;
        display: block;
            text-align: left;
        color: #2c3e50;
        }
        margin-bottom: 8px;
       
        font-weight: 500;
        label {
    }
            display: block;
   
            color: #2c3e50;
    .faith-index-container input {
            margin-bottom: 8px;
        width: 100%;
            font-weight: 500;
        padding: 15px;
        }
        border-radius: 12px;
       
        border: none;
        input {
        background: rgba(255, 255, 255, 0.5);
            width: 100%;
        color: #2c3e50;
            padding: 15px;
        font-size: 1rem;
            border-radius: 12px;
        transition: all 0.3s ease;
            border: none;
        border: 1px solid rgba(255, 255, 255, 0.5);
            background: rgba(255, 255, 255, 0.5);
         box-sizing: border-box; /* Important for wiki compatibility */
            color: #2c3e50;
    }
            font-size: 1rem;
   
            transition: all 0.3s ease;
    .faith-index-container input:focus {
            border: 1px solid rgba(255, 255, 255, 0.5);
        outline: none;
         }
        background: rgba(255, 255, 255, 0.7);
       
        box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.2);
        input:focus {
    }
            outline: none;
   
            background: rgba(255, 255, 255, 0.7);
    .faith-index-container button {
            box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.2);
        background: linear-gradient(to right, #34495e, #2c3e50);
        }
        color: white;
       
        border: none;
        button {
        padding: 15px 30px;
            background: linear-gradient(to right, #34495e, #2c3e50);
        border-radius: 12px;
            color: white;
        font-size: 1.1rem;
            border: none;
        font-weight: 600;
            padding: 15px 30px;
        cursor: pointer;
            border-radius: 12px;
        transition: all 0.3s ease;
            font-size: 1.1rem;
        width: 100%;
            font-weight: 600;
        margin-top: 10px;
            cursor: pointer;
        box-shadow: 0 5px 15px rgba(44, 62, 80, 0.3);
            transition: all 0.3s ease;
        display: flex;
            width: 100%;
        justify-content: center;
            margin-top: 10px;
        align-items: center;
            box-shadow: 0 5px 15px rgba(44, 62, 80, 0.3);
        gap: 10px;
            display: flex;
    }
            justify-content: center;
   
            align-items: center;
    .faith-index-container button:hover {
            gap: 10px;
        transform: translateY(-3px);
        }
        box-shadow: 0 8px 20px rgba(44, 62, 80, 0.4);
       
    }
        button:hover {
   
            transform: translateY(-3px);
    .faith-index-container button:active {
            box-shadow: 0 8px 20px rgba(44, 62, 80, 0.4);
        transform: translateY(0);
        }
    }
       
   
        button:active {
    .faith-index-container button:disabled {
            transform: translateY(0);
        opacity: 0.7;
        }
        cursor: not-allowed;
       
        transform: none;
        button:disabled {
    }
            opacity: 0.7;
   
            cursor: not-allowed;
    .faith-index-container .loader {
            transform: none;
        width: 20px;
        }
        height: 20px;
       
        border: 2px solid rgba(255, 255, 255, 0.3);
        .loader {
        border-radius: 50%;
            width: 20px;
        border-top: 2px solid white;
            height: 20px;
        animation: faith-index-spin 1s linear infinite;
            border: 2px solid rgba(255, 255, 255, 0.3);
    }
            border-radius: 50%;
   
            border-top: 2px solid white;
    @keyframes faith-index-spin {
            animation: spin 1s linear infinite;
        0% { transform: rotate(0deg); }
        }
        100% { transform: rotate(360deg); }
       
    }
        @keyframes spin {
   
            0% { transform: rotate(0deg); }
    .faith-index-container .result {
            100% { transform: rotate(360deg); }
         margin-top: 30px;
         }
        padding: 25px;
          
        border-radius: 15px;
         .result {
        background: rgba(255, 255, 255, 0.3);
            margin-top: 30px;
        display: none;
        animation: faith-index-fadeIn 0.5s ease;
    }
   
    @keyframes faith-index-fadeIn {
         from { opacity: 0; transform: translateY(10px); }
         to { opacity: 1; transform: translateY(0); }
    }
   
    .faith-index-container .result h2 {
        color: #2c3e50;
        margin-bottom: 15px;
    }
   
    .faith-index-container .score {
        font-size: 3.5rem;
        font-weight: 800;
        margin: 15px 0;
        color: #2c3e50;
    }
   
    .faith-index-container .comment {
        font-size: 1.2rem;
        color: #2c3e50;
        margin: 15px 0;
        padding: 15px;
        border-radius: 10px;
        background: rgba(255, 255, 255, 0.4);
        text-align: left;
        line-height: 1.5;
    }
   
    .faith-index-container .meter {
        height: 20px;
        background: rgba(0, 0, 0, 0.1);
        border-radius: 10px;
        margin: 20px 0;
        overflow: hidden;
    }
   
    .faith-index-container .meter-fill {
        height: 100%;
        border-radius: 10px;
        transition: width 1s ease;
        background: linear-gradient(to right, #0052a5, #f9e300, #d40000);
    }
   
    .faith-index-container .ranges {
        display: flex;
        justify-content: space-between;
        margin-top: 10px;
        color: #34495e;
        font-size: 0.85rem;
    }
   
    .faith-index-container .footer {
        margin-top: 30px;
        color: #34495e;
        font-size: 0.9rem;
    }
   
    .faith-index-container .error {
        color: #d9534f;
        background: rgba(217, 83, 79, 0.1);
        padding: 10px;
        border-radius: 8px;
        margin-top: 10px;
        display: none;
    }
   
    @media (max-width: 600px) {
        .faith-index-container {
             padding: 25px;
             padding: 25px;
            border-radius: 15px;
            background: rgba(255, 255, 255, 0.3);
            display: none;
            animation: fadeIn 0.5s ease;
         }
         }
          
          
         @keyframes fadeIn {
         .faith-index-container h1 {
             from { opacity: 0; transform: translateY(10px); }
             font-size: 1.8rem;
            to { opacity: 1; transform: translateY(0); }
         }
         }
       
    }
        .result h2 {
</style>
            color: #2c3e50;
 
            margin-bottom: 15px;
<!-- HTML structure for the application -->
        }
<div class="faith-index-body">
       
     <div class="faith-index-container">
        .score {
            font-size: 3.5rem;
            font-weight: 800;
            margin: 15px 0;
            color: #2c3e50;
        }
       
        .comment {
            font-size: 1.2rem;
            color: #2c3e50;
            margin: 15px 0;
            padding: 15px;
            border-radius: 10px;
            background: rgba(255, 255, 255, 0.4);
            text-align: left;
            line-height: 1.5;
        }
       
        .meter {
            height: 20px;
            background: rgba(0, 0, 0, 0.1);
            border-radius: 10px;
            margin: 20px 0;
            overflow: hidden;
        }
       
        .meter-fill {
            height: 100%;
            border-radius: 10px;
            transition: width 1s ease;
            background: linear-gradient(to right, #0052a5, #f9e300, #d40000);
        }
       
        .ranges {
            display: flex;
            justify-content: space-between;
            margin-top: 10px;
            color: #34495e;
            font-size: 0.85rem;
        }
       
        .footer {
            margin-top: 30px;
            color: #34495e;
            font-size: 0.9rem;
        }
       
        .error {
            color: #d9534f;
            background: rgba(217, 83, 79, 0.1);
            padding: 10px;
            border-radius: 8px;
            margin-top: 10px;
            display: none;
        }
       
        @media (max-width: 600px) {
            .container {
                padding: 25px;
            }
           
            h1 {
                font-size: 1.8rem;
            }
        }
    </style>
</head>
<body>
     <div class="container">
         <h1>信仰指数测试</h1>
         <h1>信仰指数测试</h1>
         <p class="subtitle">测测你的信仰有多虔诚</p>
         <p class="subtitle">测测你的信仰有多虔诚</p>
第219行: 第216行:
         <div class="input-group">
         <div class="input-group">
             <label for="username">请输入您的名字:</label>
             <label for="username">请输入您的名字:</label>
             <input type="text" id="username" placeholder="输入名字..." autocomplete="off">
             <input type="text" id="faith-index-username" placeholder="输入名字..." autocomplete="off">
         </div>
         </div>
          
          
         <button id="analyzeBtn">
         <button id="faith-index-analyzeBtn">
             <span id="btnText">开始测试</span>
             <span id="faith-index-btnText">开始测试</span>
             <div class="loader" id="loader" style="display: none;"></div>
             <div class="loader" id="faith-index-loader" style="display: none;"></div>
         </button>
         </button>
          
          
         <div class="error" id="errorMsg"></div>
         <div class="error" id="faith-index-errorMsg"></div>
          
          
         <div class="result" id="result">
         <div class="result" id="faith-index-result">
             <h2>测试结果</h2>
             <h2>测试结果</h2>
             <p>姓名: <span id="resultUsername"></span></p>
             <p>姓名: <span id="faith-index-resultUsername"></span></p>
             <div class="score" id="scoreDisplay">0%</div>
             <div class="score" id="faith-index-scoreDisplay">0%</div>
             <div class="meter">
             <div class="meter">
                 <div class="meter-fill" id="meterFill" style="width: 0%;"></div>
                 <div class="meter-fill" id="faith-index-meterFill" style="width: 0%;"></div>
             </div>
             </div>
             <div class="ranges">
             <div class="ranges">
第243行: 第240行:
                 <span>81-100</span>
                 <span>81-100</span>
             </div>
             </div>
             <div class="comment" id="comment"></div>
             <div class="comment" id="faith-index-comment"></div>
             <p class="footer">* 本结果为娱乐目的,基于名字的随机计算,每次查询结果相同</p>
             <p class="footer">* 本结果为娱乐目的,基于名字的随机计算,每次查询结果相同</p>
         </div>
         </div>
     </div>
     </div>
</div>
<!-- JavaScript logic for the application -->
<script>
    (function() {
        // We wrap the entire script in a function to avoid global scope conflicts.
        const analyzeBtn = document.getElementById('faith-index-analyzeBtn');
        const usernameInput = document.getElementById('faith-index-username');


    <script>
         analyzeBtn.addEventListener('click', function() {
         document.getElementById('analyzeBtn').addEventListener('click', function() {
             const username = usernameInput.value.trim();
             const username = document.getElementById('username').value.trim();
             const resultDiv = document.getElementById('faith-index-result');
             const resultDiv = document.getElementById('result');
              
              
             if (!username) {
             if (!username) {
第261行: 第265行:
             hideError();
             hideError();
              
              
             // 计算信仰指数
             // Calculate the faith index
             const score = calculateFaithIndex(username);
             const score = calculateFaithIndex(username);
              
              
             // 获取评价
             // Get the comment based on the score
             const comment = getFaithComment(score);
             const comment = getFaithComment(score);
              
              
             // 显示结果
             // Display the results
             document.getElementById('resultUsername').textContent = username;
             document.getElementById('faith-index-resultUsername').textContent = username;
             document.getElementById('scoreDisplay').textContent = score + '%';
             document.getElementById('faith-index-scoreDisplay').textContent = score + '%';
             document.getElementById('comment').textContent = comment;
             document.getElementById('faith-index-comment').textContent = comment;
             resultDiv.style.display = 'block';
             resultDiv.style.display = 'block';


             // 延迟设置宽度以触发动画
             // Use a timeout to ensure the CSS transition for the meter fill is visible
             setTimeout(() => {
             setTimeout(() => {
                 document.getElementById('meterFill').style.width = score + '%';
                 document.getElementById('faith-index-meterFill').style.width = score + '%';
             }, 100);
             }, 100);
         });
         });
          
          
         // 确定性算法计算信仰指数(0-100)
         // Deterministic algorithm to calculate faith index (0-100)
         function calculateFaithIndex(username) {
         function calculateFaithIndex(username) {
             let hash = 0;
             let hash = 0;
            if (username.length === 0) return 0;
             for (let i = 0; i < username.length; i++) {
             for (let i = 0; i < username.length; i++) {
                 const char = username.charCodeAt(i);
                 const char = username.charCodeAt(i);
                 hash = ((hash << 5) - hash) + char;
                 hash = ((hash << 5) - hash) + char;
                 hash = hash & hash; // 转换为32位整数
                 hash = hash & hash; // Convert to 32bit integer
             }
             }
             // 将哈希值映射到0-100的范围
             // Map the hash to a range of 0-100
             return Math.abs(hash) % 101;
             return Math.abs(hash) % 101;
         }
         }
          
          
         // 根据分数生成评价
         // Generate a comment based on the score
         function getFaithComment(score) {
         function getFaithComment(score) {
             if (score <= 20) {
             if (score <= 20) {
第306行: 第311行:
         }
         }
          
          
         // 显示错误信息
         // Function to show an error message
         function showError(message) {
         function showError(message) {
             const errorMsg = document.getElementById('errorMsg');
             const errorMsg = document.getElementById('faith-index-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('errorMsg');
             const errorMsg = document.getElementById('faith-index-errorMsg');
             errorMsg.style.display = 'none';
             errorMsg.style.display = 'none';
         }
         }
          
          
         // 按Enter键也可以触发查询
         // Add event listener for the 'Enter' key
         document.getElementById('username').addEventListener('keypress', function(e) {
         usernameInput.addEventListener('keypress', function(e) {
             if (e.key === 'Enter') {
             if (e.key === 'Enter') {
                 document.getElementById('analyzeBtn').click();
                 analyzeBtn.click();
             }
             }
         });
         });
     </script>
     })();
</body>
</script>
</html>
}}
}}

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

返回主页

这里是您的页面内容。