<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="zh-Hans-CN">
	<id>https://soka.cafe/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-faith-index.js</id>
	<title>MediaWiki:Gadget-faith-index.js - 版本历史</title>
	<link rel="self" type="application/atom+xml" href="https://soka.cafe/index.php?action=history&amp;feed=atom&amp;title=MediaWiki%3AGadget-faith-index.js"/>
	<link rel="alternate" type="text/html" href="https://soka.cafe/index.php?title=MediaWiki:Gadget-faith-index.js&amp;action=history"/>
	<updated>2026-04-16T11:22:37Z</updated>
	<subtitle>本wiki上该页面的版本历史</subtitle>
	<generator>MediaWiki 1.41.1</generator>
	<entry>
		<id>https://soka.cafe/index.php?title=MediaWiki:Gadget-faith-index.js&amp;diff=2818&amp;oldid=prev</id>
		<title>Banmad3n：​创建页面，内容为“// MediaWiki:Gadget-faith-index.js (function () {   &#039;use strict&#039;;    // 避免多次初始化   if (window.__faithIndexInit) return;   window.__faithIndexInit = true;    // 在页面就绪时运行（兼容可视化编辑后的局部刷新）   function init($root) {     var container = ($root || document).querySelector(&#039;.faith-index-container&#039;);     if (!container) return;      var analyzeBtn = container.querySelector(&#039;#faith-index-analyzeBtn&#039;);     var userna…”</title>
		<link rel="alternate" type="text/html" href="https://soka.cafe/index.php?title=MediaWiki:Gadget-faith-index.js&amp;diff=2818&amp;oldid=prev"/>
		<updated>2025-10-12T08:43:09Z</updated>

		<summary type="html">&lt;p&gt;创建页面，内容为“// MediaWiki:Gadget-faith-index.js (function () {   &amp;#039;use strict&amp;#039;;    // 避免多次初始化   if (window.__faithIndexInit) return;   window.__faithIndexInit = true;    // 在页面就绪时运行（兼容可视化编辑后的局部刷新）   function init($root) {     var container = ($root || document).querySelector(&amp;#039;.faith-index-container&amp;#039;);     if (!container) return;      var analyzeBtn = container.querySelector(&amp;#039;#faith-index-analyzeBtn&amp;#039;);     var userna…”&lt;/p&gt;
&lt;p&gt;&lt;b&gt;新页面&lt;/b&gt;&lt;/p&gt;&lt;div&gt;// MediaWiki:Gadget-faith-index.js&lt;br /&gt;
(function () {&lt;br /&gt;
  &amp;#039;use strict&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
  // 避免多次初始化&lt;br /&gt;
  if (window.__faithIndexInit) return;&lt;br /&gt;
  window.__faithIndexInit = true;&lt;br /&gt;
&lt;br /&gt;
  // 在页面就绪时运行（兼容可视化编辑后的局部刷新）&lt;br /&gt;
  function init($root) {&lt;br /&gt;
    var container = ($root || document).querySelector(&amp;#039;.faith-index-container&amp;#039;);&lt;br /&gt;
    if (!container) return;&lt;br /&gt;
&lt;br /&gt;
    var analyzeBtn = container.querySelector(&amp;#039;#faith-index-analyzeBtn&amp;#039;);&lt;br /&gt;
    var usernameInput = container.querySelector(&amp;#039;#faith-index-username&amp;#039;);&lt;br /&gt;
&lt;br /&gt;
    function showError(message) {&lt;br /&gt;
      var errorMsg = container.querySelector(&amp;#039;#faith-index-errorMsg&amp;#039;);&lt;br /&gt;
      if (errorMsg) {&lt;br /&gt;
        errorMsg.textContent = message;&lt;br /&gt;
        errorMsg.style.display = &amp;#039;block&amp;#039;;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function hideError() {&lt;br /&gt;
      var errorMsg = container.querySelector(&amp;#039;#faith-index-errorMsg&amp;#039;);&lt;br /&gt;
      if (errorMsg) errorMsg.style.display = &amp;#039;none&amp;#039;;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function calculateFaithIndex(username) {&lt;br /&gt;
      var hash = 0;&lt;br /&gt;
      if (!username || !username.length) return 0;&lt;br /&gt;
      for (var i = 0; i &amp;lt; username.length; i++) {&lt;br /&gt;
        var char = username.charCodeAt(i);&lt;br /&gt;
        hash = ((hash &amp;lt;&amp;lt; 5) - hash) + char;&lt;br /&gt;
        hash = hash &amp;amp; hash; // 32位&lt;br /&gt;
      }&lt;br /&gt;
      return Math.abs(hash) % 101;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function getFaithComment(score) {&lt;br /&gt;
      if (score &amp;lt;= 20) {&lt;br /&gt;
        return &amp;quot;信仰指数较低，信心还需磨练。请多参加活动，加强学习，在广布的道路上继续精进！&amp;quot;;&lt;br /&gt;
      } else if (score &amp;lt;= 40) {&lt;br /&gt;
        return &amp;quot;作为一名初信者，你的信心正在萌芽。坚持每日的实践，你将见证不可思议的功德！&amp;quot;;&lt;br /&gt;
      } else if (score &amp;lt;= 60) {&lt;br /&gt;
        return &amp;quot;信心坚定，是广布的有力实践者。你的存在本身就是胜利的证明，请继续鼓励身边的同志！&amp;quot;;&lt;br /&gt;
      } else if (score &amp;lt;= 80) {&lt;br /&gt;
        return &amp;quot;不愧是池田门生，信心强盛如狮子王！你的祈愿必将实现，继续作为常胜的先驱奋斗吧！&amp;quot;;&lt;br /&gt;
      } else {&lt;br /&gt;
        return &amp;quot;了不起！你拥有佛的生命，是人间革命的先锋。你的生命正在闪耀着最尊贵的光芒！&amp;quot;;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    function runOnce() {&lt;br /&gt;
      var resultDiv = container.querySelector(&amp;#039;#faith-index-result&amp;#039;);&lt;br /&gt;
      var loader = container.querySelector(&amp;#039;#faith-index-loader&amp;#039;);&lt;br /&gt;
      var btnText = container.querySelector(&amp;#039;#faith-index-btnText&amp;#039;);&lt;br /&gt;
      if (!analyzeBtn || !usernameInput) return;&lt;br /&gt;
&lt;br /&gt;
      var username = usernameInput.value.trim();&lt;br /&gt;
      if (!username) {&lt;br /&gt;
        showError(&amp;#039;请输入您的名字！&amp;#039;);&lt;br /&gt;
        if (resultDiv) resultDiv.style.display = &amp;#039;none&amp;#039;;&lt;br /&gt;
        return;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
      hideError();&lt;br /&gt;
&lt;br /&gt;
      // 交互小状态（可选）&lt;br /&gt;
      if (loader) loader.style.display = &amp;#039;inline-block&amp;#039;;&lt;br /&gt;
      if (btnText) btnText.textContent = &amp;#039;计算中...&amp;#039;;&lt;br /&gt;
      analyzeBtn.disabled = true;&lt;br /&gt;
&lt;br /&gt;
      // 计算 &amp;amp; 展示（加入少许延时以便过渡）&lt;br /&gt;
      setTimeout(function () {&lt;br /&gt;
        var score = calculateFaithIndex(username);&lt;br /&gt;
        var comment = getFaithComment(score);&lt;br /&gt;
&lt;br /&gt;
        container.querySelector(&amp;#039;#faith-index-resultUsername&amp;#039;).textContent = username;&lt;br /&gt;
        container.querySelector(&amp;#039;#faith-index-scoreDisplay&amp;#039;).textContent = score + &amp;#039;%&amp;#039;;&lt;br /&gt;
        container.querySelector(&amp;#039;#faith-index-comment&amp;#039;).textContent = comment;&lt;br /&gt;
        if (resultDiv) resultDiv.style.display = &amp;#039;block&amp;#039;;&lt;br /&gt;
&lt;br /&gt;
        setTimeout(function () {&lt;br /&gt;
          var meterFill = container.querySelector(&amp;#039;#faith-index-meterFill&amp;#039;);&lt;br /&gt;
          if (meterFill) meterFill.style.width = score + &amp;#039;%&amp;#039;;&lt;br /&gt;
        }, 100);&lt;br /&gt;
&lt;br /&gt;
        if (loader) loader.style.display = &amp;#039;none&amp;#039;;&lt;br /&gt;
        if (btnText) btnText.textContent = &amp;#039;开始测试&amp;#039;;&lt;br /&gt;
        analyzeBtn.disabled = false;&lt;br /&gt;
      }, 200);&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    analyzeBtn &amp;amp;&amp;amp; analyzeBtn.addEventListener(&amp;#039;click&amp;#039;, runOnce);&lt;br /&gt;
    usernameInput &amp;amp;&amp;amp; usernameInput.addEventListener(&amp;#039;keypress&amp;#039;, function (e) {&lt;br /&gt;
      if (e.key === &amp;#039;Enter&amp;#039;) runOnce();&lt;br /&gt;
    });&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  if (window.mw &amp;amp;&amp;amp; mw.hook) {&lt;br /&gt;
    mw.hook(&amp;#039;wikipage.content&amp;#039;).add(function ($content) {&lt;br /&gt;
      // $content 可能是 jQuery 对象或原生节点&lt;br /&gt;
      var root = $content &amp;amp;&amp;amp; $content[0] ? $content[0] : document;&lt;br /&gt;
      init(root);&lt;br /&gt;
    });&lt;br /&gt;
  } else {&lt;br /&gt;
    // 兜底（极简环境）&lt;br /&gt;
    document.addEventListener(&amp;#039;DOMContentLoaded&amp;#039;, function () { init(document); });&lt;br /&gt;
  }&lt;br /&gt;
})();&lt;/div&gt;</summary>
		<author><name>Banmad3n</name></author>
	</entry>
</feed>