• 欢迎来到Minecraft插件百科!
  • 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
  • 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289

“MediaWiki:Common.js”的版本间的差异

来自Minecraft插件百科
跳转至: 导航搜索
(撤销Henry5041讨论)的版本9152)
1个标签撤销
(April Fools)
第211行: 第211行:
  
 
document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", '<link rel="shortcut icon" type="image/png" href="/skins/common/Mineplugin_logo.png">');
 
document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", '<link rel="shortcut icon" type="image/png" href="/skins/common/Mineplugin_logo.png">');
 +
 +
 +
/* April Fools */
 +
$("body").css("transform", "rotateY(180deg)");
 +
$("body").click(function () { $("body").css("transform", "") });

2020年4月1日 (三) 00:46的版本

/* 这里的任何JavaScript将在全站加载
 * 此代码根据知识共享 署名-非商业性使用-相同方式共享 3.0复制自萌娘百科http://zh.moegirl.org/MediaWiki:Common.css
 * 版权协定:知识共享 署名-非商业性使用-相同方式共享 3.0
 */
(function($, mw) { //使用匿名函数防止污染顶级变量
    /* 函数定义体 */
    //滚动公告
    function AutoScroll(obj) {
        $(obj).find("ul:first").animate({
            marginTop: "-25px"
        }, 500, function() {
            $(this).css({
                marginTop: "0px"
            }).find("li:first").appendTo(this);
        });
    }
    //Tabs
    function tabs() {
        $('body').addClass('tab');
        $('.Tabs').each(function(i) {
            if ($(this).find('.TabLabel')[0]) return true;
            var self = $(this),
                data = $.extend({
                    labelPadding: null,
                    labelBorderColor: null,
                    labelColor: null,
                    labelBackgroundColor: $('body').css('background-color'),
                    textPadding: null,
                    textBorderColor: null,
                    textBackgroundColor: null,
                    defaultTab: 1,
                }, self.attr('class').length > 4 ? {
                    purple: {
                        labelColor: ' ', //anti check
                        labelBackgroundColor: '#9070c0',
                        labelBorderColor: '#b090e0 #7050a0 #9070c0 #b090e0',
                        labelPadding: '.2em .3em .2em .3em',
                        textBorderColor: '#9070c0',
                        textBackgroundColor: '#f0edf5',
                        textPadding: '1em'
                    },
                    green: {
                        labelColor: ' ',
                        labelBackgroundColor: '#75c045',
                        labelBorderColor: '#90d060 #60b030 #75c045 #90d060',
                        labelPadding: '.2em .3em .2em .3em',
                        textBorderColor: '#75c045 #60b030 #60b030 #75c045',
                        textBackgroundColor: '#f5fffa',
                        textPadding: '1em'
                    },
                    red: {
                        labelColor: ' ',
                        labelBackgroundColor: '#FF0000',
                        labelBorderColor: '#FF8888 #CC0000 #FF0000 #FF8888',
                        labelPadding: '.2em .3em .2em .3em',
                        textBorderColor: '#FF0000 #CC0000 #CC0000 #FF0000',
                        textBackgroundColor: '#fffafa',
                        textPadding: '1em'
                    },
                    blue: {
                        labelColor: ' ',
                        labelBackgroundColor: '#5b8dd6',
                        labelBorderColor: '#88abde #3379de #5b8dd6 #88abde',
                        labelPadding: '.2em .3em .2em .3em',
                        textBackgroundColor: '#f0f8ff',
                        textBorderColor: '#5b8dd6 #3379de #3379de #5b8dd6',
                        textPadding: '1em'
                    },
                    yellow: {
                        labelColor: ' ',
                        labelBackgroundColor: '#ffe147',
                        labelBorderColor: '#ffe977 #ffd813 #ffe147 #ffe977',
                        labelPadding: '.2em .3em .2em .3em',
                        textBackgroundColor: '#fffce8',
                        textBorderColor: '#ffe147 #ffd813 #ffd813 #ffe147',
                        textPadding: '1em'
                    },
                    orange: {
                        labelColor: ' ',
                        labelBackgroundColor: '#ff9d42',
                        labelBorderColor: '#ffac5d #ff820e #ff9d42 #ffac5d',
                        labelPadding: '.2em .3em .2em .3em',
                        textBackgroundColor: '#ffeedd',
                        textBorderColor: '#ff9d42 #ff820e #ff820e #ff9d42',
                        textPadding: '1em'
                    },
                    black: {
                        labelColor: ' ',
                        labelBackgroundColor: '#7f7f7f',
                        labelBorderColor: '#999999 #4c4c4c #7f7f7f #999999',
                        labelPadding: '.2em .3em .2em .3em',
                        textBackgroundColor: '#e5e5e5',
                        textBorderColor: '#7f7f7f #4c4c4c #4c4c4c #7f7f7f',
                        textPadding: '1em'
                    }
                }[self.attr('class').slice(5)] || {} : {}, this.dataset),
                tabLabel = self.append('<div class="TabLabel"></div>').find('.TabLabel'),
                tabContent = self.append('<div class="TabContent"></div>').find('.TabContent'),
                labelPadding = data.labelPadding,
                labelBorderColor = data.labelBorderColor,
                labelBackgroundColor = data.labelBackgroundColor,
                labelColor = data.labelColor,
                textPadding = data.textPadding,
                textBorderColor = data.textBorderColor,
                textBackgroundColor = data.textBackgroundColor,
                labelStyleSheet = {},
                textStyleSheet = {},
                dafaultTab,
                objectLength = function(obj) {
                    return Object.getOwnPropertyNames(obj).length;
                };
            self.find('.Tab').each(function() {
                $(this).find('.TabLabelText').appendTo(self.find('.TabLabel'));
                $(this).find('.TabContentText').appendTo(self.find('.TabContent'));
                $(this).remove();
            });
            defaultTab = parseInt(data.defaultTab);
            if (isNaN(defaultTab) || defaultTab <= 0 || defaultTab > self.find('.TabLabelText').length) defaultTab = 1;
            self.find('.TabLabelText').bind('click', function() {
                var label = $(this);
                label.addClass('selected').siblings().removeClass('selected').css({
                    'border-color': 'inherit',
                    'background-color': 'inherit'
                });
                self.find('.TabContentText').eq(self.find('.TabLabelText').index(label)).addClass('selected').siblings().removeClass('selected').removeAttr('style');
                if (objectLength(labelStyleSheet)) label.css(labelStyleSheet);
                self.find('.TabLabel').height(label.height() + parseFloat(label.css('padding-top')) + parseFloat(label.css('padding-bottom')) + 2);
            }).eq(defaultTab - 1).click();
            if (labelPadding) self.find('.TabLabelText').css('padding', labelPadding);
            if (labelBorderColor) labelStyleSheet.borderColor = labelBorderColor;
            if (labelBackgroundColor) labelStyleSheet.backgroundColor = labelBackgroundColor;
            if (labelColor) labelStyleSheet.borderTopColor = labelColor;
            else if (labelStyleSheet.borderColor) labelStyleSheet.borderTopColor = 'green';
            if (textPadding) textStyleSheet.padding = textPadding;
            if (textBorderColor) textStyleSheet.borderColor = textBorderColor;
            if (textBackgroundColor) textStyleSheet.backgroundColor = textBackgroundColor;
            tabLabel.find('.selected').click();
            if (objectLength(textStyleSheet)) tabContent.css(textStyleSheet);
            if (data.autoWidth == 'yes') self.css('display', 'inline-block');
        });
    }
    //子页面页顶链接
    function subpage_links() {
        if (mw.config.values.wgPageName.indexOf('/') != -1 && !$('.subpages')[0] && (mw.config.values.wgNamespaceIds.special != mw.config.values.wgNamespaceNumber || mw.config.values.wgPageName.indexOf('Special:移动页面') != -1)) {
            var links = mw.config.values.wgPageName.split('/'),
                link = '',
                subpages = $('<span class="subpages"></span>').text('<'),
                length = links.length - 1,
                index;
            if (mw.config.values.wgPageName.indexOf('Special:移动页面') != -1) links.splice(0, 1);
            for (index = 0; index < length; index++) {
                link += '/' + links[index];
                subpages.append($('<a/>', {
                    text: ' ' + links[index],
                    href: link
                }));
                if (length - index - 1) subpages.append(" |");
            }
            $('#contentSub').prepend(subpages);
        }
    }
    //由于mw的锅导致部分文字可能超出#mw-content-text的范围,为这些文字的{{hide}}补上隐藏效果
    function missedHideFun(obj) {
        $('<span class="mw-collapsible-toggle"><span class="mw-collapsible-bracket">[</span><a href="javascript:void(0);"/><span class="mw-collapsible-bracket">]</span></span>').appendTo(obj.find('tr:first > :last'));
        obj.find('.mw-collapsible-toggle a').text('隐藏').bind('click', function() {
            var a = $(this).closest('table.mw-collapsible').find('tr').not(':first');
            "none" == a.css("display") ? a.show() && $(this).text("显示") : a.hide() && $(this).text("隐藏");
        });
        obj.filter('.mw-collapsed').find('.mw-collapsible-toggle a').click();
    }
    //重复文件列表函数
    function duplicatedFileList() {
        if (window.location.href.indexOf("title") == -1) window.location.replace("http://mineplugin.org/index.php?title=Special:ListDuplicatedFiles&limit=500&offset=0");
        $('#mw-content-text .mw-spcontent ol').attr("id", "picOl");
        $('#picOl').before('<p id="picOlTitle">图片列表:</p>').after('<p id="MP3OlTitle">MP3列表:</p><ol start="1" id="MP3Ol"></ol>');
        $("#picOlTitle, #MP3OlTitle").hide();
        $("#picOl").find("[href$='.mp3'], [href$='.ogg']").parent().appendTo("#MP3Ol");
        if ($("#picOl").find("li").length) $("#picOlTitle").show();
        if ($("#MP3Ol").find("li").length) $("#MP3OlTitle").show();
        $(".mw-spcontent > p:nth-child(1), .mw-spcontent > p:nth-child(2), .mw-spcontent > p:nth-child(7)").hide();
    }
    /* 函数执行体 */
    $(function() {
        //滚动公告
        setInterval(function() {
            AutoScroll("#scrollDiv");
        }, 5000);
        // Add "mainpage" class to the body element
        if (mw.config.values.wgMainPageTitle === mw.config.values.wgPageName && mw.config.values.wgAction === 'view') $('body').addClass('mainpage');
        //重复文件列表区分图片和音频
        if ($(".mw-special-ListDuplicatedFiles").length && $('.mw-spcontent > p').length > 1) duplicatedFileList();
        //需要时载入对应的 scripts
        if (mw.config.values.wgAction == "edit" || mw.config.values.wgAction == "submit" || mw.config.values.wgCanonicalSpecialPageName == 'Search') importScript('MediaWiki:Common.js/edit.js');
        // Tabs执行
        if ($('.Tabs')[0]) tabs();
        //missedhideHideFun执行
        var missedHide = $('#mw-content-text').nextAll().filter('.mw-collapsible').not(':has(.mw-collapsible-toggle)');
        if (missedHide[0]) missedHideFun(missedHide);
        //子页面页顶链接
        subpage_links();
        //以下代码必须在全部内容加载完成后才能正常工作
        $(window).bind('load', function() {
            //语言对应
            $('.mw-helplink').each(function() {
                var linkHref = this.href;
                if (linkHref.indexOf('/zh') != linkHref.length - 3) this.href += '/zh';
            });
        });
    });
})(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量以防止冲突

document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend", '<link rel="shortcut icon" type="image/png" href="/skins/common/Mineplugin_logo.png">');


/* April Fools */
$("body").css("transform", "rotateY(180deg)");
$("body").click(function () { $("body").css("transform", "") });