mirror of
https://gitlab.com/vyla-entertainment/documentation.git
synced 2026-11-19 17:07:22 -05:00
rewrite
This commit is contained in:
146
src/js/main.js
146
src/js/main.js
@@ -4,16 +4,6 @@ var ICONS = {
|
||||
system: '<rect x="2" y="3" width="20" height="14" rx="2"/><path d="M8 21h8M12 17v4"/>',
|
||||
light: '<circle cx="12" cy="12" r="4"/><path d="M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M6.3 17.7l-1.4 1.4M19.1 4.9l-1.4 1.4"/>',
|
||||
dark: '<path d="M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"/>',
|
||||
midnight: '<path d="M12 2a10 10 0 1 0 10 10A10 10 0 0 1 12 2Z"/>',
|
||||
nord: '<path d="m2 12 5-5 5 5 5-5 5 5"/><path d="M12 7v14"/>',
|
||||
dracula: '<path d="M7 3v7l5 3 5-3V3"/><path d="M7 14l5 7 5-7"/>',
|
||||
forest: '<path d="m12 2 7 12h-4l3 6H6l3-6H5z"/>',
|
||||
sunset: '<path d="M17 18a5 5 0 0 0-10 0"/><path d="M12 2v4M4.22 10.22l2.83 2.83M1 18h4M19 18h4M16.95 13.05l2.83-2.83M12 13a5 5 0 0 0-5 5h10a5 5 0 0 0-5-5z"/>',
|
||||
cyberpunk: '<path d="M4 4h16v16H4z"/><path d="M4 9h16M9 4v16"/>',
|
||||
halloween: '<circle cx="12" cy="12" r="9"/><path d="M9 10h.01M15 10h.01M8 15s1.5 2 4 2 4-2 4-2"/><path d="M12 3v3"/>',
|
||||
christmas: '<path d="m12 3-5 7h3l-4 6h12l-4-6h3z"/><path d="M12 16v5"/>',
|
||||
autumn: '<path d="M11 20A7 7 0 0 1 9.8 6.1C15.5 5 17 4.48 19 2c1 2 2 4.18 2 8 0 5.5-4.78 10-10 10Z"/><path d="M2 21c0-3 1.85-5.36 5.08-6C9.5 14.52 12 13 13 12"/>',
|
||||
winter: '<path d="M12 2v20M4.93 7l14.14 10M4.93 17 19.07 7"/><path d="m9 4 3 2 3-2M9 20l3-2 3 2"/>',
|
||||
auto: '<rect x="3" y="5" width="18" height="16" rx="2"/><path d="M16 3v4M8 3v4M3 11h18"/>',
|
||||
sliders: '<path d="M4 6h10M18 6h2M4 12h4M12 12h8M4 18h12M20 18h0"/><circle cx="16" cy="6" r="2"/><circle cx="10" cy="12" r="2"/><circle cx="18" cy="18" r="2"/>',
|
||||
star: '<path d="m12 3 2.7 5.6 6.1.9-4.4 4.3 1 6.1L12 17l-5.4 2.9 1-6.1L3.2 9.5l6.1-.9z"/>',
|
||||
@@ -30,24 +20,12 @@ var ICONS = {
|
||||
|
||||
var THEMES_GENERAL = [
|
||||
{ id: "dark", label: "Dark" },
|
||||
{ id: "light", label: "Light" },
|
||||
{ id: "midnight", label: "Midnight" },
|
||||
{ id: "nord", label: "Nord" },
|
||||
{ id: "dracula", label: "Dracula" },
|
||||
{ id: "forest", label: "Forest" },
|
||||
{ id: "sunset", label: "Sunset" },
|
||||
{ id: "cyberpunk", label: "Cyberpunk" }
|
||||
{ id: "light", label: "Light" }
|
||||
];
|
||||
|
||||
var THEME_MEDIA = {
|
||||
dark: "/src/assets/images/wallpaper-media/tree.webp",
|
||||
light: "/src/assets/images/wallpaper-media/tree.webp",
|
||||
midnight: "/src/assets/images/wallpaper-media/tree.webp",
|
||||
nord: "/src/assets/images/wallpaper-media/tree.webp",
|
||||
dracula: "/src/assets/images/wallpaper-media/tree.webp",
|
||||
forest: "/src/assets/images/wallpaper-media/tree.webp",
|
||||
sunset: "/src/assets/images/wallpaper-media/tree.webp",
|
||||
cyberpunk: "/src/assets/images/wallpaper-media/tree.webp"
|
||||
light: "/src/assets/images/wallpaper-media/ocean.webp"
|
||||
};
|
||||
|
||||
var SITE_TREE = [
|
||||
@@ -92,21 +70,6 @@ var SITE_TREE = [
|
||||
"file": "/products/tv.md",
|
||||
"path": "/products/tv",
|
||||
"hasMedia": true
|
||||
},
|
||||
{
|
||||
"title": "Build a Player",
|
||||
"file": "/products/player.md",
|
||||
"path": "/products/player"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Concepts",
|
||||
"items": [
|
||||
{
|
||||
"title": "Providers",
|
||||
"file": "/concepts/providers.md",
|
||||
"path": "/concepts/providers"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -174,11 +137,6 @@ var SITE_TREE = [
|
||||
"title": "Stream API Overview",
|
||||
"file": "/stream-api/overview/index.md",
|
||||
"path": "/stream-api/overview"
|
||||
},
|
||||
{
|
||||
"title": "Authentication & Keys",
|
||||
"file": "/stream-api/authentication/index.md",
|
||||
"path": "/stream-api/authentication"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -215,50 +173,29 @@ var SITE_TREE = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "guides",
|
||||
"title": "Guides",
|
||||
"path": "/guides/integrations",
|
||||
"groups": [
|
||||
{
|
||||
"title": "Player Guides",
|
||||
"items": [
|
||||
{
|
||||
"title": "Client Integration",
|
||||
"file": "/guides/integrations.md",
|
||||
"path": "/guides/integrations"
|
||||
},
|
||||
{
|
||||
"title": "Error Handling",
|
||||
"file": "/guides/error-handling.md",
|
||||
"path": "/guides/error-handling"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "resources",
|
||||
"title": "Resources",
|
||||
"path": "/resources/faq",
|
||||
"path": "/misc/project/support-us",
|
||||
"groups": [
|
||||
{
|
||||
"title": "Reference & Help",
|
||||
"title": "Support Vyla",
|
||||
"items": [
|
||||
{
|
||||
"title": "Support Us",
|
||||
"file": "/misc/project/support-us.md",
|
||||
"path": "/misc/project/support-us",
|
||||
"hasMedia": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"title": "Help & Questions",
|
||||
"items": [
|
||||
{
|
||||
"title": "FAQ",
|
||||
"file": "/resources/faq.md",
|
||||
"path": "/resources/faq"
|
||||
},
|
||||
{
|
||||
"title": "Troubleshooting",
|
||||
"file": "/resources/troubleshooting.md",
|
||||
"path": "/resources/troubleshooting"
|
||||
},
|
||||
{
|
||||
"title": "Glossary",
|
||||
"file": "/resources/glossary.md",
|
||||
"path": "/resources/glossary"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -280,11 +217,6 @@ var SITE_TREE = [
|
||||
"file": "/misc/project/credit.md",
|
||||
"path": "/misc/project/credit"
|
||||
},
|
||||
{
|
||||
"title": "Support Us",
|
||||
"file": "/misc/project/support-us.md",
|
||||
"path": "/misc/project/support-us"
|
||||
},
|
||||
{
|
||||
"title": "DMCA Policy",
|
||||
"file": "/misc/project/DMCA.md",
|
||||
@@ -327,9 +259,7 @@ function applyTheme() {
|
||||
|
||||
|
||||
var targetSrc = THEME_MEDIA[theme] || THEME_MEDIA.dark;
|
||||
if (typeof window !== "undefined" && window.innerWidth <= 768 && targetSrc && targetSrc.indexOf("tree.webp") !== -1) {
|
||||
targetSrc = "/src/assets/images/wallpaper-media/tree-mobile.webp";
|
||||
}
|
||||
|
||||
var videosOff = getPref("video", "on") === "off";
|
||||
var isImageSource = /\.(jpe?g|png|gif|webp|avif|svg)(\?.*)?$/i.test(targetSrc || "");
|
||||
|
||||
@@ -1999,7 +1929,11 @@ function buildSearch() {
|
||||
'<input id="search-input" type="text" placeholder="Search..." autocomplete="off" spellcheck="false"></div>' +
|
||||
'<div id="search-results"></div><div class="search-footer"><span><kbd>↑</kbd><kbd>↓</kbd>Select</span><span><kbd>↵</kbd>Open</span><span class="close-hint"><kbd>esc</kbd>Close</span></div></div>';
|
||||
document.body.appendChild(modal);
|
||||
modal.querySelector(".search-backdrop").addEventListener("click", closeSearch);
|
||||
modal.addEventListener("click", function (e) {
|
||||
if (!e.target.closest(".search-panel")) {
|
||||
closeSearch();
|
||||
}
|
||||
});
|
||||
document.getElementById("search-input").addEventListener("input", function () { renderSearch(false); });
|
||||
document.getElementById("search-results").addEventListener("click", function (e) {
|
||||
var a = e.target.closest(".sr");
|
||||
@@ -2246,8 +2180,43 @@ function initContribSheet() {
|
||||
currentTranslate = closest;
|
||||
panel.style.transform = "translateY(" + closest + "px)";
|
||||
});
|
||||
}
|
||||
|
||||
setTimeout(openSheet, 400);
|
||||
function scrollToHeading(id) {
|
||||
if (!id) return;
|
||||
var el = document.getElementById(id);
|
||||
if (!el) return;
|
||||
var header = document.getElementById("header-container") || document.getElementById("navbar");
|
||||
var offset = header ? header.offsetHeight + 24 : 90;
|
||||
var topPos = el.getBoundingClientRect().top + window.pageYOffset - offset;
|
||||
window.scrollTo({ top: Math.max(0, topPos), behavior: "smooth" });
|
||||
if (window.history && window.history.pushState) {
|
||||
window.history.pushState(null, "", "#" + id);
|
||||
} else {
|
||||
window.location.hash = id;
|
||||
}
|
||||
}
|
||||
|
||||
function bindHeadingClicks() {
|
||||
document.addEventListener("click", function (e) {
|
||||
var heading = e.target.closest("main.prose h1, main.prose h2, main.prose h3, main.prose h4, main.prose h5, main.prose h6");
|
||||
if (heading && heading.id) {
|
||||
e.preventDefault();
|
||||
scrollToHeading(heading.id);
|
||||
return;
|
||||
}
|
||||
var hashLink = e.target.closest('a[href^="#"]');
|
||||
if (hashLink) {
|
||||
var href = hashLink.getAttribute("href");
|
||||
if (href && href.length > 1) {
|
||||
var targetId = href.slice(1);
|
||||
if (document.getElementById(targetId)) {
|
||||
e.preventDefault();
|
||||
scrollToHeading(targetId);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
@@ -2275,6 +2244,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
buildSettings();
|
||||
initEasterEggs();
|
||||
bindLightboxClicks();
|
||||
bindHeadingClicks();
|
||||
loadPage();
|
||||
|
||||
window.addEventListener("popstate", loadPage);
|
||||
|
||||
Reference in New Issue
Block a user