Files
ArtPlayer/docs/document/main.js
T

55 lines
3.5 KiB
JavaScript

// Generated by yarn build:site-assets. Do not edit.
(() => {
// packages/artplayer-vitepress/browser/navigation.ts
function isDevelopment(hostname) {
return ["localhost", "127.0.0.1", "[::1]", "::1"].includes(hostname.toLowerCase());
}
function runCodeUrl(location, libraries, code) {
const hostname = location.hostname === "::1" ? "[::1]" : location.hostname;
const origin = isDevelopment(hostname) ? `http://${hostname}:8082` : "https://artplayer.org";
return `${origin}/?libs=${encodeURIComponent(libraries)}&code=${encodeURIComponent(code)}`;
}
function languageDestination(url, language, initialized, englishPaths) {
const current = new URL(url);
if (initialized || isDevelopment(current.hostname) || language.toLowerCase().startsWith("zh") || !language || !current.pathname.startsWith("/document/"))
return { remember: false, target: null };
if (current.pathname.startsWith("/document/en/"))
return { remember: true, target: null };
const relative = current.pathname.slice("/document/".length);
const counterpart = englishPaths.includes(relative);
const target = new URL(counterpart ? `/document/en/${relative}` : "/document/en/", current.origin);
if (counterpart) {
target.search = current.search;
target.hash = current.hash;
}
return { remember: true, target: target.href };
}
function installNavigation(host, englishPaths) {
const marker = "run-code-init";
if (Reflect.get(host, marker))
return;
Reflect.set(host, marker, true);
host.document.addEventListener("click", (event) => {
const element = event.target instanceof Element ? event.target : null;
const button = element?.closest('.run-code, [classname="run-code"]');
const code = button?.nextElementSibling?.querySelector("pre code");
if (!(button instanceof HTMLElement) || !code)
return;
event.preventDefault();
const text = code.innerText ?? code.textContent ?? "";
host.open(runCodeUrl(host.location, button.dataset.libs || "", text));
});
try {
const result = languageDestination(host.location.href, host.navigator.language, !!host.localStorage.getItem("lang-init"), englishPaths);
if (result.remember)
host.localStorage.setItem("lang-init", "true");
if (result.target)
host.location.href = result.target;
} catch {
}
}
// <stdin>
installNavigation(window, ["advanced/built-in.html", "advanced/built-in", "advanced/class.html", "advanced/class", "advanced/event.html", "advanced/event", "advanced/global.html", "advanced/global", "advanced/plugin.html", "advanced/plugin", "advanced/property.html", "advanced/property", "component/contextmenu.html", "component/contextmenu", "component/controls.html", "component/controls", "component/layers.html", "component/layers", "component/setting.html", "component/setting", "", "index.html", "plugin/ambilight.html", "plugin/ambilight", "plugin/asr.html", "plugin/asr", "plugin/audio-track.html", "plugin/audio-track", "plugin/auto-thumbnail.html", "plugin/auto-thumbnail", "plugin/chapter.html", "plugin/chapter", "plugin/danmuku.html", "plugin/danmuku", "plugin/dash-control.html", "plugin/dash-control", "plugin/document-pip.html", "plugin/document-pip", "plugin/hls-control.html", "plugin/hls-control", "plugin/multiple-subtitles.html", "plugin/multiple-subtitles", "plugin/vtt-thumbnail.html", "plugin/vtt-thumbnail", "start/i18n.html", "start/i18n", "start/option.html", "start/option"]);
})();