-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcustom.html
More file actions
97 lines (87 loc) · 4.74 KB
/
Copy pathcustom.html
File metadata and controls
97 lines (87 loc) · 4.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css?family=Roboto+Mono|Source+Sans+Pro:300,400,600" rel="stylesheet">
<meta name='zd-site-verification' content='xj9koofr1crilmoclgxsjd' />
<script type="text/javascript">
function setActiveClassForCurrentUrl() {
// Find all links in the navbarCollapse div where the href attribute is set to the current URL
let anchorTag = document.querySelector('#navbarCollapse a[href="' + window.location.href + '"]');
if (anchorTag) {
// Find the closest parent of the navigation
let parentUl = anchorTag.closest('li.nav-item')?.querySelector('a.nav-link');
if (parentUl) {
// Add active class to both the anchor tag and the parent ul
anchorTag.classList.add('active');
parentUl.classList.add('active');
}
}
}
window.addEventListener('popstate', setActiveClassForCurrentUrl);
window.addEventListener('hashchange', setActiveClassForCurrentUrl);
document.addEventListener("DOMContentLoaded", async function () {
const items = Array.from(document.querySelectorAll(".tag-filter-item"));
const filterUi = document.querySelector(".tag-filter-ui");
if (items.length === 0 || !filterUi) return;
const staticBadges = Array.from(document.querySelectorAll(".tag-filter-badge"));
const hasLiveProcesses = items.some((item) => item.hasAttribute("data-process"));
let support = null;
if (hasLiveProcesses) {
try {
const url = new URL("../../_data/backend_process_support.json", window.location.href);
const response = await fetch(url);
if (!response.ok) throw new Error(`HTTP ${response.status}`);
support = await response.json();
} catch (error) { console.warn("Could not load backend process support data.", error); }
}
const getExplicitTags = (item) => new Set((item.getAttribute("data-tags") || "").toLowerCase().split(/\s+/).filter(Boolean));
const getDefaultTags = () => new Set(staticBadges.map((badge) => badge.dataset.tag).filter(Boolean));
const getTags = (item) => {
const explicitTags = getExplicitTags(item);
if (support && item.hasAttribute("data-process")) {
const liveTags = new Set(item.getAttribute("data-process").split(/[\s,]+/).flatMap((id) => support.processes[id] || []));
return liveTags.size > 0 ? liveTags : explicitTags.size > 0 ? explicitTags : getDefaultTags();
}
return explicitTags.size > 0 ? explicitTags : getDefaultTags();
};
let badges = staticBadges;
if (support) {
const availableTags = [...new Set(items.flatMap((item) => [...getTags(item)]))].sort();
filterUi.replaceChildren();
badges = availableTags.map((tag) => {
const button = document.createElement("button");
button.className = "tag-filter-badge active";
button.dataset.tag = tag;
button.textContent = support.backends[tag]?.label || tag;
filterUi.appendChild(button);
return button;
});
}
if (badges.length === 0) return;
const tocLinks = Array.from(document.querySelectorAll("#TOC a[data-scroll-target]"));
const applyFilter = () => {
const selectedTags = new Set(badges.filter((badge) => badge.classList.contains("active")).map((badge) => badge.dataset.tag));
items.forEach((item) => {
const tags = getTags(item);
const visible = [...selectedTags].some((tag) => tags.has(tag));
item.hidden = !visible;
const tocLink = tocLinks.find((link) => link.dataset.scrollTarget === `#${item.id}`);
tocLink?.closest("li")?.toggleAttribute("hidden", !visible);
});
};
badges.forEach((badge) => badge.addEventListener("click", function (event) {
event.preventDefault(); this.classList.toggle("active"); this.classList.toggle("inactive"); applyFilter();
}));
applyFilter();
});
window.onload = () => {
const brand = document.querySelector('.navbar-brand');
if (brand) {
// Keep local/preview behavior, but use the GitHub Pages project root in production.
const brandHref = window.location.hostname === 'open-eo.github.io'
? '/openeo-docs/'
: '/index.html';
brand.setAttribute('href', brandHref);
}
setActiveClassForCurrentUrl();
}
</script>