MediaWiki:Common.js: Difference between revisions

From VRChat Wiki
No edit summary
No edit summary
Line 1: Line 1:
(() => {
(() => {
var __defProp = Object.defineProperty;
var e = Object.defineProperty, __esmMin = (e, t) => () => (e && (t = e(e = 0)), t), __export = (t, n) => {
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
let r = {};
var __export = (all, symbols) => {
for (var i in t) e(r, i, {
let target = {};
get: t[i],
for (var name in all) __defProp(target, name, {
enumerable: !0
get: all[name],
enumerable: true
});
});
if (symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
return n && e(r, Symbol.toStringTag, { value: "Module" }), r;
return target;
};
};
function isPage(pages) {
function isPage(e) {
const [pageName, pageLanguage] = mw.config.get("wgPageName").split("/");
let [t, n] = mw.config.get("wgPageName").split("/");
if (!pageName || !pages.includes(pageName)) return false;
return !(!t || !e.includes(t) || n && mw.config.get("wgPageContentLanguage") != n);
if (pageLanguage && mw.config.get("wgPageContentLanguage") != pageLanguage) return false;
return true;
}
}
[...document.querySelectorAll(".spoiler")].map((container) => {
[...document.querySelectorAll(".spoiler")].map((e) => {
const overlay = container.querySelector(".spoiler-overlay");
e.querySelector(".spoiler-overlay")?.addEventListener("click", () => {
overlay === null || overlay === void 0 || overlay.addEventListener("click", () => {
e.dataset.open = "";
container.dataset.open = "";
});
});
});
});
function _objectWithoutPropertiesLoose(r, e) {
function _objectWithoutPropertiesLoose(e, t) {
if (null == r) return {};
if (e == null) return {};
var t = {};
var n = {};
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
if (e.includes(n)) continue;
if (t.includes(r)) continue;
t[n] = r[n];
n[r] = e[r];
}
}
return t;
return n;
}
}
function _objectWithoutProperties(e, t) {
function _objectWithoutProperties(e, t) {
if (null == e) return {};
if (e == null) return {};
var o, r, i = _objectWithoutPropertiesLoose(e, t);
var n, r, i = _objectWithoutPropertiesLoose(e, t);
if (Object.getOwnPropertySymbols) {
if (Object.getOwnPropertySymbols) {
var s = Object.getOwnPropertySymbols(e);
var a = Object.getOwnPropertySymbols(e);
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
for (r = 0; r < a.length; r++) n = a[r], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
}
}
return i;
return i;
}
}
var _excluded = ["videoId"];
var t = ["videoId"];
[...document.querySelectorAll(".youtube")].map((element) => {
[...document.querySelectorAll(".youtube")].map((e) => {
const _element$dataset = element.dataset, { videoId } = _element$dataset, attributes = _objectWithoutProperties(_element$dataset, _excluded);
let n = e.dataset, { videoId: r } = n, i = _objectWithoutProperties(n, t), a = document.createElement("iframe");
const iframe = document.createElement("iframe");
a.setAttribute("width", "560"), a.setAttribute("height", "315"), a.setAttribute("frameborder", "0"), a.setAttribute("allow", [
iframe.setAttribute("width", String(560));
iframe.setAttribute("height", String(315));
iframe.setAttribute("frameborder", String(0));
iframe.setAttribute("allow", [
"accelerometer",
"accelerometer",
"autoplay",
"autoplay",
Line 56: Line 46:
"picture-in-picture",
"picture-in-picture",
"web-share"
"web-share"
].join("; "));
].join("; ")), a.setAttribute("referrerpolicy", "strict-origin-when-cross-origin"), a.setAttribute("allowfullscreen", "true"), Object.entries(i).map(([e, t]) => t && a.setAttribute(e, t)), a.setAttribute("style", e.getAttribute("style") || ""), a.src = `https://www.youtube-nocookie.com/embed/${r}?rel=0`, e.replaceWith(a);
iframe.setAttribute("referrerpolicy", "strict-origin-when-cross-origin");
iframe.setAttribute("allowfullscreen", String(true));
Object.entries(attributes).map(([key, value]) => value && iframe.setAttribute(key, value));
iframe.setAttribute("style", element.getAttribute("style") || "");
iframe.src = `https://www.youtube-nocookie.com/embed/${videoId}?rel=0`;
element.replaceWith(iframe);
});
});
const __vitePreload = function preload(baseModule, deps, importerUrl) {
let __vitePreload = function(e, t, n) {
let promise = Promise.resolve();
let r = Promise.resolve();
function handlePreloadError(err$2) {
function handlePreloadError(e) {
const e$1 = new Event("vite:preloadError", { cancelable: true });
let t = new Event("vite:preloadError", { cancelable: !0 });
e$1.payload = err$2;
if (t.payload = e, window.dispatchEvent(t), !t.defaultPrevented) throw e;
window.dispatchEvent(e$1);
if (!e$1.defaultPrevented) throw err$2;
}
}
return promise.then((res) => {
return r.then((t) => {
for (const item of res || []) {
for (let e of t || []) e.status === "rejected" && handlePreloadError(e.reason);
if (item.status !== "rejected") continue;
return e().catch(handlePreloadError);
handlePreloadError(item.reason);
}
return baseModule().catch(handlePreloadError);
});
});
};
};
function getArticleFromElement(element) {
function getArticleFromElement(e) {
const { articleId, articleTitle, articleContent } = element.dataset;
let { articleId: t, articleTitle: n, articleContent: r } = e.dataset;
if (!articleId || !articleTitle || !articleContent) return null;
return !t || !n || !r ? null : {
return {
id: t,
id: articleId,
title: n,
title: articleTitle,
content: atob(r)
content: atob(articleContent)
};
};
}
}
var ArticleDialog;
var ArticleDialog, n = __esmMin((() => {
var init_article = __esmMin((() => {
ArticleDialog = class extends OO.ui.ProcessDialog {
ArticleDialog = class extends OO.ui.ProcessDialog {
constructor(article) {
constructor(e) {
super({ size: "large" });
super({
this.article = article;
size: "large",
data: { title: e.title }
}), this.article = e;
}
}
initialize() {
initialize() {
super.initialize();
super.initialize();
const content = new OO.ui.PanelLayout({
let e = new OO.ui.PanelLayout({
expanded: false,
expanded: !1,
padded: true,
padded: !0,
scrollable: true
scrollable: !0
});
});
content.$element.append(this.article.htmlContent);
return e.$element.append(this.article.content), this.$body.append(e.$element), this;
this.$content.append(content.$element);
return this;
}
}
getActionProcess(action) {
getActionProcess(e) {
switch (action) {
switch (e) {
case "close": return new OO.ui.Process(() => {
case "close": return new OO.ui.Process(() => {
this.close({ action: "close" });
this.close({ action: "close" });
});
});
}
}
return super.getActionProcess(action);
return super.getActionProcess(e);
}
}
};
}, ArticleDialog.static.name = ArticleDialog.name, ArticleDialog.static.actions = [{
ArticleDialog.static.name = ArticleDialog.name;
ArticleDialog.static.title = "Article Aaa";
ArticleDialog.static.actions = [{
action: "close",
action: "close",
flags: "safe",
flags: "safe",
Line 124: Line 98:
label: "Close"
label: "Close"
}];
}];
}));
})), r = __esmMin((() => {}));
var init_infopush$1 = __esmMin((() => {}));
function asyncGeneratorStep(e, t, n, r, i, a, o) {
function asyncGeneratorStep(n, t, e, r, o, a, c) {
try {
try {
var i = n[a](c), u = i.value;
var s = e[a](o), c = s.value;
} catch (n$1) {
} catch (e) {
e(n$1);
n(e);
return;
return;
}
}
i.done ? t(u) : Promise.resolve(u).then(r, o);
s.done ? t(c) : Promise.resolve(c).then(r, i);
}
}
function _asyncToGenerator(n) {
function _asyncToGenerator(e) {
return function() {
return function() {
var t = this, e = arguments;
var t = this, n = arguments;
return new Promise(function(r, o) {
return new Promise(function(r, i) {
var a = n.apply(t, e);
var a = e.apply(t, n);
function _next(n$1) {
function _next(e) {
asyncGeneratorStep(a, r, o, _next, _throw, "next", n$1);
asyncGeneratorStep(a, r, i, _next, _throw, "next", e);
}
}
function _throw(n$1) {
function _throw(e) {
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n$1);
asyncGeneratorStep(a, r, i, _next, _throw, "throw", e);
}
}
_next(void 0);
_next(void 0);
Line 150: Line 123:
};
};
}
}
var init_asyncToGenerator = __esmMin((() => {}));
var i = __esmMin((() => {})), a = /* @__PURE__ */ __export({}, 1), o, s, c = __esmMin((() => {
var infopush_exports = /* @__PURE__ */ __export({}, 1);
n(), r(), i(), o = document.querySelectorAll(".tpl-infopush"), console.log({ infopushes: o }), s = new OO.ui.WindowManager(), $(document.body).append(s.$element);
var infopushes, windowManager;
for (let e of o) {
var init_infopush = __esmMin((() => {
let t = e.querySelector(".tpl-infopush-content"), n = t.querySelectorAll(".tpl-infopush-item"), r = n.length;
init_article();
for (let e of n) {
init_infopush$1();
if (e.querySelector("a")) continue;
init_asyncToGenerator();
let t = getArticleFromElement(e);
infopushes = document.querySelectorAll(".tpl-infopush");
t && (e.style.cursor = "pointer", e.addEventListener("click", _asyncToGenerator(function* () {
console.log({ infopushes });
if (!(yield s.getWindow(t.id).then(() => !0).catch(() => !1))) {
windowManager = new OO.ui.WindowManager();
let e = new ArticleDialog(t);
$(document.body).append(windowManager.$element);
s.addWindows({ [t.id]: e });
for (const infopush of infopushes) {
const content = infopush.querySelector(".tpl-infopush-content");
const items = content.querySelectorAll(".tpl-infopush-item");
const total = items.length;
for (const item of items) {
if (!!item.querySelector("a")) continue;
const article = getArticleFromElement(item);
if (!article) continue;
item.style.cursor = "pointer";
item.addEventListener("click", _asyncToGenerator(function* () {
if (!windowManager.getWindow(article.id)) {
const articleDialog = new ArticleDialog(article);
windowManager.addWindows({ [article.id]: articleDialog });
}
}
yield windowManager.openWindow(article.id);
yield s.openWindow(t.id).opening;
}));
})));
}
}
const navigation = infopush.querySelector(".tpl-infopush-navigation");
let i = e.querySelector(".tpl-infopush-navigation"), a = 0;
let currentOffset = 0;
function showSlide(e) {
function showSlide(index) {
a = (e + r) % r, t.style.transform = `translateX(-${a * 100}%)`;
currentOffset = (index + total) % total;
content.style.transform = `translateX(-${currentOffset * 100}%)`;
}
}
const autoAdvanceEvery = 5e3;
let o;
let autoAdvanceInterval;
function resetAutoAdvance() {
function resetAutoAdvance() {
if (autoAdvanceInterval) clearInterval(autoAdvanceInterval);
o && clearInterval(o), o = setInterval(function() {
autoAdvanceInterval = setInterval(function() {
showSlide(a + 1);
showSlide(currentOffset + 1);
}, 5e3);
}, autoAdvanceEvery);
}
}
navigation.querySelector(".tpl-infopush-navigation-previous").addEventListener("click", () => {
i.querySelector(".tpl-infopush-navigation-previous").addEventListener("click", () => {
showSlide(currentOffset - 1);
showSlide(a - 1), resetAutoAdvance();
resetAutoAdvance();
}), i.querySelector(".tpl-infopush-navigation-next").addEventListener("click", () => {
});
showSlide(a + 1), resetAutoAdvance();
navigation.querySelector(".tpl-infopush-navigation-next").addEventListener("click", () => {
}), resetAutoAdvance(), showSlide(0);
showSlide(currentOffset + 1);
resetAutoAdvance();
});
resetAutoAdvance();
showSlide(0);
}
}
}));
}));
if (isPage(["Template:MainPageInfopush", "Main_Page"])) mw.loader.using(["oojs-ui-core", "oojs-ui-windows"]).then(() => __vitePreload(() => Promise.resolve().then(() => (init_infopush(), infopush_exports)), void 0, {}.url));
isPage(["Template:MainPageInfopush", "Main_Page"]) && mw.loader.using(["oojs-ui-core", "oojs-ui-windows"]).then(() => __vitePreload(() => Promise.resolve().then(() => (c(), a)), void 0, {}.url));
var script = document.createElement("script");
var l = document.createElement("script");
script.setAttribute("defer", "defer");
l.setAttribute("defer", "defer"), l.setAttribute("data-domain", "wiki.vrchat.com"), l.setAttribute("event-page-name", mw.config.get("wgTitle")), l.setAttribute("event-page-language", mw.config.get("wgPageContentLanguage"));
script.setAttribute("data-domain", "wiki.vrchat.com");
var u = mw.config.get("wgFormattedNamespaces");
script.setAttribute("event-page-name", mw.config.get("wgTitle"));
l.setAttribute("event-page-namespace", u[mw.config.get("wgNamespaceNumber")]), l.setAttribute("event-theme", mw.config.get("skin")), l.setAttribute("event-action", mw.config.get("wgAction")), l.setAttribute("event-is-logged-in", String(mw.config.get("wgUserName") !== null));
script.setAttribute("event-page-language", mw.config.get("wgPageContentLanguage"));
var d = mw.config.get("wgUserGroups"), f = d.includes("community-mod") || d.includes("moderator") || d.includes("sysop");
var namespaces = mw.config.get("wgFormattedNamespaces");
l.setAttribute("event-is-maintainer", String(f)), l.src = "https://plausible.io/js/script.pageview-props.outbound-links.js", document.head.appendChild(l);
script.setAttribute("event-page-namespace", namespaces[mw.config.get("wgNamespaceNumber")]);
script.setAttribute("event-theme", mw.config.get("skin"));
script.setAttribute("event-action", mw.config.get("wgAction"));
script.setAttribute("event-is-logged-in", String(mw.config.get("wgUserName") !== null));
var wgUserGroups = mw.config.get("wgUserGroups");
var maintainer = wgUserGroups.includes("community-mod") || wgUserGroups.includes("moderator") || wgUserGroups.includes("sysop");
script.setAttribute("event-is-maintainer", String(maintainer));
script.src = "https://plausible.io/js/script.pageview-props.outbound-links.js";
document.head.appendChild(script);
})();
})();

Revision as of 13:51, 13 December 2025

(() => {
	var e = Object.defineProperty, __esmMin = (e, t) => () => (e && (t = e(e = 0)), t), __export = (t, n) => {
		let r = {};
		for (var i in t) e(r, i, {
			get: t[i],
			enumerable: !0
		});
		return n && e(r, Symbol.toStringTag, { value: "Module" }), r;
	};
	function isPage(e) {
		let [t, n] = mw.config.get("wgPageName").split("/");
		return !(!t || !e.includes(t) || n && mw.config.get("wgPageContentLanguage") != n);
	}
	[...document.querySelectorAll(".spoiler")].map((e) => {
		e.querySelector(".spoiler-overlay")?.addEventListener("click", () => {
			e.dataset.open = "";
		});
	});
	function _objectWithoutPropertiesLoose(e, t) {
		if (e == null) return {};
		var n = {};
		for (var r in e) if ({}.hasOwnProperty.call(e, r)) {
			if (t.includes(r)) continue;
			n[r] = e[r];
		}
		return n;
	}
	function _objectWithoutProperties(e, t) {
		if (e == null) return {};
		var n, r, i = _objectWithoutPropertiesLoose(e, t);
		if (Object.getOwnPropertySymbols) {
			var a = Object.getOwnPropertySymbols(e);
			for (r = 0; r < a.length; r++) n = a[r], t.includes(n) || {}.propertyIsEnumerable.call(e, n) && (i[n] = e[n]);
		}
		return i;
	}
	var t = ["videoId"];
	[...document.querySelectorAll(".youtube")].map((e) => {
		let n = e.dataset, { videoId: r } = n, i = _objectWithoutProperties(n, t), a = document.createElement("iframe");
		a.setAttribute("width", "560"), a.setAttribute("height", "315"), a.setAttribute("frameborder", "0"), a.setAttribute("allow", [
			"accelerometer",
			"autoplay",
			"clipboard-write",
			"encrypted-media",
			"gyroscope",
			"picture-in-picture",
			"web-share"
		].join("; ")), a.setAttribute("referrerpolicy", "strict-origin-when-cross-origin"), a.setAttribute("allowfullscreen", "true"), Object.entries(i).map(([e, t]) => t && a.setAttribute(e, t)), a.setAttribute("style", e.getAttribute("style") || ""), a.src = `https://www.youtube-nocookie.com/embed/${r}?rel=0`, e.replaceWith(a);
	});
	let __vitePreload = function(e, t, n) {
		let r = Promise.resolve();
		function handlePreloadError(e) {
			let t = new Event("vite:preloadError", { cancelable: !0 });
			if (t.payload = e, window.dispatchEvent(t), !t.defaultPrevented) throw e;
		}
		return r.then((t) => {
			for (let e of t || []) e.status === "rejected" && handlePreloadError(e.reason);
			return e().catch(handlePreloadError);
		});
	};
	function getArticleFromElement(e) {
		let { articleId: t, articleTitle: n, articleContent: r } = e.dataset;
		return !t || !n || !r ? null : {
			id: t,
			title: n,
			content: atob(r)
		};
	}
	var ArticleDialog, n = __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
				});
				return e.$element.append(this.article.content), this.$body.append(e.$element), 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"
		}];
	})), r = __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 i = __esmMin((() => {})), a = /* @__PURE__ */ __export({}, 1), o, s, c = __esmMin((() => {
		n(), r(), i(), o = document.querySelectorAll(".tpl-infopush"), console.log({ infopushes: o }), s = new OO.ui.WindowManager(), $(document.body).append(s.$element);
		for (let e of o) {
			let t = e.querySelector(".tpl-infopush-content"), n = t.querySelectorAll(".tpl-infopush-item"), r = n.length;
			for (let e of n) {
				if (e.querySelector("a")) continue;
				let t = getArticleFromElement(e);
				t && (e.style.cursor = "pointer", e.addEventListener("click", _asyncToGenerator(function* () {
					if (!(yield s.getWindow(t.id).then(() => !0).catch(() => !1))) {
						let e = new ArticleDialog(t);
						s.addWindows({ [t.id]: e });
					}
					yield s.openWindow(t.id).opening;
				})));
			}
			let i = e.querySelector(".tpl-infopush-navigation"), a = 0;
			function showSlide(e) {
				a = (e + r) % r, t.style.transform = `translateX(-${a * 100}%)`;
			}
			let o;
			function resetAutoAdvance() {
				o && clearInterval(o), o = setInterval(function() {
					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(() => (c(), a)), void 0, {}.url));
	var l = document.createElement("script");
	l.setAttribute("defer", "defer"), l.setAttribute("data-domain", "wiki.vrchat.com"), l.setAttribute("event-page-name", mw.config.get("wgTitle")), l.setAttribute("event-page-language", mw.config.get("wgPageContentLanguage"));
	var u = mw.config.get("wgFormattedNamespaces");
	l.setAttribute("event-page-namespace", u[mw.config.get("wgNamespaceNumber")]), l.setAttribute("event-theme", mw.config.get("skin")), l.setAttribute("event-action", mw.config.get("wgAction")), l.setAttribute("event-is-logged-in", String(mw.config.get("wgUserName") !== null));
	var d = mw.config.get("wgUserGroups"), f = d.includes("community-mod") || d.includes("moderator") || d.includes("sysop");
	l.setAttribute("event-is-maintainer", String(f)), l.src = "https://plausible.io/js/script.pageview-props.outbound-links.js", document.head.appendChild(l);
})();