|
|
| (未显示3个用户的11个中间版本) |
| 第13行: |
第13行: |
| } catch (err) { /* */ } | | } catch (err) { /* */ } |
| /* 函数定义体 */ | | /* 函数定义体 */ |
| //用户资料页相关
| |
| function isUserProfile() {
| |
| return mw.config.get('wgCanonicalSpecialPageName') === "UserProfile" && mw.config.get('wgArticleId') === "0";
| |
| }
| |
| //Tabs
| |
| /* eslint-disable comma-dangle */
| |
| /* eslint-disable prefer-arrow-callback */
| |
| /* eslint-disable no-var */
| |
| "use strict";
| |
| $(function () {
| |
| 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",
| |
| },
| |
| };
| |
| var sides = {
| |
| top: {
| |
| className: "tabLabelTop",
| |
| labelColorSide: "top",
| |
| labelBorderSide: ["left", "right"],
| |
| labelColorSideReverse: "bottom",
| |
| dividerSizeType: "height"
| |
| },
| |
| bottom: {
| |
| className: "tabLabelBottom",
| |
| labelColorSide: "bottom",
| |
| labelBorderSide: ["left", "right"],
| |
| labelColorSideReverse: "top",
| |
| dividerSizeType: "height"
| |
| },
| |
| left: {
| |
| className: "tabLabelLeft",
| |
| labelColorSide: "left",
| |
| labelBorderSide: ["top", "bottom"],
| |
| labelColorSideReverse: "right",
| |
| dividerSizeType: "width"
| |
| },
| |
| right: {
| |
| className: "tabLabelRight",
| |
| labelColorSide: "right",
| |
| labelBorderSide: ["top", "bottom"],
| |
| labelColorSideReverse: "left",
| |
| dividerSizeType: "width"
| |
| }
| |
| };
| |
| var truthy = ["1", "on", "true", "yes"];
| |
| $("body").addClass("tab");
| |
| function getOwnPropertyNamesLength(obj) {
| |
| return Object.getOwnPropertyNames(obj).length;
| |
| }
| |
| function toLowerFirstCase(str) {
| |
| return str.substring(0, 1).toLowerCase() + str.substring(1);
| |
| }
| |
| function toUpperFirstCase(str) {
| |
| return str.substring(0, 1).toUpperCase() + str.substring(1);
| |
| }
| |
| mw.hook("wikipage.content").add(function () {
| |
| $(".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"),
| |
| tabDivider = self.append('<div class="TabDivider"></div>').children(".TabDivider"),
| |
| tabContent = self.append('<div class="TabContent"></div>').children(".TabContent"),
| |
| labelPadding = data.labelPadding,
| |
| labelColor = data.labelColor,
| |
| styleSheet = {
| |
| label: {},
| |
| text: {},
| |
| },
| |
| labelSide = data.labelSide in sides ? data.labelSide : "top",
| |
| side = sides[labelSide],
| |
| labelColorSideReverse = truthy.includes(data.labelColorSideReverse),
| |
| dividerSize = parseInt(data.dividerSize),
| |
| defaultTab = parseInt(data.defaultTab);
| |
| if(labelSide==="top"){
| |
| tabLabel.after(tabDivider);
| |
| tabDivider.after(tabContent);
| |
| }else if(labelSide==="bottom"){
| |
| tabContent.after(tabDivider);
| |
| tabDivider.after(tabLabel);
| |
| }
| |
| if (!isNaN(dividerSize) && dividerSize > 0) {
| |
| self.find(".TabDivider")[side.dividerSizeType](dividerSize);
| |
| }
| |
| var labelColorName = toUpperFirstCase(labelColorSideReverse ? side.labelColorSideReverse : side.labelColorSide);
| |
| self.addClass(side.className);
| |
| if (labelColorSideReverse) {
| |
| self.addClass("reverse");
| |
| }
| |
| 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 (getOwnPropertyNamesLength(styleSheet.label) > 0) {
| |
| 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 = toLowerFirstCase(n.replace(target, ""));
| |
| styleSheet[target][key] = data[n];
| |
| });
| |
| if (labelColor) {
| |
| styleSheet.label["border" + labelColorName + "Color"] = labelColor;
| |
| } else if (styleSheet.label.borderColor) {
| |
| styleSheet.label["border" + labelColorName + "Color"] = "green";
| |
| }
| |
| tabLabel.find(".selected").click();
| |
| if (getOwnPropertyNamesLength(styleSheet.text) > 0) {
| |
| tabContent.css(styleSheet.text);
| |
| }
| |
| if (data.autoWidth === "yes") {
| |
| self.addClass("AutoWidth");
| |
| }
| |
| if (data.float === "left") {
| |
| self.addClass("FloatLeft");
| |
| }
| |
| if (data.float === "right") {
| |
| self.addClass("FloatRight");
| |
| }
| |
|
| |
| });
| |
| });
| |
| });
| |
| //页顶提示模板相关 | | //页顶提示模板相关 |
| function commonBoxs() { | | function commonBoxs() { |
| 第265行: |
第50行: |
| } while (document.querySelector('a[data-linkid="' + result + '"]')); | | } while (document.querySelector('a[data-linkid="' + result + '"]')); |
| return result; | | return result; |
| }
| |
| //来自搜索引擎的访问默认跳转zh版
| |
| function searchReferrerJump() {
| |
| if (/\/\/www.(?:google|baidu|bing).com\//.test(document.referrer)) {
| |
| var mobileTags = ["Android", "iPhone", "SymbianOS", "Windows Phone", "iPod"];
| |
| if (!/\sVR\s/g.test(navigator.userAgent)) {
| |
| for (var i = 0, l = mobileTags.length; i < l; i++) {
| |
| if (navigator.userAgent.includes(mobileTags[i])) {
| |
| return;
| |
| }
| |
| }
| |
| var toggleLink = document.querySelector("#mw-mf-display-toggle");
| |
| window.location.replace(toggleLink.href);
| |
| }
| |
| }
| |
| } | | } |
| // Mobile Navmenu by GFwiki | | // Mobile Navmenu by GFwiki |
| 第298行: |
第68行: |
| }); | | }); |
| }; | | }; |
| | //需要时载入对应的 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"); } |
| $(function(){mfSidebar();}); | | $(function(){mfSidebar();}); |
| /* 函数执行体 */ | | /* 函数执行体 */ |
| $(function() { | | $(function() { |
| //来自搜索引擎的访问默认跳转桌面版
| |
| searchReferrerJump();
| |
| //页顶提示模板相关 | | //页顶提示模板相关 |
| commonBoxs(); | | commonBoxs(); |
| //用户资料页
| |
| if (isUserProfile()) {
| |
| var cardContainer = $('.card-container'),
| |
| containerImage = cardContainer.find('.card'),
| |
| containerImageFile = containerImage.find('a.image'),
| |
| containerImageCaption = containerImage.find('.caption');
| |
| containerImageCaption.css("padding", "0 8px");
| |
| containerImageFile.before('<div id="#containerImage" class="listThumb list-thumb-placeholder" style="text-align: center;"><img src="https://img.moegirl.org.cn/common/a/a4/Placeholder-upload.png" style="height:32px" /></div>');
| |
| }
| |
| //黑幕 | | //黑幕 |
| $('.heimu a').on("click", function() { | | $('.heimu a').on("click", function() { |
| 第328行: |
第89行: |
| if (ele instanceof HTMLAnchorElement) { | | if (ele instanceof HTMLAnchorElement) { |
| var url = new mw.Uri(ele.href); | | var url = new mw.Uri(ele.href); |
| if (/www\.hmoegirl\.com?$/.test(url.host) && url.query.mobileaction !== "toggle_view_desktop") { | | if (/www\.hmoegirl\.info?$/.test(url.host) && url.query.mobileaction !== "toggle_view_desktop") { |
| url.host = mw.config.get("wgServer").replace(/^(?:(?:https?:)?\/\/)?www/, "m"); | | url.host = mw.config.get("wgServer").replace(/^(?:(?:https?:)?\/\/)?www/, "m"); |
| ele.href = url; | | ele.href = url; |
| 第339行: |
第100行: |
| }); | | }); |
| })(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量 | | })(jQuery, mediaWiki); //立即执行匿名函数并传递原始变量 |
| | //页顶加入选项控制 |
| | if( mw.config.get('wgNamespaceNumber') != 2){ |
| | spanobj=document.createElement("span"); |
| | srch=document.getElementById("page-actions"); |
| | srch.parentElement.insertBefore(spanobj,srch); |
| | spanobj.innerHTML='<a href="#/talk">讨论</a> · <a href="' + mw.config.get('wgScript') + '?' + $.param({ title: mw.config.get('wgPageName'), action: 'info' }) +'">信息</a> · <a href="' + mw.config.get("wgServer") + mw.config.get("wgScriptPath") + '/特殊:链入页面/' + mw.config.get("wgPageName") + '">相关</a>'; |
| | } |
| // </pre> | | // </pre> |