MediaWiki:Gadget-CodePrettify.js
From Elwiki
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/* 代码高亮 引自http://www.pokemon.name/wiki/MediaWiki:Common.js */
;jQuery.cachedScript = function(url, options) {
options = $.extend(options || {}, {
dataType: "script",
cache: true,
url: url
});
return jQuery.ajax(options);
};
(function(){
$('pre').addClass('mw-code prettyprint linenums');
if(mw.config.get('wgPageName').match(/\.js$/)) $('.mw-code').addClass('lang-js');
if(mw.config.get('wgPageName').match(/\.css$/)) $('.mw-code').addClass('lang-css');
if($('.prettyprint').length > 0){
importStylesheet('MediaWiki:Prettify.css');
$.cachedScript(mw.config.get('wgScriptPath') + '/index.php?title=MediaWiki:Gadget-CodePrettifyMap.js&action=raw&ctype=text/javascript').done(function(){
prettyPrint();
});
}
})();