MediaWiki:Gadget-era note.js
外观
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5。
// [[mw:ResourceLoader/Core modules]]
jQuery.getScript('https://kanasimi.github.io/CeJS/ce.js')
// https://api.jquery.com/jQuery.getScript/
.done(function( script, textStatus ) {
if (mw.config.get('wgNamespaceNumber') !== 0) {
// 僅處理條目頁面。
return;
}
CeL.run('interact.DOM', function() {
CeL.new_node({
div : '標注年號',
onclick : add_era_note,
S : 'position: fixed; right: 0; bottom: 0; cursor: pointer; color: blue; background-color: #def; border: 1pt solid #eff; padding: .2em;'
}, document.body);
});
})
.fail(function( jqxhr, settings, exception ) {
console.error( exception );
});
window.add_era_note = function() {
Object.assign(this.style, {
color : '#888',
backgroundColor : '#ffe',
cursor : 'wait'
});
// reset event
this.onclick = null;
this.innerHTML = '準備開始載入曆數資料';
var _this = this;
CeL.env.era_data_load = function(country, queue) {
if (typeof country === 'object') {
// 第一次呼叫 callback。
// 在載入era模組之前設定好,可以用來篩選需要載入的國家。
queue.truncate().push('中國', '日本', '한국', 'Việt Nam', '琉球');
} else if (queue) {
_this.innerHTML = '已載入' + country;
} else {
_this.innerHTML = '標注文本中';
setTimeout(function() {
CeL.era.note_node('#mw-content-text', { add_date : true });
Object.assign(_this.style, {
color : 'green',
backgroundColor : '#efe',
cursor : 'pointer'
});
_this.innerHTML = '文本標注完成<br />請幫忙檢查錯誤並且回報 謝謝';
_this.onclick = function() {
this.remove();
};
}, 0);
}
};
CeL.run([ 'data.date.era', 'interact.DOM' ]);
};