本网站正在建设中(~ ̄▽ ̄)~
- 你好~!欢迎来到中文歌声合成个人收集站-VCPedia.cn!
- 若发现页面信息有误或投稿至本站,请联系管理员。
MediaWiki:Common.js
跳到导航
跳到搜索
注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的变更的影响。
- Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5或Ctrl-R(Mac为⌘-R)
- Google Chrome:按Ctrl-Shift-R(Mac为⌘-Shift-R)
- Internet Explorer或Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
- Opera:按 Ctrl-F5。
- /* <pre> */
- /**
- * -------------------------------------------------------------------------
- * 此页面为全站的js常态加载脚本,如果你不知道你要修改的代码的作用和实现,请不要修改!
- * -------------------------------------------------------------------------
- */
- "use strict";
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
- };
- var __generator = (this && this.__generator) || function (thisArg, body) {
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
- function verb(n) { return function (v) { return step([n, v]); }; }
- function step(op) {
- if (f) throw new TypeError("Generator is already executing.");
- while (_) try {
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
- if (y = 0, t) op = [op[0] & 2, t.value];
- switch (op[0]) {
- case 0: case 1: t = op; break;
- case 4: _.label++; return { value: op[1], done: false };
- case 5: _.label++; y = op[1]; op = [0]; continue;
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
- default:
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
- if (t[2]) _.ops.pop();
- _.trys.pop(); continue;
- }
- op = body.call(thisArg, _);
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
- }
- };
- (function () { return __awaiter(void 0, void 0, void 0, function () {
- function startScroll() {
- $("body > #content > #siteNotice .scrollDiv:not(.scrolling), #moe-sitenotice-container > .moe-sitenotice .scrollDiv:not(.scrolling)").addClass("scrolling").each(function (_, ele) {
- var self = $(ele);
- self.children().each(function (_, child) {
- if (child.innerHTML.trim() === "") {
- child.remove();
- }
- });
- var children = self.children();
- if (children.length === 0) {
- return;
- }
- var firstChild = children.first();
- var firstChildHeight = firstChild.outerHeight();
- self.height(firstChildHeight);
- children.slice(1).css("top", "".concat(Math.ceil(firstChildHeight), "px"));
- firstChild.css("top", "0");
- });
- }
- function autoScroll() {
- setInterval(function () {
- if (!document.hidden) {
- $("body > #content > #siteNotice .scrollDiv.scrolling, #moe-sitenotice-container > .moe-sitenotice .scrollDiv.scrolling").each(function (_, ele) {
- var self = $(ele);
- if (self.css("font-weight") === "700") {
- return;
- }
- var children = self.children();
- var all = self.add(children);
- if (children.length === 1) {
- return;
- }
- var firstChild = children.first();
- var firstChildHeight = firstChild.outerHeight();
- var secondChild = firstChild.next();
- var secondChildHeight = secondChild.outerHeight();
- var otherChild = children.slice(2);
- var maxHeight = Math.max(firstChildHeight, secondChildHeight);
- otherChild.each(function (_, child) {
- maxHeight = Math.max(maxHeight, $(child).outerHeight());
- });
- all.addClass("animation");
- self.height(maxHeight);
- firstChild.css("top", "-".concat(firstChildHeight, "px"));
- secondChild.css("top", "".concat((maxHeight - secondChildHeight) / 2, "px"));
- otherChild.css("top", "".concat(Math.ceil(maxHeight), "px"));
- setTimeout(function () {
- all.removeClass("animation");
- firstChild.appendTo(self).css("top", Math.ceil(maxHeight));
- }, 400);
- });
- }
- }, 5000);
- }
- function multimediaViewer() {
- var _scrollTo = window.scrollTo;
- var flag = location.hash.startsWith("#/media/");
- window.scrollTo = function scrollTo(x_option, y) {
- if (flag) {
- console.info("Prevent multimediaViewer called");
- }
- else if (y === undefined) {
- _scrollTo(x_option);
- }
- else {
- _scrollTo(x_option, y);
- }
- };
- setInterval(function () {
- $("a.image img[data-file-width], a.image img[data-file-height], .mw-mmv-filepage-buttons a.mw-mmv-view-expanded").not(".multimediaViewerScrollSet").each(function (_, ele) {
- ele.addEventListener("click", function (e) {
- if ($(e.target).closest(".TabLabelText")[0] || $(e.target).closest("a").closest(".mw-customtoggle")[0]) {
- e.preventDefault();
- e.stopPropagation();
- e.stopImmediatePropagation();
- $($(e.target).closest(".TabLabelText")[0] || $(e.target).closest("a").closest(".mw-customtoggle")[0]).trigger("click");
- return false;
- }
- flag = true;
- }, {
- capture: true
- });
- $(ele).addClass("multimediaViewerScrollSet");
- });
- if (document.querySelector(".mw-mmv-close")) {
- if (mw.config.get("wgMultimediaViewerInjected") !== "on") {
- mw.config.set("wgMultimediaViewerInjected", "on");
- $(".mw-mmv-image").off("click")[0].addEventListener("click", function (e) {
- if ($(e.target).is("img")) {
- window.open($(e.target).attr("src").replace(/(img\.moegirl\.org\.cn\/common\/)thumb\/([a-z\d]+\/[a-z\d]+\/)([^/]+)\/\d+px-\3/i, "$1$2$3"), "_blank").focus();
- e.preventDefault();
- e.stopPropagation();
- e.stopImmediatePropagation();
- return false;
- }
- else if ($(e.target).closest(".error-box")[0]) {
- return;
- }
- $(".mw-mmv-close").trigger("click");
- }, {
- capture: true
- });
- }
- }
- else if (mw.config.get("wgMultimediaViewerInjected") === "on") {
- flag = false;
- mw.config.set("wgMultimediaViewerInjected", "off");
- }
- }, 137);
- }
- function noticeActivityClose() {
- return __awaiter(this, void 0, void 0, function () {
- var noticeActivity, topNoticeId_1, children_1, button_1, link_1, status_1, localStorageValue;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- noticeActivity = $("body > #content #notice-activity");
- if (!(noticeActivity.length > 0)) return [3, 2];
- return [4, mw.loader.using(["user.options"])];
- case 1:
- _a.sent();
- if (+mw.user.options.get("gadget-noticeActivity") === 1) {
- noticeActivity.hide();
- return [2];
- }
- topNoticeId_1 = noticeActivity.data("topNoticeId");
- noticeActivity.css("position", "relative");
- children_1 = noticeActivity.children();
- button_1 = $("<span>");
- button_1.css({
- position: "absolute",
- right: "1rem",
- top: "50%",
- transform: "translate(0,-50%)",
- fontSize: "1rem"
- });
- link_1 = $("<a>");
- link_1.attr({
- href: "javascript:void(0);"
- }).text("隐藏活动通知");
- button_1.append("[").append(link_1).append("]");
- noticeActivity.append(button_1);
- status_1 = true;
- link_1.on("click", function () {
- if (status_1) {
- status_1 = false;
- children_1.hide();
- noticeActivity.css({
- height: "0px",
- overflow: "visible"
- });
- button_1.css("transform", "translate(0,0)");
- localStorage.setItem("AnnTools-notice-activity", topNoticeId_1);
- link_1.text("显示活动通知");
- }
- else {
- status_1 = true;
- children_1.show();
- noticeActivity.css({
- height: "auto",
- overflow: "visible"
- });
- button_1.css("transform", "translate(0,-50%)");
- localStorage.removeItem("AnnTools-notice-activity");
- link_1.text("隐藏活动通知");
- }
- });
- localStorageValue = localStorage.getItem("AnnTools-notice-activity");
- if (localStorageValue === topNoticeId_1) {
- link_1.trigger("click");
- }
- _a.label = 2;
- case 2: return [2];
- }
- });
- });
- }
- function parseLocalStorageItemAsArray(key) {
- try {
- var result = JSON.parse(localStorage.getItem(key));
- return Array.isArray(result) ? result : [];
- }
- catch (_a) {
- return [];
- }
- }
- function topNoticeScroll() {
- var siteNotice = $("body.skin-vector > #content > #siteNotice, body.skin-moeskin > #app > #moe-full-container > #moe-main-container > main > #moe-global-sidenav #moe-sidenav-sitenotice");
- var noticeType = {
- pinnedAnnouncement: "置顶公告",
- newAnnouncement: "7日内新公告",
- discussing: "新的讨论中提案、申请",
- voting: "新的投票中提案、申请",
- voted: "新的已投票结束提案、申请",
- };
- var newNotices = [];
- Object.keys(noticeType).forEach(function (type){
- var id = type;
- var links = siteNotice.find("#topNotice-".concat(type)).find("a");
- var existLinks = parseLocalStorageItemAsArray("AnnTools-top-notice-exist-".concat(id));
- var currentLinks = [];
- var newLinks = [];
- links.each(function (_, link){
- var href = link.href;
- var text = link.text.trim();
- currentLinks.push(href);
- if (!existLinks.includes(href)) {
- newLinks.push({
- href: href,
- text: text,
- });
- }
- });
- localStorage.setItem("AnnTools-top-notice-exist-".concat(id), JSON.stringify(currentLinks));
- if (newLinks.length > 0) {
- newNotices.push({
- type: noticeType[id],
- links: newLinks,
- });
- }
- });
- if (newNotices.length > 0) {
- $("#mw-notification-area").appendTo("body");
- var notification_1 = $("<dl>");
- newNotices.forEach(function (newNotice) {
- notification_1.append("<dt class=\"mw-parser-output\" style=\"font-weight: 400;\">".concat(newNotice.type, "\uFF1A</dt>"));
- var dd = $("<dd>");
- var ul = $("<ul>");
- dd.css("marginLeft", ".9em");
- newNotice.links.forEach(function(link) {
- var li = $("<li>");
- var a = $("<a>");
- a.attr({
- href: link.href,
- target: "_blank",
- "class": "external",
- }).text(link.text);
- a.appendTo(li);
- li.appendTo(ul);
- });
- ul.appendTo(dd);
- dd.appendTo(notification_1);
- });
- notification_1.find("a").on("click",function(e) {
- e.stopImmediatePropagation();
- e.stopPropagation();
- });
- mw.notify(notification_1, {
- autoHide: false,
- title: "有新的站务通知(点击通知空白处关闭)",
- });
- }
- }
- function hashJump() {
- return __awaiter(this, void 0, void 0, function () {
- var hash;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0: return [4, mw.loader.using(["jquery.makeCollapsible"])];
- case 1:
- _a.sent();
- $(".mw-collapsible").makeCollapsible();
- hash = location.hash;
- location.hash = "";
- location.hash = hash;
- return [2];
- }
- });
- });
- }
- var copyRightsNameSpaces, wgUserGroups, isMGPMGUser, getResponseHeader;
- return __generator(this, function (_a) {
- switch (_a.label) {
- case 0:
- copyRightsNameSpaces = [
- 0,
- 4,
- 8,
- 10,
- 12,
- 274,
- 828,
- ];
- wgUserGroups = mw.config.get("wgUserGroups");
- isMGPMGUser = wgUserGroups.includes("patroller") || wgUserGroups.includes("sysop");
- getResponseHeader = XMLHttpRequest.prototype.getResponseHeader;
- XMLHttpRequest.prototype.getResponseHeader = function (name) {
- return "\n".concat(this.getAllResponseHeaders().toLowerCase()).includes("\n".concat(name.toLowerCase(), ": ")) ? getResponseHeader.bind(this)(name) : (console.info("Refused to get unsafe header \"".concat(name, "\"\n"), this, "\n", new Error().stack), null);
- };
- return [4, $.ready];
- case 1:
- _a.sent();
- startScroll();
- autoScroll();
- multimediaViewer();
- if (mw.config.get("wgMainPageTitle") === mw.config.get("wgPageName") && mw.config.get("wgAction") === "view") {
- $("body").addClass("mainpage");
- }
- $.extend({
- ucFirst: function (_s) {
- var s = "".concat(_s);
- return s.charAt(0).toUpperCase() + s.substring(1);
- }
- });
- $(".reference-text > ul,.reference-text > ol").each(function (_, ele) {
- if (ele.parentElement.childNodes[0] === ele) {
- $(ele).addClass("listInRef");
- }
- });
- if ($(".mw-collapsible")[0] && location.hash !== "") {
- hashJump();
- }
- noticeActivityClose();
- if (wgUserGroups.includes("user")) {
- topNoticeScroll();
- }
- $(window).on("load", function () {
- $(".mw-helplink").each(function (_, ele) {
- if (!ele.href.endsWith("/zh")) {
- ele.href += "/zh";
- }
- });
- });
- return [2];
- }
- });
- }); })();
- /* </pre> */