MediaWiki:Gadget-CodePrettify.js: Difference between revisions

From Elwiki
m (Boxsnake moved page MediaWiki:Gadgets-CodePrettify.js to MediaWiki:Gadget-CodePrettify.js without leaving a redirect)
mNo edit summary
Line 14: Line 14:
if ( $('.prettyprint').length > 0 ) {
if ( $('.prettyprint').length > 0 ) {
             importStylesheet('MediaWiki:Prettify.css');
             importStylesheet('MediaWiki:Prettify.css');
             $.cachedScript('//zh.moegirl.org/index.php?title=MediaWiki:Gadget-code-prettify-prettify.js&action=raw&ctype=text/javascript').done(function(){
             $.cachedScript('/wiki/index.php?title=MediaWiki:Gadget-CodePrettifyMap.js&action=raw&ctype=text/javascript').done(function(){
                 prettyPrint();
                 prettyPrint();
             } );
             } );
}
}
})();
})();

Revision as of 04:13, 18 May 2015

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