imported>=海豚= |
imported>=海豚= |
(未显示同一用户的13个中间版本) |
第1行: |
第1行: |
| (function($, mw) {
| | mw.loader.load('https://cdn.jsdelivr.net/gh/bhsd-harry/LLWiki@2.4/js/gadget-code-prettify.min.js','text/javascript'); |
| if (mw.config.get('wgPageName').match(/\.js$/)) $('.mw-code').addClass('prettyprint linenums lang-js');
| |
| if (mw.config.get('wgPageName').match(/\.css$/)) $('.mw-code').addClass('prettyprint linenums lang-css');
| |
| var acceptsLangs = {
| |
| "js": "js",
| |
| "javascript": "js",
| |
| "css": "css",
| |
| "html": "html",
| |
| "Scribunto": "lua"
| |
| }
| |
| var wgPageContentModel = mw.config.get("wgPageContentModel");
| |
| if (wgPageContentModel in acceptsLangs) $('.mw-code').addClass('prettyprint linenums lang-' + acceptsLangs[wgPageContentModel]);
| |
| $('pre[lang]').each(function() {
| |
| var self = $(this);
| |
| var lang = self.attr("lang").toLowerCase();
| |
| if (lang in acceptsLangs) {
| |
| self.addClass("prettyprint linenums lang-" + acceptsLangs[lang]);
| |
| }
| |
| });
| |
| if ($('.prettyprint').length > 0) {
| |
| // mw.loader.load('MediaWiki:Gadget-code-prettify.css', 'text/css');
| |
| $.ajax({
| |
| url: "//zh.moegirl.org/index.php?title=MediaWiki:Gadget-code-prettify-core.js&action=raw&ctype=text/javascript",
| |
| dataType: 'script',
| |
| cache: true,
| |
| success: function() {
| |
| prettyPrint();
| |
| if (mw.config.get('wgPageName').match(/\.(js|css)$/)) {
| |
| $(window).on("hashchange", function() {
| |
| mw.loader.using("mw.Uri").then(function() {
| |
| var frag = new mw.Uri().fragment;
| |
| if (/^L\d+$/.test(frag)) {
| |
| var firstCode = $(".prettyprint.prettyprinted > .linenums").first().children().eq(+frag.substring(1) - 1);
| |
| if (firstCode[0]) {
| |
| $('html, body').animate({
| |
| scrollTop: firstCode.offset().top,
| |
| });
| |
| }
| |
| }
| |
| });
| |
| });
| |
| $(window).trigger("hashchange");
| |
| }
| |
| }
| |
| });
| |
| }
| |
| })(jQuery, mediaWiki);
| |