MediaWiki:Gadget-CodePrettify.js: Difference between revisions

From Elwiki
mNo edit summary
mNo edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
/* 代码高亮  引自http://www.pokemon.name/wiki/MediaWiki:Common.js */
/* 代码高亮  引自http://www.pokemon.name/wiki/MediaWiki:Common.js */
;jQuery.cachedScript = function(url, options) {
;jQuery.cachedScript = function(url, options) {
options = $.extend(options || {}, {
    options = $.extend(options || {}, {
dataType: "script",
        dataType: "script",
cache: true,
        cache: true,
url: url
        url: url
});
    });
return jQuery.ajax(options);
    return jQuery.ajax(options);
};
};


(function() {
(function(){
        $('pre').addClass('mw-code');
    $('pre').addClass('mw-code prettyprint linenums');
if ( wgPageName.match(/\.js$/) ) $('.mw-code').addClass('prettyprint linenums lang-js');
    if(mw.config.get('wgPageName').match(/\.js$/)) $('.mw-code').addClass('lang-js');
if ( wgPageName.match(/\.css$/) ) $('.mw-code').addClass('prettyprint linenums lang-css');
    if(mw.config.get('wgPageName').match(/\.css$/)) $('.mw-code').addClass('lang-css');
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(mw.config.get('wgScriptPath') + '/index.php?title=MediaWiki:Gadget-CodePrettifyMap.js&action=raw&ctype=text/javascript').done(function(){
                prettyPrint();
            prettyPrint();
            } );
        });
}
    }
})();
})();

Latest revision as of 04:58, 20 July 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(){
    $('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();
        });
    }
})();