-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom.html
More file actions
87 lines (66 loc) · 3.02 KB
/
Copy pathcustom.html
File metadata and controls
87 lines (66 loc) · 3.02 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
<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", function () {
const badges = Array.from(document.querySelectorAll(".tag-filter-badge"));
const items = Array.from(document.querySelectorAll(".tag-filter-item"));
if (badges.length === 0 || items.length === 0) return;
const getTags = (item) => {
const fromDataAttr = (item.getAttribute("data-tags") || "")
.toLowerCase()
.split(/\s+/)
.filter(Boolean);
if (fromDataAttr.length > 0) {
return new Set(fromDataAttr);
}
const fromBadges = Array.from(item.querySelectorAll(".badge"))
.flatMap((el) => Array.from(el.classList))
.filter((cls) => cls.startsWith("badge-"))
.map((cls) => cls.replace("badge-", "").toLowerCase());
return new Set(fromBadges);
};
const applyFilter = () => {
const activeBadges = badges.filter((b) => b.classList.contains("active"));
const selectedTags = new Set(activeBadges.map((b) => b.getAttribute("data-tag")));
items.forEach((item) => {
const tags = getTags(item);
const visible = Array.from(selectedTags).some((tag) => tags.has(tag));
item.hidden = !visible;
});
};
badges.forEach((badge) => {
badge.addEventListener("click", function (e) {
e.preventDefault();
this.classList.toggle("active");
this.classList.toggle("inactive");
applyFilter();
});
});
applyFilter();
});
window.onload = () => {
const elems = document.getElementsByClassName('navbar-title');
if (elems.length > 0) {
const title = elems[0];
title.parentElement.href = '/index.html'
}
setActiveClassForCurrentUrl();
}
</script>