MediaWiki:Common.js:修订间差异

imported>=海豚=
无编辑摘要
imported>=海豚=
测试!!!!
第10行: 第10行:
"use strict";
"use strict";
(function($, mw) { //使用匿名函数防止污染顶级变量
(function($, mw) { //使用匿名函数防止污染顶级变量
    /* 函数定义体 */
    //滚动公告
    function autoScroll(obj) {
        $(obj).animate({
            height: "show",
            paddingTop: "show",
            marginTop: "show",
            paddingBottom: "show",
            marginBottom: "show",
        });
        var isFrozen = false;
        setInterval(function() {
            if (!isFrozen) {
                $(obj).find("ul:first").animate({
                    marginTop: "0px",
                }, 500, function() {
                    $(this).css({
                        marginTop: "0px",
                    }).find("li:first").appendTo(this);
                });
            }
        }, 5000);
        $(window).on({
            blur: function() {
                isFrozen = true;
            },
            focus: function() {
                isFrozen = false;
            },
        });
    }
     /* MediaViewer#populateStatsFromXhr 错误屏蔽 */
     /* MediaViewer#populateStatsFromXhr 错误屏蔽 */
     (function() {
     (function() {
第96行: 第65行:
             }
             }
         }, 137);
         }, 137);
    }
    //Tabs
    function tabs() {
        var defaultStyle = {
            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",
            },
        };
        $("body").addClass("tab");
        // A Class
        function StyleSheet() {}
        StyleSheet.prototype.getOwnPropertyNamesLength = function getOwnPropertyNamesLength() {
            return Object.getOwnPropertyNames(this).length;
        };
        String.prototype.toLowerFirstCase = function toLowerFirstCase() {
            return this[0].toLowerCase() + this.substring(1);
        };
        $(".Tabs").each(function() {
            if ($(this).children(".TabLabel")[0]) { return true; }
            var self = $(this),
                classList = Array.from(this.classList).filter(function(n) { return n in defaultStyle; }),
                data = $.extend({
                    labelPadding: "2px",
                    labelBorderColor: "#aaa",
                    labelColor: "green",
                    labelBackgroundColor: $("#content").css("background-color"),
                    textPadding: "20px 30px",
                    textBorderColor: "#aaa",
                    textBackgroundColor: "white",
                    defaultTab: 1,
                }, classList[0] ? defaultStyle[classList[0]] || {} : {}, this.dataset || {}),
                tabLabel = self.append('<div class="TabLabel"></div>').children(".TabLabel"),
                tabContent = self.append('<div class="TabContent"></div>').children(".TabContent"),
                labelPadding = data.labelPadding,
                labelColor = data.labelColor,
                styleSheet = {
                    label: new StyleSheet(),
                    text: new StyleSheet(),
                },
                defaultTab = parseInt(data.defaultTab);
            self.children(".Tab").each(function() {
                if ($(this).children(".TabLabelText").text().replace(/\s/g, "").length || $(this).children(".TabLabelText").children().length) {
                    $(this).children(".TabLabelText").appendTo(tabLabel);
                    $(this).children(".TabContentText").appendTo(self.children(".TabContent"));
                }
                $(this).remove();
            });
            if (isNaN(defaultTab) || defaultTab <= 0 || defaultTab > tabLabel.children(".TabLabelText").length) { defaultTab = 1; }
            tabLabel.children(".TabLabelText").on("click", function() {
                var label = $(this);
                label.addClass("selected").siblings().removeClass("selected").css({
                    "border-color": "transparent",
                    "background-color": "inherit",
                });
                tabContent.children(".TabContentText").eq(tabLabel.children(".TabLabelText").index(label)).addClass("selected").siblings().removeClass("selected").removeAttr("style");
                if (styleSheet.label.getOwnPropertyNamesLength()) { label.css(styleSheet.label); }
            }).eq(defaultTab - 1).click();
            if (labelPadding) { tabLabel.children(".TabLabelText").css("padding", labelPadding); }
            ["labelBorderColor", "labelBackgroundColor", "textPadding", "textBorderColor", "textBackgroundColor"].forEach(function(n) {
                var target = /^label/.test(n) ? "label" : "text",
                    key = n.replace(target, "").toLowerFirstCase();
                styleSheet[target][key] = data[n];
            });
            if (labelColor) {
                styleSheet.label.borderTopColor = labelColor;
            } else if (styleSheet.label.borderColor) {
                styleSheet.label.borderTopColor = "green";
            }
            tabLabel.find(".selected").click();
            if (styleSheet.text.getOwnPropertyNamesLength()) { tabContent.css(styleSheet.text); }
            if (data.autoWidth === "yes") { self.css("display", "inline-block"); }
        });
     }
     }
     //子页面页顶链接
     //子页面页顶链接
第129行: 第231行:
     //重复文件列表函数
     //重复文件列表函数
     function duplicatedFileList() {
     function duplicatedFileList() {
         if (window.location.href.indexOf("title") === -1) { window.location.replace("http://www.hmoegirl.com/index.php?title=Special:ListDuplicatedFiles&limit=500&offset=0"); }
         if (window.location.href.indexOf("title") === -1) { window.location.replace("http://zh.moegirl.org/index.php?title=Special:ListDuplicatedFiles&limit=500&offset=0"); }
         $("#mw-content-text .mw-spcontent ol").attr("id",
         $("#mw-content-text .mw-spcontent ol").attr("id",
             "picOl");
             "picOl");
第161行: 第263行:
         container.append("您虽然无权编辑本页面,但您可以点击右侧按钮在本页的讨论页提出编辑请求,让可以编辑的人代为编辑:");
         container.append("您虽然无权编辑本页面,但您可以点击右侧按钮在本页的讨论页提出编辑请求,让可以编辑的人代为编辑:");
         $("<span/>").addClass("newComment").text("提出编辑请求").on("click", function() {
         $("<span/>").addClass("newComment").text("提出编辑请求").on("click", function() {
             window.open("https://www.hmoegirl.com/index.php?action=edit&preload=Template:编辑请求/comment&preloadtitle=编辑请求 - " + mw.config.get("wgUserName") + "&section=new&title=" + talkpage, "_blank");
             window.open("https://zh.moegirl.org/index.php?action=edit&preload=Template:编辑请求/comment&preloadtitle=编辑请求 - " + mw.config.get("wgUserName") + "&section=new&title=" + talkpage, "_blank");
         }).appendTo(container);
         }).appendTo(container);
         $("#mw-content-text").children(".wikiEditor-ui:first, textarea[readonly]:first").before("<hr>").before(container);
         $("#mw-content-text").children(".wikiEditor-ui:first, textarea[readonly]:first").before("<hr>").before(container);
第209行: 第311行:
             messageDialog.message.$label.html("<br>您提交的内容包含以下部分,被禁止提交:<br><br><ul>" + results.map(function(result) {
             messageDialog.message.$label.html("<br>您提交的内容包含以下部分,被禁止提交:<br><br><ul>" + results.map(function(result) {
                 return "<li>" + result + "</li>";
                 return "<li>" + result + "</li>";
             }).join("") + '</ul><br><br>如果您认为您的编辑无误,请在自行保存编辑内容后到<a target="_blank" rel="nofollow noreferrer noopener" class="external text" href="https://www.hmoegirl.com/Talk:讨论版">讨论版</a>提问。');
             }).join("") + '</ul><br><br>如果您认为您的编辑无误,请在自行保存编辑内容后到<a target="_blank" rel="nofollow noreferrer noopener" class="external text" href="https://zh.moegirl.org/Talk:%E6%8F%90%E9%97%AE%E6%B1%82%E5%8A%A9%E5%8C%BA">提问求助区</a>提问。');
             windowManager.openWindow(messageDialog, {
             windowManager.openWindow(messageDialog, {
                 actions: [{
                 actions: [{
第270行: 第372行:
         //需要时载入对应的 scripts
         //需要时载入对应的 scripts
         if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit" || mw.config.get("wgCanonicalSpecialPageName") === "Search") { mw.loader.load("/index.php?title=MediaWiki:Common.js/edit.js&action=raw&ctype=text/javascript"); }
         if (mw.config.get("wgAction") === "edit" || mw.config.get("wgAction") === "submit" || mw.config.get("wgCanonicalSpecialPageName") === "Search") { mw.loader.load("/index.php?title=MediaWiki:Common.js/edit.js&action=raw&ctype=text/javascript"); }
        // Tabs执行
        mw.hook('wikipage.content').add(function() { tabs(); });
         //子页面页顶链接
         //子页面页顶链接
         if (mw.config.get("wgPageName").indexOf("/") !== -1 && (mw.config.get("wgNamespaceIds").special !== mw.config.get("wgNamespaceNumber") || mw.config.get("wgPageName").indexOf("Special:移动页面") !== -1) && !window._unsubpage) { subpage_links(); }
         if (mw.config.get("wgPageName").indexOf("/") !== -1 && (mw.config.get("wgNamespaceIds").special !== mw.config.get("wgNamespaceNumber") || mw.config.get("wgPageName").indexOf("Special:移动页面") !== -1) && !window._unsubpage) { subpage_links(); }
第277行: 第381行:
         });
         });
         //编辑请求
         //编辑请求
         if (["edit", "submit"].indexOf(mw.config.get("wgAction")) !== -1 && !!$(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName")) { editRequest(); }
         if (["edit", "submit"].indexOf(mw.config.get("wgAction")) !== -1 && !$(".permissions-errors, #wpTextbox1[readonly]")[1] && mw.config.get("wgUserName")) { editRequest(); }
         //修复代码编辑器$.ucFirst引用错误
         //修复代码编辑器$.ucFirst引用错误
         $.extend({
         $.extend({