查看“MediaWiki:Gadget-Navbox-link.js”的源代码
←
MediaWiki:Gadget-Navbox-link.js
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
该页提供此wiki软件的界面文字,它已被保护以防止恶意修改。如欲修改所有wiki的翻译,请到
translatewiki.net
上的MediaWiki本地化计划。
您可以查看与复制此页面的源代码。
// <pre> "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 () { if (mw.config.get("wgNamespaceNumber") !== 10 || $("#mw-content-text .navbox:not(.template-documentation .navbox)").length === 0) { return; } var pageNonExist = wgULS("(页面不存在)", "(頁面不存在)"); var wgPageName = mw.config.get("wgPageName"); var api = new mw.Api(); var targetLoc = $("<div>", { id: "not-listed-articles" }).hide(); var refresh = $("<a>", { href: "javascript:void(0)", title: wgULS("强制刷新", "強制重新整理"), id: "not-listed-articles-refresh", text: wgULS("未添加本模版的条目(点击刷新)", "未新增本模版的條目(點選重新整理)", null, null, "未新增本模版的條目(點擊重新整理)") }); targetLoc.append("<hr>"); $("#catlinks").append(targetLoc); var targetUl = $("<ul>", { id: "not-listed-articles-list" }); targetLoc.append(refresh).append(":").append(targetUl); var generateSelector = function (_title, redirects) { var title = _title.replace(/"/g, '\\"'); var selector = "a[title=\"".concat(title, "\"], a[title=\"").concat(title).concat(pageNonExist, "\"], a[data-title=\"").concat(title, "\"], a[data-title=\"").concat(title).concat(pageNonExist, "\"]"); if (typeof redirects[title] === "string") { selector += ", a[title=\"".concat(redirects[title], "\"], a[title=\"").concat(redirects[title]).concat(pageNonExist, "\"], a[data-title=\"").concat(redirects[title], "\"], a[data-title=\"").concat(redirects[title]).concat(pageNonExist, "\"]"); } return selector; }; refresh.on("click", function (e) { return __awaiter(void 0, void 0, void 0, function () { var result, redirects_1, _loop_1, _i, _a, _b, templates, missing, title; return __generator(this, function (_c) { switch (_c.label) { case 0: e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); return [4 /*yield*/, api.post({ action: "query", redirects: "true", generator: "links", gplnamespace: "0", gpllimit: "max", prop: "templates", tllimit: "max", tlnamespace: "10", tltemplates: wgPageName, titles: wgPageName })]; case 1: result = _c.sent(); targetUl.empty(); if (!result.query) { targetUl.text(wgULS("本模板未被任何条目嵌入", "本模板未被任何條目引用")); } else { redirects_1 = Object.fromEntries((result.query.redirects || []).map(function (_a) { var from = _a.from, to = _a.to; return [from, to]; })); _loop_1 = function (templates, missing, title) { if (!Array.isArray(templates) && typeof missing === "undefined") { var link = $("<a>", { title: title, text: title, href: "/".concat(encodeURIComponent(title)) }); $("<li>").append(link).appendTo(targetUl); $(generateSelector(title, redirects_1)).each(function (_, ele) { if (ele.title.length > 0) { ele.dataset.title = ele.title; } }); link.on("mouseenter", function () { $(generateSelector(title, redirects_1)).css("background-color", "yellow"); }); link.on("mouseleave", function () { $(generateSelector(title, redirects_1)).css("background-color", ""); }); } }; for (_i = 0, _a = Object.values(result.query.pages); _i < _a.length; _i++) { _b = _a[_i], templates = _b.templates, missing = _b.missing, title = _b.title; _loop_1(templates, missing, title); } if (targetUl.children().length === 0) { targetUl.text(wgULS("本模板所有条目均添加了本模板", "本模板所有條目均添加了本模板")); } } targetLoc.show(); return [2 /*return*/]; } }); }); }).trigger("click"); }); // </pre>
返回至
MediaWiki:Gadget-Navbox-link.js
。
导航菜单
个人工具
登录
名字空间
消息
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
导航
首页
随机页面
最近更改
最新文件
常用
上传多个文件
工具
链入页面
相关更改
特殊页面
页面信息