跳转到内容

MediaWiki:Citizen.js:修订间差异

来自天明的百科全书
Ztm0929留言 | 贡献
添加页脚logo
 
Ztm0929留言 | 贡献
补充class以匹配自带格式
第10行: 第10行:
         if ($smw.length) {
         if ($smw.length) {
             $smw.after(
             $smw.after(
                '<li id="footer-poweredbycitizenico">' +
  '<li id="footer-poweredbycitizenico">' +
                '<a href="https://github.com/StarCitizenTools/mediawiki-skins-Citizen" target="_blank">' +
    '<a href="https://github.com/StarCitizenTools/mediawiki-skins-Citizen" ' +
                '<img src="/resources/assets/poweredby-citizen-dark.svg" alt="Powered by Citizen" width="88" height="31" loading="lazy">' +
      'class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled" ' +
                '</a></li>'
      'target="_blank">' +
            );
      '<img src="/resources/assets/poweredby-citizen-dark.svg" alt="Powered by Citizen" width="88" height="31" loading="lazy">' +
    '</a>' +
  '</li>'
);
         }
         }
     }
     }

2025年9月28日 (日) 06:09的版本

/* 这里所有JavaScript都会加载给Citizen皮肤的用户 */

// 添加powered by logo
$(function () {
    // 插入 Citizen footer 图标
    function ensureCitizenFooterIcon() {
        if ($('#footer-poweredbycitizenico').length) return;

        var $smw = $('#footer-poweredbysmwico');
        if ($smw.length) {
            $smw.after(
			  '<li id="footer-poweredbycitizenico">' +
			    '<a href="https://github.com/StarCitizenTools/mediawiki-skins-Citizen" ' +
			       'class="cdx-button cdx-button--fake-button cdx-button--size-large cdx-button--fake-button--enabled" ' +
			       'target="_blank">' +
			      '<img src="/resources/assets/poweredby-citizen-dark.svg" alt="Powered by Citizen" width="88" height="31" loading="lazy">' +
			    '</a>' +
			  '</li>'
			);
        }
    }

    ensureCitizenFooterIcon();

    // 监听主题切换,更新图标
    function updateCitizenIcon() {
        var theme = document.documentElement.classList.contains('skin-theme-clientpref-night') ? 'dark' : 'light';
        var src = theme === 'dark' ? '/resources/assets/poweredby-citizen-dark.svg' : '/resources/assets/poweredby-citizen.svg';
        $('#footer-poweredbycitizenico img').attr('src', src);
    }

    updateCitizenIcon();
    var htmlObserver = new MutationObserver(updateCitizenIcon);
    htmlObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['class'] });
});