「MediaWiki:Gadget-UserLinkAvatar.js」の版間の差分
細 (// Edit Via InPageEdit) |
星海-interfacebot (トーク | 投稿記録) 細 (跨站同步) (タグ: Bot) |
||
1行目: | 1行目: | ||
− | $(function() { | + | /* <pre> */ |
− | + | /** | |
− | + | * ------------------------------------------------------------------------- | |
− | + | * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!! | |
− | + | * ------------------------------------------------------------------------- | |
− | + | */ | |
− | + | var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/UserLinkAvatar/MediaWiki:Gadget-UserLinkAvatar.js|user=[[U:AnnAngela]]|longId=232f0658e3594fb2db4ba1dfcccb7ee7db55cadc|shortId=232f065|message=fix(Gadget-UserLinkAvatar): Fix reference error}}'; | |
− | + | ||
− | + | "use strict"; | |
+ | (function () { | ||
+ | var magnifierOn = +mw.user.options.get("gadget-userLinkAvatarMagnifier", 0) === 1; | ||
+ | var $window = $(window); | ||
+ | var loadingImage = "https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif"; | ||
+ | $window.on("load.UserLinkAvatar", function () { | ||
+ | var images = []; | ||
+ | $(".mw-userlink:not(.user-avatar-added)").each(function (_, ele) { | ||
+ | var item = $(ele); | ||
+ | var src = "".concat(mw.config.get("wgServer").replace("zh.moegirl", "commons.moegirl")).concat(mw.config.get("wgScriptPath"), "/extensions/Avatar/avatar.php?user=").concat(encodeURIComponent(item.text())); | ||
+ | var img = $("<img/>").on("error", function () { | ||
+ | window.setTimeout(function () { | ||
+ | img.closest(".userlink-avatar").remove(); | ||
+ | }, 0); | ||
+ | }).addClass("userlink-avatar-small").attr({ | ||
+ | "data-src": src, | ||
+ | src: loadingImage | ||
+ | }); | ||
+ | images.push(img[0]); | ||
+ | var bigAvatar = $("<span/>").addClass("userlink-avatar"); | ||
+ | item.prepend(bigAvatar.append(img)); | ||
+ | item.addClass("user-avatar-added"); | ||
+ | if (magnifierOn) { | ||
+ | var magnifierImg_1 = $("<img/>", { | ||
+ | attr: { | ||
+ | "data-src": src, | ||
+ | src: loadingImage | ||
+ | }, | ||
+ | on: { | ||
+ | error: function () { | ||
+ | window.setTimeout(function () { | ||
+ | magnifierImg_1.closest(".userlink-avatar-large").remove(); | ||
+ | }, 0); | ||
+ | } | ||
+ | } | ||
+ | }); | ||
+ | images.push(magnifierImg_1[0]); | ||
+ | bigAvatar.on("click", function () { | ||
+ | window.open("".concat(mw.config.get("wgServer").replace("zh.moegirl", "commons.moegirl")).concat(mw.config.get("wgScriptPath"), "/index.php?title=Special%3A\u67E5\u770B\u5934\u50CF&user=").concat(encodeURIComponent(item.text())), "_blank"); | ||
+ | return false; | ||
+ | }).append($("<div/>", { | ||
+ | attr: { | ||
+ | "class": "userlink-avatar-large" | ||
+ | } | ||
+ | }).prepend(magnifierImg_1)).addClass("userlink-avatar-hover"); | ||
+ | item.before(bigAvatar); | ||
+ | bigAvatar.add(bigAvatar.children()).attr("title", "\u67E5\u770B\u7528\u6237".concat(item.text(), "\u7684\u5934\u50CF")); | ||
+ | } | ||
+ | }); | ||
+ | if (typeof window.lazyload === "function") { | ||
+ | window.lazyload(images); | ||
+ | } | ||
+ | else { | ||
+ | images.forEach(function (ele) { | ||
+ | ele.src = ele.dataset.src; | ||
+ | }); | ||
+ | } | ||
}); | }); | ||
− | + | $(function () { | |
− | + | $window.trigger("load.UserLinkAvatar"); | |
− | }); | + | }); |
+ | })(); | ||
+ | |||
+ | /* </pre> */ |
2022年9月6日 (火) 02:54時点における最新版
/* <pre> */ /** * ------------------------------------------------------------------------- * !!! DON'T MODIFY THIS PAGE MANUALLY, YOUR CHANGES WILL BE OVERWRITTEN !!! * ------------------------------------------------------------------------- */ var _addText = '{{GHIACode|page=GHIA:MoegirlPediaInterfaceCodes/blob/master/src/gadgets/UserLinkAvatar/MediaWiki:Gadget-UserLinkAvatar.js|user=[[U:AnnAngela]]|longId=232f0658e3594fb2db4ba1dfcccb7ee7db55cadc|shortId=232f065|message=fix(Gadget-UserLinkAvatar): Fix reference error}}'; "use strict"; (function () { var magnifierOn = +mw.user.options.get("gadget-userLinkAvatarMagnifier", 0) === 1; var $window = $(window); var loadingImage = "https://img.moegirl.org.cn/common/d/d1/Windows_10_loading.gif"; $window.on("load.UserLinkAvatar", function () { var images = []; $(".mw-userlink:not(.user-avatar-added)").each(function (_, ele) { var item = $(ele); var src = "".concat(mw.config.get("wgServer").replace("zh.moegirl", "commons.moegirl")).concat(mw.config.get("wgScriptPath"), "/extensions/Avatar/avatar.php?user=").concat(encodeURIComponent(item.text())); var img = $("<img/>").on("error", function () { window.setTimeout(function () { img.closest(".userlink-avatar").remove(); }, 0); }).addClass("userlink-avatar-small").attr({ "data-src": src, src: loadingImage }); images.push(img[0]); var bigAvatar = $("<span/>").addClass("userlink-avatar"); item.prepend(bigAvatar.append(img)); item.addClass("user-avatar-added"); if (magnifierOn) { var magnifierImg_1 = $("<img/>", { attr: { "data-src": src, src: loadingImage }, on: { error: function () { window.setTimeout(function () { magnifierImg_1.closest(".userlink-avatar-large").remove(); }, 0); } } }); images.push(magnifierImg_1[0]); bigAvatar.on("click", function () { window.open("".concat(mw.config.get("wgServer").replace("zh.moegirl", "commons.moegirl")).concat(mw.config.get("wgScriptPath"), "/index.php?title=Special%3A\u67E5\u770B\u5934\u50CF&user=").concat(encodeURIComponent(item.text())), "_blank"); return false; }).append($("<div/>", { attr: { "class": "userlink-avatar-large" } }).prepend(magnifierImg_1)).addClass("userlink-avatar-hover"); item.before(bigAvatar); bigAvatar.add(bigAvatar.children()).attr("title", "\u67E5\u770B\u7528\u6237".concat(item.text(), "\u7684\u5934\u50CF")); } }); if (typeof window.lazyload === "function") { window.lazyload(images); } else { images.forEach(function (ele) { ele.src = ele.dataset.src; }); } }); $(function () { $window.trigger("load.UserLinkAvatar"); }); })(); /* </pre> */