|
|
(未显示同一用户的15个中间版本) |
第1行: |
第1行: |
| <script> | | <includeonly><script> |
| //(function waitForGadgetAndRun() {
| | (function waitForGadgetAndRun() { |
| // // 等待 mw 和 loader 初始化
| | // 等待 mw 和 loader 初始化 |
| // if (typeof mw === 'undefined' || !mw.loader?.using || !mw.loader?.getState) {
| | if (typeof mw === 'undefined' || !mw.loader?.using || !mw.loader?.getState) { |
| // return setTimeout(waitForGadgetAndRun, 50);
| | return setTimeout(waitForGadgetAndRun, 50); |
| // }
| | } |
| //
| |
| // const gadgetName = 'ext.gadget.CaoCaoBi';
| |
| //
| |
| // const state = mw.loader.getState(gadgetName);
| |
| //
| |
| // if (state === 'registered') {
| |
| // // 如果还只是 registered,就主动触发加载
| |
| // mw.loader.load(gadgetName);
| |
| // return setTimeout(waitForGadgetAndRun, 50);
| |
| // }
| |
|
| |
|
| // if (state === 'loading' || state === 'loaded') {
| | const gadgetName = 'ext.gadget.CaoCaoBi'; |
| // // 还在加载中,再等一等
| |
| // return setTimeout(waitForGadgetAndRun, 50);
| |
| // }
| |
|
| |
|
| // if (state === 'ready') {
| | const state = mw.loader.getState(gadgetName); |
| // // 已加载完成,可以执行
| |
| // if (typeof swit_so_CCB === 'function') {
| |
| // swit_so_CCB();
| |
| // } else {
| |
| // console.warn('swit_so_CCB 仍未定义(函数未注册到 window?)');
| |
| // }
| |
| // return;
| |
| // //
| |
| // // 不可识别状态,继续等
| |
| // setTime、、ut(waitForGadgetAndRun, 50);
| |
| //、})();
| |
|
| |
|
| |
|
| |
| </script>
| |
|
| |
|
| | | if (state === 'registered') { |
| <span id="CCB_button" class="oo-ui-widget oo-ui-widget-enabled oo-ui-buttonElement oo-ui-buttonElement-framed oo-ui-iconElement oo-ui-labelElement oo-ui-flaggedElement-progressive oo-ui-buttonWidget" onclick="swit_so_CCB()">
| | // 如果还只是 registered,就主动触发加载 |
| <span class="oo-ui-buttonElement-button" role="button"> | | mw.loader.load(gadgetName); |
| <span class="oo-ui-iconElement-icon oo-ui-icon-search oo-ui-image-progressive"></span> | | return setTimeout(waitForGadgetAndRun, 50); |
| <span class="oo-ui-labelElement-label">点我CCB!!</span> | | } |
| <span class="oo-ui-indicatorElement-indicator oo-ui-indicatorElement-noIndicator oo-ui-image-progressive"></span>
| | if (state === 'loading' || state === 'loaded') { |
| </span>
| | // 还在加载中,再等一等 |
| </span> | | return setTimeout(waitForGadgetAndRun, 50); |
| | } |
| | if (state === 'ready') { |
| | // 已加载完成,可以执行 |
| | if (typeof swit_so_CCB === 'function') { |
| | swit_so_CCB(); |
| | } else { |
| | console.warn('swit_so_CCB 仍未定义(函数未注册到 window?)'); |
| | } |
| | return; |
| | // |
| | // 不可识别状态,继续等 |
| | setTime、、ut(waitForGadgetAndRun, 50); |
| | })();</script></includeonly><noinclude>注意:widget不应该在条目中直接使用!请使用{{tl|CCB-auto}}。</noinclude> |
注意:widget不应该在条目中直接使用!请使用{{CCB-auto}}。