|
|
第1行: |
第1行: |
| <includeonly> | | <includeonly><span id="CCB_button" class="mw-ui-button mw-ui-progressive"> |
| <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"> |
| <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 bindCCBButton() {
| |
| // 等待 mw.loader.ready
| |
| if (typeof mw === 'undefined' || !mw.loader || typeof mw.loader.using !== 'function') {
| |
| return setTimeout(bindCCBButton, 50);
| |
| }
| |
| | |
| // 使用主模块名加载并获取导出接口
| |
| mw.loader.using('ext.gadget.CaoCaoBi').then(function(ccb) {
| |
| var btn = document.getElementById('CCB_button');
| |
| if (!btn) return;
| |
| // 先移除已绑定的,防止重复
| |
| btn.replaceWith(btn.cloneNode(true));
| |
| btn = document.getElementById('CCB_button');
| |
| btn.addEventListener('click', function(e) {
| |
| e.preventDefault();
| |
| if (typeof ccb.swit_so_CCB === 'function') {
| |
| ccb.swit_so_CCB();
| |
| } else {
| |
| console.warn('swit_so_CCB 未找到');
| |
| }
| |
| });
| |
| });
| |
| })();</script></includeonly><noinclude>注意:请通过模板 <code>{{tl|CCB-auto}}</code> 调用此 Widget。</noinclude>
| |