MediaWiki:Common.js:修订间差异

来自赛尔号精灵图鉴
跳转到导航 跳转到搜索
无编辑摘要
标签已被回退
无编辑摘要
标签已被回退
第8行: 第8行:
});
});


document.addEventListener("DOMContentLoaded", function () {
<style>
    function calc2() {
.stat-calc {
        const level = parseInt(document.getElementsByName("level2")[0].value || 100);
  background: rgba(255,255,255,0.8);
        const iv = parseInt(document.getElementsByName("geti")[0].value || 31);
  padding: 15px;
        const evs = document.getElementsByName("nvli2");
  border-radius: 10px;
        const bases = document.querySelectorAll("._race2");
  max-width: 600px;
        const resultSpans = document.querySelectorAll("._result2");
  margin: 0 auto;
        const c2s = document.getElementsByName("_c2");
  font-family: sans-serif;
 
}
        for (let i = 0; i < 6; i++) {
.config-block {
            const base = parseInt(bases[i].textContent || "0");
  display: flex;
            const ev = parseInt(evs[i].value || 0);
  flex-wrap: wrap;
            const nature = parseFloat(c2s[i]?.value || "1.0");
  gap: 10px;
 
  align-items: center;
            let stat = 0;
  margin-bottom: 10px;
            if (i === 0) {
}
                stat = Math.floor(((base * 2 + iv + Math.floor(ev / 4)) * level) / 100 + level + 10);
.config-block label {
            } else {
  display: flex;
                stat = Math.floor((((base * 2 + iv + Math.floor(ev / 4)) * level) / 100 + 5) * nature);
  flex-direction: column;
            }
  font-size: 14px;
 
}
            resultSpans[i].textContent = stat;
.stat-table {
        }
  width: 100%;
    }
  border-collapse: collapse;
 
  margin-top: 10px;
    const inputs = document.querySelectorAll("input, select");
}
    inputs.forEach(el => el.addEventListener("input", calc2));
.stat-table th, .stat-table td {
    inputs.forEach(el => el.addEventListener("change", calc2));
  border: 1px solid #ccc;
    calc2();
  padding: 5px;
});
  text-align: center;
}
.stat-table input {
  width: 60px;
}
.result {
  font-weight: bold;
  color: #FF6600;
}
#calc-btn {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}
#calc-btn:hover {
  background: #45a049;
}
</style>

2025年5月10日 (六) 16:35的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
$(function () {
  // 只在条目页面生效,不影响首页/编辑页等
  if (mw.config.get("wgNamespaceNumber") === 0) {
    $('<a href="/index.php/首页" id="return-home-button">← 返回首页</a>')
      .appendTo('body');
  }
});

<style>
.stat-calc {
  background: rgba(255,255,255,0.8);
  padding: 15px;
  border-radius: 10px;
  max-width: 600px;
  margin: 0 auto;
  font-family: sans-serif;
}
.config-block {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.config-block label {
  display: flex;
  flex-direction: column;
  font-size: 14px;
}
.stat-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}
.stat-table th, .stat-table td {
  border: 1px solid #ccc;
  padding: 5px;
  text-align: center;
}
.stat-table input {
  width: 60px;
}
.result {
  font-weight: bold;
  color: #FF6600;
}
#calc-btn {
  background: #4CAF50;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
}
#calc-btn:hover {
  background: #45a049;
}
</style>
👥 当前在线人数:65