User:Emojiwiki/module/QuickView.js
外观
< User:Emojiwiki | module
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google Chrome、Firefox、Microsoft Edge及Safari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
(function(){
mw.util.addCSS( 'qv-quick-view-links::before{ content:\'[\' } .qv-quick-view-links::after{content:\']\'}' );
var pop = mw.loader.load("/wiki/User:Emojiwiki/module/PopupBox.js?action=raw&ctype=text/javascript")();
var r = /^\/wiki\/(.+)/;
var api = new mw.Api();
function QVupdate() {
$( "a" ).each(function() {
var elem = $( this );
if (elem.hasClass('qv-scanned')) {
return;
}
var href = elem.attr('href');
if (href != undefined) {
var matched = href.match(r);
if (matched != undefined && matched[1] != undefined) {
var name = decodeURI(matched[1])
elem.after($('<a></a>').attr('href','#').text("QV").addClass('qv-quick-view-links').click(function(e){
e.preventDefault();
var popContent = $( '<div></div>' ).addClass('qv-content');
api.get( {
action: 'parse',
page: name,
} ).done(function(data) {
if ("errors" in data) {
return;
}
var text = data.parse.text['*'];
pop.open("Quick View of " + name,text);
});
}));
}
elem.addClass('qv-scanned');
}
});
}
QVupdate()
})();