信仰指数:修订间差异

来自SOKA CAFE
こばと
こばと留言 | 贡献 (修改)
こばと
こばと留言 | 贡献 (修改)
第1行: 第1行:
{{全屏|
<html>
<html>
<head>
<style>
<style>
    /*
.faith-index-body {
      The container styling is slightly adjusted to work better in a wiki context.
  background: linear-gradient(135deg, #0052a5 0%, #f9e300 50%, #d40000 100%);
      Using a class name like 'faith-index-container' avoids potential conflicts
  min-height: 90vh;
      with MediaWiki's own styles.
  display: flex;
    */
  justify-content: center;
    .faith-index-body {
  align-items: center;
        background: linear-gradient(135deg, #0052a5 0%, #f9e300 50%, #d40000 100%);
  padding: 20px;
        min-height: 90vh; /* Use vh for viewport height */
  font-family: 'Segoe UI','Microsoft YaHei',sans-serif;
        display: flex;
}
        justify-content: center;
 
        align-items: center;
.faith-index-container {
        padding: 20px;
  background: rgba(255,255,255,0.25);
        font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  backdrop-filter: blur(12px);
    }
  border-radius: 20px;
   
  padding: 40px;
    .faith-index-container {
  width: 100%;
        background: rgba(255, 255, 255, 0.25);
  max-width: 500px;
        backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
        border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.4);
        padding: 40px;
  text-align: center;
        width: 100%;
  margin: 0 auto;
        max-width: 500px;
}
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
 
        border: 1px solid rgba(255, 255, 255, 0.4);
.faith-index-container h1 {
        text-align: center;
  color: #2c3e50;
        margin: 0 auto; /* Center the container */
  margin-bottom: 10px;
    }
  font-size: 2.2rem;
   
  font-weight: 600;
    .faith-index-container 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;
   
}
    .faith-index-container .subtitle {
 
        color: #34495e;
.faith-index-container .input-group { margin-bottom: 25px; text-align: left; }
        margin-bottom: 30px;
 
        font-size: 1rem;
.faith-index-container label {
    }
  display: block;
   
  color: #2c3e50;
    .faith-index-container .input-group {
  margin-bottom: 8px;
        margin-bottom: 25px;
  font-weight: 500;
        text-align: left;
}
    }
 
   
.faith-index-container input {
    .faith-index-container label {
  width: 100%;
        display: block;
  padding: 15px;
        color: #2c3e50;
  border-radius: 12px;
        margin-bottom: 8px;
  border: none;
        font-weight: 500;
  background: rgba(255,255,255,0.5);
    }
  color: #2c3e50;
   
  font-size: 1rem;
    .faith-index-container input {
  transition: all 0.3s ease;
        width: 100%;
  border: 1px solid rgba(255,255,255,0.5);
        padding: 15px;
  box-sizing: border-box;
        border-radius: 12px;
}
        border: none;
 
        background: rgba(255, 255, 255, 0.5);
.faith-index-container input:focus {
        color: #2c3e50;
  outline: none;
        font-size: 1rem;
  background: rgba(255,255,255,0.7);
        transition: all 0.3s ease;
  box-shadow: 0 0 0 3px rgba(44,62,80,0.2);
        border: 1px solid rgba(255, 255, 255, 0.5);
}
        box-sizing: border-box; /* Important for wiki compatibility */
 
    }
.faith-index-container button {
   
  background: linear-gradient(to right, #34495e, #2c3e50);
    .faith-index-container input:focus {
  color: #fff;
        outline: none;
  border: none;
        background: rgba(255, 255, 255, 0.7);
  padding: 15px 30px;
        box-shadow: 0 0 0 3px rgba(44, 62, 80, 0.2);
  border-radius: 12px;
    }
  font-size: 1.1rem;
   
  font-weight: 600;
    .faith-index-container button {
  cursor: pointer;
        background: linear-gradient(to right, #34495e, #2c3e50);
  transition: all 0.3s ease;
        color: white;
  width: 100%;
        border: none;
  margin-top: 10px;
        padding: 15px 30px;
  box-shadow: 0 5px 15px rgba(44,62,80,0.3);
        border-radius: 12px;
  display: flex;
        font-size: 1.1rem;
  justify-content: center;
        font-weight: 600;
  align-items: center;
        cursor: pointer;
  gap: 10px;
        transition: all 0.3s ease;
}
        width: 100%;
 
        margin-top: 10px;
.faith-index-container button:hover {
        box-shadow: 0 5px 15px rgba(44, 62, 80, 0.3);
  transform: translateY(-3px);
        display: flex;
  box-shadow: 0 8px 20px rgba(44,62,80,0.4);
        justify-content: center;
}
        align-items: center;
 
        gap: 10px;
.faith-index-container button:active { transform: translateY(0); }
    }
 
   
.faith-index-container button:disabled {
    .faith-index-container button:hover {
  opacity: 0.7;
        transform: translateY(-3px);
  cursor: not-allowed;
        box-shadow: 0 8px 20px rgba(44, 62, 80, 0.4);
  transform: none;
    }
}
   
 
    .faith-index-container button:active {
.faith-index-container .loader {
        transform: translateY(0);
  width: 20px;
    }
  height: 20px;
   
  border: 2px solid rgba(255,255,255,0.3);
    .faith-index-container button:disabled {
  border-radius: 50%;
        opacity: 0.7;
  border-top: 2px solid #fff;
        cursor: not-allowed;
  animation: faith-index-spin 1s linear infinite;
        transform: none;
}
    }
 
   
@keyframes faith-index-spin {
    .faith-index-container .loader {
  0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); }
        width: 20px;
}
        height: 20px;
 
        border: 2px solid rgba(255, 255, 255, 0.3);
.faith-index-container .result {
        border-radius: 50%;
  margin-top: 30px;
        border-top: 2px solid white;
  padding: 25px;
        animation: faith-index-spin 1s linear infinite;
  border-radius: 15px;
    }
  background: rgba(255,255,255,0.3);
   
  display: none;
    @keyframes faith-index-spin {
  animation: faith-index-fadeIn 0.5s ease;
        0% { transform: rotate(0deg); }
}
        100% { transform: rotate(360deg); }
 
    }
@keyframes faith-index-fadeIn {
   
  from { opacity: 0; transform: translateY(10px); }
    .faith-index-container .result {
  to { opacity: 1; transform: translateY(0); }
        margin-top: 30px;
}
        padding: 25px;
 
        border-radius: 15px;
.faith-index-container .score {
        background: rgba(255, 255, 255, 0.3);
  font-size: 3.5rem;
        display: none;
  font-weight: 800;
        animation: faith-index-fadeIn 0.5s ease;
  margin: 15px 0;
    }
  color: #2c3e50;
   
}
    @keyframes faith-index-fadeIn {
 
        from { opacity: 0; transform: translateY(10px); }
.faith-index-container .comment {
        to { opacity: 1; transform: translateY(0); }
  font-size: 1.2rem;
    }
  color: #2c3e50;
   
  margin: 15px 0;
    .faith-index-container .result h2 {
  padding: 15px;
        color: #2c3e50;
  border-radius: 10px;
        margin-bottom: 15px;
  background: rgba(255,255,255,0.4);
    }
  text-align: left;
   
  line-height: 1.5;
    .faith-index-container .score {
}
        font-size: 3.5rem;
 
        font-weight: 800;
.faith-index-container .meter {
        margin: 15px 0;
  height: 20px;
        color: #2c3e50;
  background: rgba(0,0,0,0.1);
    }
  border-radius: 10px;
   
  margin: 20px 0;
    .faith-index-container .comment {
  overflow: hidden;
        font-size: 1.2rem;
}
        color: #2c3e50;
 
        margin: 15px 0;
.faith-index-container .meter-fill {
        padding: 15px;
  height: 100%;
        border-radius: 10px;
  border-radius: 10px;
        background: rgba(255, 255, 255, 0.4);
  transition: width 1s ease;
        text-align: left;
  background: linear-gradient(to right, #0052a5, #f9e300, #d40000);
        line-height: 1.5;
}
    }
 
   
.faith-index-container .ranges {
    .faith-index-container .meter {
  display: flex;
        height: 20px;
  justify-content: space-between;
        background: rgba(0, 0, 0, 0.1);
  margin-top: 10px;
        border-radius: 10px;
  color: #34495e;
        margin: 20px 0;
  font-size: 0.85rem;
        overflow: hidden;
}
    }
 
   
.faith-index-container .footer { margin-top: 30px; color: #34495e; font-size: 0.9rem; }
    .faith-index-container .meter-fill {
 
        height: 100%;
.faith-index-container .error {
        border-radius: 10px;
  color: #d9534f;
        transition: width 1s ease;
  background: rgba(217,83,79,0.1);
        background: linear-gradient(to right, #0052a5, #f9e300, #d40000);
  padding: 10px;
    }
  border-radius: 8px;
   
  margin-top: 10px;
    .faith-index-container .ranges {
  display: none;
        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;
        }
       
        .faith-index-container h1 {
            font-size: 1.8rem;
        }
    }
</style>
</style>
</head>


<!-- HTML structure for the application -->
<body>
<div class="faith-index-body">
<div class="faith-index-body">
    <div class="faith-index-container">
  <div class="faith-index-container">
        <h1>信仰指数测试</h1>
    <h1>信仰指数测试</h1>
        <p class="subtitle">测测你的信仰有多虔诚</p>
    <p class="subtitle">测测你的信仰有多虔诚</p>
       
 
        <div class="input-group">
    <div class="input-group">
            <label for="faith-index-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>
       
 
        <button id="faith-index-analyzeBtn">
    <button id="faith-index-analyzeBtn">
            <span id="faith-index-btnText">开始测试</span>
      <span id="faith-index-btnText">开始测试</span>
            <div class="loader" id="faith-index-loader" style="display: none;"></div>
      <div class="loader" id="faith-index-loader" style="display:none;"></div>
        </button>
    </button>
       
 
        <div class="error" id="faith-index-errorMsg"></div>
    <div class="error" id="faith-index-errorMsg"></div>
       
 
        <div class="result" id="faith-index-result">
    <div class="result" id="faith-index-result">
            <h2>测试结果</h2>
      <h2>测试结果</h2>
            <p>姓名: <span id="faith-index-resultUsername"></span></p>
      <p>姓名: <span id="faith-index-resultUsername"></span></p>
            <div class="score" id="faith-index-scoreDisplay">0%</div>
      <div class="score" id="faith-index-scoreDisplay">0%</div>
            <div class="meter">
      <div class="meter"><div class="meter-fill" id="faith-index-meterFill" style="width:0%;"></div></div>
                <div class="meter-fill" id="faith-index-meterFill" style="width: 0%;"></div>
      <div class="ranges"><span>0-20</span><span>21-40</span><span>41-60</span><span>61-80</span><span>81-100</span></div>
            </div>
      <div class="comment" id="faith-index-comment"></div>
            <div class="ranges">
      <p class="footer">* 本结果为娱乐目的,基于名字的随机计算,每次查询结果相同</p>
                <span>0-20</span>
                <span>21-40</span>
                <span>41-60</span>
                <span>61-80</span>
                <span>81-100</span>
            </div>
            <div class="comment" id="faith-index-comment"></div>
            <p class="footer">* 本结果为娱乐目的,基于名字的随机计算,每次查询结果相同</p>
        </div>
     </div>
     </div>
  </div>
</div>
</div>


<!-- 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', () => {
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');
  const resultDiv = document.getElementById('faith-index-result');
  const loader = document.getElementById('faith-index-loader');
  const btnText = document.getElementById('faith-index-btnText');
  const errorMsg = document.getElementById('faith-index-errorMsg');


    if (analyzeBtn && usernameInput) {
  function calculateFaithIndex(username) {
        analyzeBtn.addEventListener('click', function() {
    let hash = 0;
            const username = usernameInput.value.trim();
    if (username.length === 0) return 0;
            const resultDiv = document.getElementById('faith-index-result');
    for (let i = 0; i < username.length; i++) {
           
      const char = username.charCodeAt(i);
            if (!username) {
      hash = ((hash << 5) - hash) + char;
                showError('请输入您的名字!');
      hash = hash & hash;
                if(resultDiv) resultDiv.style.display = 'none';
    }
                return;
    return Math.abs(hash) % 101;
            }
  }
           
            hideError();
           
            // Calculate the faith index
            const score = calculateFaithIndex(username);
           
            // Get the comment based on the score
            const comment = getFaithComment(score);
           
            // Display the results
            document.getElementById('faith-index-resultUsername').textContent = username;
            document.getElementById('faith-index-scoreDisplay').textContent = score + '%';
            document.getElementById('faith-index-comment').textContent = comment;
            if(resultDiv) resultDiv.style.display = 'block';


            // Use a timeout to ensure the CSS transition for the meter fill is visible
  function getFaithComment(score) {
            setTimeout(() => {
    if (score <= 20) return "信仰指数较低,信心还需磨练。请多参加活动,加强学习,在广布的道路上继续精进!";
                const meterFill = document.getElementById('faith-index-meterFill');
    if (score <= 40) return "作为一名初信者,你的信心正在萌芽。坚持每日的实践,你将见证不可思议的功德!";
                if(meterFill) meterFill.style.width = score + '%';
    if (score <= 60) return "信心坚定,是广布的有力实践者。你的存在本身就是胜利的证明,请继续鼓励身边的同志!";
            }, 100);
    if (score <= 80) return "不愧是池田门生,信心强盛如狮子王!你的祈愿必将实现,继续作为常胜的先驱奋斗吧!";
        });
    return "了不起!你拥有佛的生命,是人间革命的先锋。你的生命正在闪耀着最尊贵的光芒!";
       
  }
        // Add event listener for the 'Enter' key
 
        usernameInput.addEventListener('keypress', function(e) {
  function showError(msg) {
            if (e.key === 'Enter') {
    errorMsg.textContent = msg;
                analyzeBtn.click();
     errorMsg.style.display = 'block';
            }
  }
        });
  function hideError() { errorMsg.style.display = 'none'; }
    }
 
   
  function runTest() {
    function calculateFaithIndex(username) {
    const username = usernameInput.value.trim();
        let hash = 0;
    if (!username) {
        if (username.length === 0) return 0;
      showError('请输入您的名字!');
        for (let i = 0; i < username.length; i++) {
      resultDiv.style.display = 'none';
            const char = username.charCodeAt(i);
      return;
            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.style.display = 'block';
        }
     }
     }
    hideError();
    loader.style.display = 'inline-block';
    btnText.textContent = '计算中...';
    analyzeBtn.disabled = true;
    setTimeout(() => {
      const score = calculateFaithIndex(username);
      const comment = getFaithComment(score);
      document.getElementById('faith-index-resultUsername').textContent = username;
      document.getElementById('faith-index-scoreDisplay').textContent = score + '%';
      document.getElementById('faith-index-comment').textContent = comment;
      resultDiv.style.display = 'block';
      setTimeout(() => {
        document.getElementById('faith-index-meterFill').style.width = score + '%';
      }, 100);
      loader.style.display = 'none';
      btnText.textContent = '开始测试';
      analyzeBtn.disabled = false;
    }, 200);
  }


    function hideError() {
  analyzeBtn.addEventListener('click', runTest);
        const errorMsg = document.getElementById('faith-index-errorMsg');
  usernameInput.addEventListener('keypress', e => { if (e.key === 'Enter') runTest(); });
        if (errorMsg) {
            errorMsg.style.display = 'none';
        }
    }
});
});
</script>
</script>
</body>
</html>
</html>
}}

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

信仰指数测试

测测你的信仰有多虔诚

测试结果

姓名:

0%
0-2021-4041-6061-8081-100