MediaWiki:Common.js: Difference between revisions
From VRChat Wiki
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
/** @license | |||
* This file is auto-generated. Do not edit directly. | |||
* @see https://github.com/vrchat-community/wiki-scripts/blob/main/src/index.ts | |||
*/ | |||
(() => { | (() => { | ||
var e = Object.defineProperty; | var e = Object.defineProperty; | ||
| Line 22: | Line 26: | ||
e.dataset.open = ""; | e.dataset.open = ""; | ||
}); | }); | ||
}); | }); | ||
let __vitePreload = function(e, t, n) { | let __vitePreload = function(e, t, n) { | ||
| Line 94: | Line 53: | ||
} | } | ||
var ArticleDialog; | var ArticleDialog; | ||
var | var t = __esmMin((() => { | ||
ArticleDialog = class extends OO.ui.ProcessDialog { | ArticleDialog = class extends OO.ui.ProcessDialog { | ||
constructor(e) { | constructor(e) { | ||
| Line 131: | Line 90: | ||
}]; | }]; | ||
})); | })); | ||
var | var n = __esmMin((() => {})); | ||
function asyncGeneratorStep(e, t, n, r, i, a, o) { | function asyncGeneratorStep(e, t, n, r, i, a, o) { | ||
try { | try { | ||
| Line 156: | Line 115: | ||
}; | }; | ||
} | } | ||
var | var r = __esmMin((() => {})); | ||
var | var i = /* @__PURE__ */ __export({}, 1); | ||
var o | var a, o; | ||
var | var s = __esmMin((() => { | ||
t(); | |||
n(); | n(); | ||
r(); | r(); | ||
a = document.querySelectorAll(".tpl-infopush"); | |||
o = new OO.ui.WindowManager(); | |||
$(document.body).append(o.$element); | |||
$(document.body).append( | for (let e of a) { | ||
for (let e of | |||
let t = e.querySelector(".tpl-infopush-content"); | let t = e.querySelector(".tpl-infopush-content"); | ||
let n = t.querySelectorAll(".tpl-infopush-item"); | let n = t.querySelectorAll(".tpl-infopush-item"); | ||
| Line 176: | Line 135: | ||
e.style.cursor = "pointer"; | e.style.cursor = "pointer"; | ||
e.addEventListener("click", _asyncToGenerator(function* () { | e.addEventListener("click", _asyncToGenerator(function* () { | ||
if (!(yield | if (!(yield o.getWindow(t.id).then(() => !0).catch(() => !1))) { | ||
let e = new ArticleDialog(t); | let e = new ArticleDialog(t); | ||
o.addWindows({ [t.id]: e }); | |||
} | } | ||
yield | yield o.openWindow(t.id).opening; | ||
})); | })); | ||
} | } | ||
| Line 189: | Line 148: | ||
t.style.transform = `translateX(-${a * 100}%)`; | t.style.transform = `translateX(-${a * 100}%)`; | ||
} | } | ||
let | let s; | ||
function resetAutoAdvance() { | function resetAutoAdvance() { | ||
s && clearInterval(s); | |||
s = setInterval(() => { | |||
showSlide(a + 1); | showSlide(a + 1); | ||
}, 5e3); | }, 5e3); | ||
| Line 208: | Line 167: | ||
} | } | ||
})); | })); | ||
isPage(["Template:MainPageInfopush", "Main_Page"]) && mw.loader.using(["oojs-ui-core", "oojs-ui-windows"]).then(() => __vitePreload(() => Promise.resolve().then(() => ( | isPage(["Template:MainPageInfopush", "Main_Page"]) && mw.loader.using(["oojs-ui-core", "oojs-ui-windows"]).then(() => __vitePreload(() => Promise.resolve().then(() => (s(), i)), void 0, {}.url)); | ||
var | var c = document.createElement("script"); | ||
c.setAttribute("defer", "defer"); | |||
c.setAttribute("data-domain", "wiki.vrchat.com"); | |||
c.setAttribute("event-page-name", mw.config.get("wgTitle")); | |||
c.setAttribute("event-page-language", mw.config.get("wgPageContentLanguage")); | |||
var | var l = mw.config.get("wgFormattedNamespaces"); | ||
c.setAttribute("event-page-namespace", l[mw.config.get("wgNamespaceNumber")]); | |||
c.setAttribute("event-theme", mw.config.get("skin")); | |||
c.setAttribute("event-action", mw.config.get("wgAction")); | |||
c.setAttribute("event-is-logged-in", String(mw.config.get("wgUserName") !== null)); | |||
var | var u = mw.config.get("wgUserGroups"); | ||
var | var d = u.includes("community-mod") || u.includes("moderator") || u.includes("sysop"); | ||
c.setAttribute("event-is-maintainer", String(d)); | |||
c.src = "https://plausible.io/js/script.pageview-props.outbound-links.js"; | |||
document.head.appendChild( | document.head.appendChild(c); | ||
})(); | })(); | ||
Revision as of 10:58, 10 January 2026
/** @license
* This file is auto-generated. Do not edit directly.
* @see https://github.com/vrchat-community/wiki-scripts/blob/main/src/index.ts
*/
(() => {
var e = Object.defineProperty;
var __esmMin = (e, t) => () => (e && (t = e(e = 0)), t);
var __export = (t, n) => {
let r = {};
for (var i in t) e(r, i, {
get: t[i],
enumerable: !0
});
n && e(r, Symbol.toStringTag, { value: "Module" });
return r;
};
function isPage(e) {
let [t, n] = mw.config.get("wgPageName").split("/");
if (!t || !e.includes(t)) return !1;
if (n && mw.config.get("wgPageContentLanguage") !== n) return !1;
return !0;
}
document.querySelectorAll(".spoiler").forEach((e) => {
let t = e.querySelector(".spoiler-overlay");
t == null || t.addEventListener("click", () => {
e.dataset.open = "";
});
});
let __vitePreload = function(e, t, n) {
let r = Promise.resolve();
function handlePreloadError(e) {
let t = new Event("vite:preloadError", { cancelable: !0 });
t.payload = e;
window.dispatchEvent(t);
if (!t.defaultPrevented) throw e;
}
return r.then((t) => {
for (let e of t || []) {
if (e.status !== "rejected") continue;
handlePreloadError(e.reason);
}
return e().catch(handlePreloadError);
});
};
function getArticleFromElement(e) {
let { articleId: t, articleTitle: n, articleContent: r } = e.dataset;
if (!t || !n || !r) return null;
return {
id: t,
title: n,
content: atob(r)
};
}
var ArticleDialog;
var t = __esmMin((() => {
ArticleDialog = class extends OO.ui.ProcessDialog {
constructor(e) {
super({
size: "large",
data: { title: e.title }
});
this.article = e;
}
initialize() {
super.initialize();
let e = new OO.ui.PanelLayout({
expanded: !1,
padded: !0,
scrollable: !0
});
e.$element.append(this.article.content);
this.$body.append(e.$element);
return this;
}
getActionProcess(e) {
switch (e) {
case "close": return new OO.ui.Process(() => {
this.close({ action: "close" });
});
}
return super.getActionProcess(e);
}
};
ArticleDialog.static.name = ArticleDialog.name;
ArticleDialog.static.actions = [{
action: "close",
flags: "safe",
icon: "close",
label: "Close"
}];
}));
var n = __esmMin((() => {}));
function asyncGeneratorStep(e, t, n, r, i, a, o) {
try {
var s = e[a](o), c = s.value;
} catch (e) {
n(e);
return;
}
s.done ? t(c) : Promise.resolve(c).then(r, i);
}
function _asyncToGenerator(e) {
return function() {
var t = this, n = arguments;
return new Promise(function(r, i) {
var a = e.apply(t, n);
function _next(e) {
asyncGeneratorStep(a, r, i, _next, _throw, "next", e);
}
function _throw(e) {
asyncGeneratorStep(a, r, i, _next, _throw, "throw", e);
}
_next(void 0);
});
};
}
var r = __esmMin((() => {}));
var i = /* @__PURE__ */ __export({}, 1);
var a, o;
var s = __esmMin((() => {
t();
n();
r();
a = document.querySelectorAll(".tpl-infopush");
o = new OO.ui.WindowManager();
$(document.body).append(o.$element);
for (let e of a) {
let t = e.querySelector(".tpl-infopush-content");
let n = t.querySelectorAll(".tpl-infopush-item");
let r = n.length;
for (let e of n) {
if (e.querySelector("a")) continue;
let t = getArticleFromElement(e);
if (!t) continue;
e.style.cursor = "pointer";
e.addEventListener("click", _asyncToGenerator(function* () {
if (!(yield o.getWindow(t.id).then(() => !0).catch(() => !1))) {
let e = new ArticleDialog(t);
o.addWindows({ [t.id]: e });
}
yield o.openWindow(t.id).opening;
}));
}
let i = e.querySelector(".tpl-infopush-navigation");
let a = 0;
function showSlide(e) {
a = (e + r) % r;
t.style.transform = `translateX(-${a * 100}%)`;
}
let s;
function resetAutoAdvance() {
s && clearInterval(s);
s = setInterval(() => {
showSlide(a + 1);
}, 5e3);
}
i.querySelector(".tpl-infopush-navigation-previous").addEventListener("click", () => {
showSlide(a - 1);
resetAutoAdvance();
});
i.querySelector(".tpl-infopush-navigation-next").addEventListener("click", () => {
showSlide(a + 1);
resetAutoAdvance();
});
resetAutoAdvance();
showSlide(0);
}
}));
isPage(["Template:MainPageInfopush", "Main_Page"]) && mw.loader.using(["oojs-ui-core", "oojs-ui-windows"]).then(() => __vitePreload(() => Promise.resolve().then(() => (s(), i)), void 0, {}.url));
var c = document.createElement("script");
c.setAttribute("defer", "defer");
c.setAttribute("data-domain", "wiki.vrchat.com");
c.setAttribute("event-page-name", mw.config.get("wgTitle"));
c.setAttribute("event-page-language", mw.config.get("wgPageContentLanguage"));
var l = mw.config.get("wgFormattedNamespaces");
c.setAttribute("event-page-namespace", l[mw.config.get("wgNamespaceNumber")]);
c.setAttribute("event-theme", mw.config.get("skin"));
c.setAttribute("event-action", mw.config.get("wgAction"));
c.setAttribute("event-is-logged-in", String(mw.config.get("wgUserName") !== null));
var u = mw.config.get("wgUserGroups");
var d = u.includes("community-mod") || u.includes("moderator") || u.includes("sysop");
c.setAttribute("event-is-maintainer", String(d));
c.src = "https://plausible.io/js/script.pageview-props.outbound-links.js";
document.head.appendChild(c);
})();