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

MediaWiki:Common.js:修订间差异

MediaWiki界面页面
无编辑摘要
无编辑摘要
第24行: 第24行:
   );
   );
}
}


// 检查 mw 对象是否存在
// 检查 mw 对象是否存在
if (typeof mw !== 'undefined') {
if (typeof mw !== 'undefined') {
   mw.loader.using('mediawiki.user', function() {
   mw.loader.using('mediawiki.user', function() {
       // 获取用户登录状态
       // 判断用户是否是匿名用户
       mw.user.getId().then(function(userId) {
       if (mw.user.isAnon()) {
           if (userId === 0) { // 0 表示未登录用户
           // 隐藏指定的元素
              // 隐藏指定的元素
          var elementsToHide = document.querySelector("#content > div > header > div.page-actions > div.page-actions-more.page-actions__item.citizen-dropdown");
              var elementsToHide = document.querySelector("#content > div > header > div.page-actions > div.page-actions-more.page-actions__item.citizen-dropdown");
          elementsToHide.forEach(function(element) {
              elementsToHide.forEach(function(element) {
              element.style.display = 'none';
                  element.style.display = 'none';
          });
              });
       }
          }
       });
   });
   });
} else {
} else {
   console.error('mw object is not available.');
   console.error('mw object is not available.');
}
}

2024年8月3日 (六) 07:30的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
mw.loader.load("/res/Common/js/vue.min.js");
mw.loader.load("/res/Common/js/vuetify.min.js");

// 全局颜色调整函数
function lightenColor(color, percent) {
  const num = parseInt(color.replace("#", ""), 16),
    amt = Math.round(2.55 * percent),
    R = (num >> 16) + amt,
    G = ((num >> 8) & 0x00ff) + amt,
    B = (num & 0x0000ff) + amt;

  return (
    "#" +
    (
      0x1000000 +
      (R < 255 ? (R < 1 ? 0 : R) : 255) * 0x10000 +
      (G < 255 ? (G < 1 ? 0 : G) : 255) * 0x100 +
      (B < 255 ? (B < 1 ? 0 : B) : 255)
    )
      .toString(16)
      .slice(1)
      .toUpperCase()
  );
}


// 检查 mw 对象是否存在
if (typeof mw !== 'undefined') {
  mw.loader.using('mediawiki.user', function() {
      // 判断用户是否是匿名用户
      if (mw.user.isAnon()) {
          // 隐藏指定的元素
          var elementsToHide = document.querySelector("#content > div > header > div.page-actions > div.page-actions-more.page-actions__item.citizen-dropdown");
          elementsToHide.forEach(function(element) {
              element.style.display = 'none';
          });
      }
  });
} else {
  console.error('mw object is not available.');
}