User:Mountain/metadata.js
外观
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
/***
* ResourceLoader Test
**/
mw.loader.using('jQuery.makeCollapsible', function() {
var settings = {
talkPrefix: 'Talk:',
metaSuffix: '/Metadata'
};
var config = mw.config,
h = mw.html,
isMainArticle = config.get('wgIsArticle') && config.get('wgNamespaceNumber') === 0,
pageName = config.get('wgPageName');
if (isMainArticle) {
$('#bodyContent').prepend($(
h.element('div', {id: 'metabox', class: 'toccolours mw-collapsible mw-collapsed tright'},
new h.Raw(
h.element('img', {id: 'actimg', src: 'http://upload.wikimedia.org/wikipedia/commons/4/41/Book_open.png'})
)
)
));
var metaName = mw.util.wikiUrlencode(settings.talkPrefix + pageName + settings.metaSuffix);
$.getJSON('/w/api.php?action=query&titles=' + metaName + '&format=json', function(data) {
if (data.query.pages['-2'] || data.query.pages['-1']) {
$('#actimg').attr('src', 'http://upload.wikimedia.org/wikipedia/commons/6/69/Book_edit.png');
} else {
//noop
}
});
}
});