MediaWiki:Gadget-CodePrettify.js

From Elwiki
Revision as of 06:34, 18 May 2015 by Boxsnake (talk | contribs)

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');
	if ( wgPageName.match(/\.js$/) )  $('pre').addClass('lang-js');
	if ( wgPageName.match(/\.css$/) ) $('pre').addClass('lang-css');
	if ( $('pre.mw-code').length > 0 || ) {
            importStylesheet('MediaWiki:Prettify.css');
            $.cachedScript('/wiki/index.php?title=MediaWiki:Gadget-CodePrettifyMap.js&action=raw&ctype=text/javascript').done(function(){
                 prettyPrint();
            } );
	}
})();