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

Widget:CCB-button:修订间差异

来自OTTOWiki
 
(未显示同一用户的8个中间版本)
第1行: 第1行:
<includeonly>
<includeonly><span id="CCB_button" class="mw-ui-button mw-ui-progressive" style="user-select: none;">
<span id="CCB_button" class="mw-ui-button mw-ui-progressive" style="cursor: pointer;">
<span onclick="swit_so_CCB();">
  <img src="/images/5/5b/%E5%A4%A7%E7%99%BD%E8%B1%A1.webp" style="width:1em; vertical-align:middle;">
<img src="/images/5/5b/%E5%A4%A7%E7%99%BD%E8%B1%A1.webp" style="width:1em" draggable="false">
  <span style="margin-left:0.3em;">点我 CCB!!</span>
<span>点我CCB!!</span>
</span>
</span>
 
</span></includeonly><noinclude>{{doc|content=注意:widget不应该在条目中直接使用!请使用{{tl|CCB-button}}。}}</noinclude>
<script>
(function initCCBButton() {
    // 如果还没有 mw.loader,则延迟重试
    if (typeof mw === 'undefined' || typeof mw.loader === 'undefined') {
        return setTimeout(initCCBButton, 100);
    }
 
    // 触发加载 ext.gadget.CaoCaoBi 模块
    mw.loader.load('ext.gadget.CaoCaoBi');
 
    // 如果你的模块通过 `return { swit_so_CCB, … }` 导出了函数,
    // ResourceLoader 会帮你把这些函数挂到 window 上
    if (typeof window.swit_so_CCB !== 'function') {
        // 未就绪,继续轮询
        return setTimeout(initCCBButton, 100);
    }
 
    // 模块已加载、函数已定义,绑定按钮点击事件
    var btn = document.getElementById('CCB_button');
    if (!btn) return;
    btn.addEventListener('click', function(e) {
        e.preventDefault();
        window.swit_so_CCB();
    });
})();</script></includeonly><noinclude>注意:本 Widget 不应直接插入条目正文,请使用模板 <code>{{tl|CCB-auto}}</code> 调用。</noinclude>

2025年6月20日 (五) 22:13的最新版本