打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
创建页面,内容为“这里的任何JavaScript将为所有用户在每次页面加载时加载。:​ function togglePronunciationMode() { const chao = document.getElementById("pron-chao"); const ipa = document.getElementById("pron-ipa"); const btn = document.querySelector(".toggle-wrapper button"); if (chao.style.display === "none") { chao.style.display = ""; ipa.style.display = "none"; btn.textContent = "切换为 IPA"; } else { chao.style.display = "…”
 
无编辑摘要
 
(未显示同一用户的1个中间版本)
第1行: 第1行:
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
function togglePronunciationMode() {
mw.hook("wikipage.content").add(function () {
  const btn = document.querySelector(".toggle-pronunciation-btn");
   const chao = document.getElementById("pron-chao");
   const chao = document.getElementById("pron-chao");
   const ipa = document.getElementById("pron-ipa");
   const ipa = document.getElementById("pron-ipa");
  const btn = document.querySelector(".toggle-wrapper button");


   if (chao.style.display === "none") {
   if (!btn || !chao || !ipa) return;
    chao.style.display = "";
 
    ipa.style.display = "none";
  btn.addEventListener("click", function () {
    btn.textContent = "切换为 IPA";
    const showingIPA = ipa.style.display !== "none";
  } else {
 
    chao.style.display = "none";
    if (showingIPA) {
    ipa.style.display = "";
      ipa.style.display = "none";
    btn.textContent = "切换为潮拼";
      chao.style.display = "";
   }
      btn.textContent = "切换为 IPA";
}
    } else {
      ipa.style.display = "";
      chao.style.display = "none";
      btn.textContent = "切换为潮拼";
    }
   });
});

2025年7月10日 (四) 06:21的最新版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
mw.hook("wikipage.content").add(function () {
  const btn = document.querySelector(".toggle-pronunciation-btn");
  const chao = document.getElementById("pron-chao");
  const ipa = document.getElementById("pron-ipa");

  if (!btn || !chao || !ipa) return;

  btn.addEventListener("click", function () {
    const showingIPA = ipa.style.display !== "none";

    if (showingIPA) {
      ipa.style.display = "none";
      chao.style.display = "";
      btn.textContent = "切换为 IPA";
    } else {
      ipa.style.display = "";
      chao.style.display = "none";
      btn.textContent = "切换为潮拼";
    }
  });
});