Widget:CCB-button:修订间差异
来自OTTOWiki
更多操作
![]() OctoberSama(留言 | 贡献) 小 |
![]() OctoberSama(留言 | 贡献) 小 |
||
第1行: | 第1行: | ||
<includeonly> | <includeonly> | ||
<span id="CCB_button" class="mw-ui-button mw-ui-progressive" style="cursor: pointer;"> | <span id="CCB_button" class="mw-ui-button mw-ui-progressive" style="cursor: pointer;"> | ||
<img src="/images/5/5b/%E5%A4%A7%E7%99%BD%E8%B1%A1.webp" style="width:1em; vertical-align:middle;"> | |||
<span style="margin-left:0.3em;">点我 CCB!!</span> | |||
</span> | </span> | ||
<script> | <script> | ||
(function | (function initCCBButton() { | ||
// | // 如果还没有 mw.loader,则延迟重试 | ||
if (typeof mw === 'undefined' || | if (typeof mw === 'undefined' || typeof mw.loader === 'undefined') { | ||
return setTimeout( | return setTimeout(initCCBButton, 100); | ||
} | } | ||
// 触发加载 ext.gadget.CaoCaoBi 模块 | |||
mw.loader.load('ext.gadget.CaoCaoBi'); | |||
if ( | // 如果你的模块通过 `return { swit_so_CCB, … }` 导出了函数, | ||
// | // ResourceLoader 会帮你把这些函数挂到 window 上 | ||
if (typeof window.swit_so_CCB !== 'function') { | |||
return setTimeout( | // 未就绪,继续轮询 | ||
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> | |||
} | |||
})();</script></includeonly><noinclude>注意:本 Widget |
2025年6月20日 (五) 21:02的版本
注意:本 Widget 不应直接插入条目正文,请使用模板 {{CCB-auto}}
调用。