信仰指数:修订间差异

来自SOKA CAFE
こばと
こばと留言 | 贡献 (修改)
こばと
こばと留言 | 贡献 (修改)
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
{{全屏|
<html>
<html>
<head>
<head>
<style>
    <meta charset="UTF-8">
.faith-index-body {
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
  background: linear-gradient(135deg, #0052a5 0%, #f9e300 50%, #d40000 100%);
    <title>信仰指数测试</title>
  min-height: 90vh;
    <style>
  display: flex;
        /* ---- styles (scoped by .faith-index-*) ---- */
  justify-content: center;
        body, html { margin: 0; padding: 0; }
  align-items: center;
        .faith-index-body{background:linear-gradient(135deg,#0052a5 0%,#f9e300 50%,#d40000 100%);min-height:100vh;display:flex;justify-content:center;align-items:center;padding:20px;font-family:'Segoe UI','Microsoft YaHei',sans-serif;box-sizing:border-box;}
  padding: 20px;
        .faith-index-container{background:rgba(255,255,255,.25);backdrop-filter:blur(12px);border-radius:20px;padding:40px;width:100%;max-width:500px;box-shadow:0 8px 32px rgba(0,0,0,.1);border:1px solid rgba(255,255,255,.4);text-align:center;margin:0 auto}
  font-family: 'Segoe UI','Microsoft YaHei',sans-serif;
        .faith-index-container h1{color:#2c3e50;margin-bottom:10px;font-size:2.2rem;font-weight:600}
}
        .faith-index-container .subtitle{color:#34495e;margin-bottom:30px;font-size:1rem}
 
        .faith-index-container .input-group{margin-bottom:25px;text-align:left}
.faith-index-container {
        .faith-index-container label{display:block;color:#2c3e50;margin-bottom:8px;font-weight:500}
  background: rgba(255,255,255,0.25);
        .faith-index-container input{width:100%;padding:15px;border-radius:12px;border:none;background:rgba(255,255,255,.5);color:#2c3e50;font-size:1rem;transition:all .3s ease;border:1px solid rgba(255,255,255,.5);box-sizing:border-box}
  backdrop-filter: blur(12px);
        .faith-index-container input:focus{outline:none;background:rgba(255,255,255,.7);box-shadow:0 0 0 3px rgba(44,62,80,.2)}
  border-radius: 20px;
        .faith-index-container button{background:linear-gradient(to right,#34495e,#2c3e50);color:#fff;border:none;padding:15px 30px;border-radius:12px;font-size:1.1rem;font-weight:600;cursor:pointer;transition:all .3s ease;width:100%;margin-top:10px;box-shadow:0 5px 15px rgba(44,62,80,.3);display:flex;justify-content:center;align-items:center;gap:10px}
  padding: 40px;
        .faith-index-container button:hover{transform:translateY(-3px);box-shadow:0 8px 20px rgba(44,62,80,.4)}
  width: 100%;
        .faith-index-container button:active{transform:translateY(0)}
  max-width: 500px;
        .faith-index-container button[disabled]{opacity:.7;cursor:not-allowed;transform:none}
  box-shadow: 0 8px 32px rgba(0,0,0,0.1);
        .faith-index-container .loader{width:20px;height:20px;border:2px solid rgba(255,255,255,.3);border-radius:50%;border-top:2px solid #fff;animation:faith-index-spin 1s linear infinite}
  border: 1px solid rgba(255,255,255,0.4);
        @keyframes faith-index-spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}
  text-align: center;
        .faith-index-container .result{margin-top:30px;padding:25px;border-radius:15px;background:rgba(255,255,255,.3);display:none;animation:faith-index-fadeIn .5s ease}
  margin: 0 auto;
        @keyframes faith-index-fadeIn{from{opacity:0;transform:translateY(10px)}to{opacity:1;transform:translateY(0)}}
}
        .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,.4);text-align:left;line-height:1.5}
.faith-index-container h1 {
        .faith-index-container .meter{height:20px;background:rgba(0,0,0,.1);border-radius:10px;margin:20px 0;overflow:hidden}
  color: #2c3e50;
        .faith-index-container .meter-fill{height:100%;border-radius:10px;transition:width 1s ease;background:linear-gradient(to right,#0052a5,#f9e300,#d40000)}
  margin-bottom: 10px;
        .faith-index-container .ranges{display:flex;justify-content:space-between;margin-top:10px;color:#34495e;font-size:.85rem}
  font-size: 2.2rem;
        .faith-index-container .footer{margin-top:30px;color:#34495e;font-size:.9rem}
  font-weight: 600;
        .faith-index-container .error{color:#d9534f;background:rgba(217,83,79,.1);padding:10px;border-radius:8px;margin-top:10px;display:none}
}
    </style>
 
.faith-index-container .subtitle {
  color: #34495e;
  margin-bottom: 30px;
  font-size: 1rem;
}
 
.faith-index-container .input-group { margin-bottom: 25px; text-align: left; }
 
.faith-index-container label {
  display: block;
  color: #2c3e50;
  margin-bottom: 8px;
  font-weight: 500;
}
 
.faith-index-container input {
  width: 100%;
  padding: 15px;
  border-radius: 12px;
  border: none;
  background: rgba(255,255,255,0.5);
  color: #2c3e50;
  font-size: 1rem;
  transition: all 0.3s ease;
  border: 1px solid rgba(255,255,255,0.5);
  box-sizing: border-box;
}
 
.faith-index-container input:focus {
  outline: none;
  background: rgba(255,255,255,0.7);
  box-shadow: 0 0 0 3px rgba(44,62,80,0.2);
}
 
.faith-index-container button {
  background: linear-gradient(to right, #34495e, #2c3e50);
  color: #fff;
  border: none;
  padding: 15px 30px;
  border-radius: 12px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  width: 100%;
  margin-top: 10px;
  box-shadow: 0 5px 15px rgba(44,62,80,0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}
 
.faith-index-container button:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(44,62,80,0.4);
}
 
.faith-index-container button:active { transform: translateY(0); }
 
.faith-index-container button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}
 
.faith-index-container .loader {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 50%;
  border-top: 2px solid #fff;
  animation: faith-index-spin 1s linear infinite;
}
 
@keyframes faith-index-spin {
  0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); }
}
 
.faith-index-container .result {
  margin-top: 30px;
  padding: 25px;
  border-radius: 15px;
  background: rgba(255,255,255,0.3);
  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 .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;
}
</style>
</head>
</head>
<body>
<body>
<div class="faith-index-body">
  <div class="faith-index-container">
    <h1>信仰指数测试</h1>
    <p class="subtitle">测测你的信仰有多虔诚</p>


     <div class="input-group">
     <div class="fi-root">
      <label for="faith-index-username">请输入您的名字:</label>
        <div class="faith-index-body">
      <input type="text" id="faith-index-username" placeholder="输入名字..." autocomplete="off">
            <div class="faith-index-container">
                <h1>信仰指数测试</h1>
                <p class="subtitle">测测你的信仰有多虔诚</p>
                <div class="input-group">
                    <label>请输入您的名字:</label>
                    <input class="fi-input" type="text" placeholder="输入名字..." autocomplete="off">
                </div>
                <button type="button" class="fi-btn">
                    <span class="fi-btn-text">开始测试</span>
                    <div class="loader fi-loader" style="display:none;"></div>
                </button>
                <div class="error fi-error" style="display:none;"></div>
                <div class="result fi-result" style="display:none;">
                    <h2>测试结果</h2>
                    <p>姓名: <span class="fi-name"></span></p>
                    <div class="score fi-score">0%</div>
                    <div class="meter"><div class="meter-fill fi-meter" style="width:0%"></div></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 class="comment fi-comment"></div>
                    <p class="footer">* 本结果为娱乐目的,基于名字的随机计算,每次查询结果相同</p>
                </div>
            </div>
        </div>
     </div>
     </div>


     <button id="faith-index-analyzeBtn">
     <script type="text/javascript">
      <span id="faith-index-btnText">开始测试</span>
        (function(){
      <div class="loader" id="faith-index-loader" style="display:none;"></div>
            // Find the root element to scope our DOM queries
    </button>
            var root = document.querySelector('.fi-root');
            if (!root) return;


    <div class="error" id="faith-index-errorMsg"></div>
            // Select all elements within the root
 
            var input  = root.querySelector('.fi-input');
     <div class="result" id="faith-index-result">
            var btn     = root.querySelector('.fi-btn');
      <h2>测试结果</h2>
            var btnTxt  = root.querySelector('.fi-btn-text');
      <p>姓名: <span id="faith-index-resultUsername"></span></p>
            var loader  = root.querySelector('.fi-loader');
      <div class="score" id="faith-index-scoreDisplay">0%</div>
            var result  = root.querySelector('.fi-result');
      <div class="meter"><div class="meter-fill" id="faith-index-meterFill" style="width:0%;"></div></div>
            var error  = root.querySelector('.fi-error');
      <div class="ranges"><span>0-20</span><span>21-40</span><span>41-60</span><span>61-80</span><span>81-100</span></div>
            var nameEl  = root.querySelector('.fi-name');
      <div class="comment" id="faith-index-comment"></div>
            var scoreEl = root.querySelector('.fi-score');
      <p class="footer">* 本结果为娱乐目的,基于名字的随机计算,每次查询结果相同</p>
            var cmtEl  = root.querySelector('.fi-comment');
    </div>
            var meter  = root.querySelector('.fi-meter');
  </div>
</div>


<script>
            // Logic functions
document.addEventListener('DOMContentLoaded', () => {
            function calculateFaithIndex(name){
  const analyzeBtn = document.getElementById('faith-index-analyzeBtn');
                var hash = 0, i, ch;
  const usernameInput = document.getElementById('faith-index-username');
                if (!name) return 0;
  const resultDiv = document.getElementById('faith-index-result');
                for (i = 0; i < name.length; i++){
  const loader = document.getElementById('faith-index-loader');
                    ch = name.charCodeAt(i);
  const btnText = document.getElementById('faith-index-btnText');
                    hash = ((hash << 5) - hash) + ch;
  const errorMsg = document.getElementById('faith-index-errorMsg');
                    hash = hash | 0;
                }
                return Math.abs(hash) % 101;
            }


  function calculateFaithIndex(username) {
            function getFaithComment(score){
    let hash = 0;
                if (score <= 20) return "信仰指数较低,信心还需磨练。请多参加活动,加强学习,在广布的道路上继续精进!";
    if (username.length === 0) return 0;
                if (score <= 40) return "作为一名初信者,你的信心正在萌芽。坚持每日的实践,你将见证不可思议的功德!";
    for (let i = 0; i < username.length; i++) {
                if (score <= 60) return "信心坚定,是广布的有力实践者。你的存在本身就是胜利的证明,请继续鼓励身边的同志!";
      const char = username.charCodeAt(i);
                if (score <= 80) return "不愧是池田门生,信心强盛如狮子王!你的祈愿必将实现,继续作为常胜的先驱奋斗吧!";
      hash = ((hash << 5) - hash) + char;
                return "了不起!你拥有佛的生命,是人间革命的先锋。你的生命正在闪耀着最尊贵的光芒!";
      hash = hash & hash;
            }
    }
    return Math.abs(hash) % 101;
  }


  function getFaithComment(score) {
            function showError(msg){ if(!error) return; error.textContent = msg; error.style.display = 'block'; }
    if (score <= 20) return "信仰指数较低,信心还需磨练。请多参加活动,加强学习,在广布的道路上继续精进!";
            function hideError(){ if(error) error.style.display = 'none'; }
    if (score <= 40) return "作为一名初信者,你的信心正在萌芽。坚持每日的实践,你将见证不可思议的功德!";
    if (score <= 60) return "信心坚定,是广布的有力实践者。你的存在本身就是胜利的证明,请继续鼓励身边的同志!";
    if (score <= 80) return "不愧是池田门生,信心强盛如狮子王!你的祈愿必将实现,继续作为常胜的先驱奋斗吧!";
    return "了不起!你拥有佛的生命,是人间革命的先锋。你的生命正在闪耀着最尊贵的光芒!";
  }


  function showError(msg) {
            function runTest(){
    errorMsg.textContent = msg;
                var username = (input.value || '').trim();
    errorMsg.style.display = 'block';
                if (!username){
  }
                    showError('请输入您的名字!');
  function hideError() { errorMsg.style.display = 'none'; }
                    result.style.display = 'none';
                    return;
                }
                hideError();
                loader.style.display = 'inline-block';
                btnTxt.textContent = '计算中...';
                btn.disabled = true;


  function runTest() {
                setTimeout(function(){
    const username = usernameInput.value.trim();
                    try {
    if (!username) {
                        var score = calculateFaithIndex(username);
      showError('请输入您的名字!');
                        nameEl.textContent  = username;
      resultDiv.style.display = 'none';
                        scoreEl.textContent = score + '%';
      return;
                        cmtEl.textContent  = getFaithComment(score);
    }
                        result.style.display = 'block';
    hideError();
                        setTimeout(function(){ meter.style.width = score + '%'; }, 60);
    loader.style.display = 'inline-block';
                    } finally {
    btnText.textContent = '计算中...';
                        loader.style.display = 'none';
    analyzeBtn.disabled = true;
                        btnTxt.textContent = '开始测试';
                        btn.disabled = false;
                    }
                }, 800);
            }


    setTimeout(() => {
            // Event listeners
      const score = calculateFaithIndex(username);
            btn.addEventListener('click', runTest);
      const comment = getFaithComment(score);
            input.addEventListener('keydown', function(e){ if (e.key === 'Enter') runTest(); });
      document.getElementById('faith-index-resultUsername').textContent = username;
        })();
      document.getElementById('faith-index-scoreDisplay').textContent = score + '%';
    </script>
      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);
  }


  analyzeBtn.addEventListener('click', runTest);
  usernameInput.addEventListener('keypress', e => { if (e.key === 'Enter') runTest(); });
});
</script>
</body>
</body>
</html>
</html>
}}

2025年10月12日 (日) 16:49的最新版本

返回主页

信仰指数测试

信仰指数测试

测测你的信仰有多虔诚