-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.html
154 lines (137 loc) · 4.54 KB
/
index.html
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<!--
Angel/Azrae was here :3
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Discord Fonts</title>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" rel="stylesheet">
<link rel="icon" href="https://github.com/Rairof/Discord-Theme/blob/main/Icon.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-icons/1.11.3/font/bootstrap-icons.min.css">
<style>
:root {
--body-bg: #1e2124;
--body-color: #ffffff;
--link-color: #9fcdff;
--border-color: rgba(255,255,255,.125);
}
body {
background-color: var(--body-bg);
color: var(--body-color);
}
#item-list {
padding: 0;
}
#item-list li {
margin-bottom: 5px;
background-color: var(--body-bg);
border-color: var(--border-color);
}
#item-list a {
color: var(--link-color);
text-decoration: none;
transition: font-weight 0.1s cubic-bezier(.46,.03,.52,.96);
}
#item-list a:hover {
font-weight: bold;
}
.container {
margin-top: 50px;
}
.btn {
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col text-center">
<h1>List of Available Fonts <a
style="color: inherit; text-decoration: none;"
href="https://github.com/Rairof/Theme-Fonts/"
target="_blank"
>
<i class="bi bi-github"></i>
</a>
</h1>
</div>
</div>
<button id="theme-toggle" class="btn btn-primary">Toggle Theme</button>
<ul id="item-list" class="list-group"></ul>
</div>
<script>
// Predefined array of items to exclude from the list
const excludedItems = ['readme.md', "index.html", "assets", ".gitignore"];
const targetRepo = 'https://api.github.com/repos/Rairof/Theme-Fonts/contents';
function fetchItems(url, parentElement) {
fetch(url)
.then(response => response.json())
.then(data => {
data.forEach(item => {
if (!excludedItems.includes(item?.name?.toLowerCase?.())) {
const listItem = document.createElement('li');
listItem.classList.add('list-group-item');
const link = document.createElement('a');
const downloadLink = document.createElement('a');
const viewLink = document.createElement('a');
if (item.type === 'dir') {
const subListName = `sub_${item.name.replace(/\s+/g, '-')}`;
link.href = '#';
link.textContent = item.name;
link.onclick = function() {
const parent = document.getElementById(subListName);
if(parent) {
parent.replaceChildren()
parent.remove();
}
else {
const newSublist = document.createElement('ul');
newSublist.classList.add('list-group');
newSublist.id = subListName;
listItem.appendChild(newSublist);
fetchItems(item.url, newSublist);
}
};
listItem.appendChild(link);
}
else {
downloadLink.textContent = `Download ${item.name}`;
downloadLink.href = item.download_url;
downloadLink.target = "_blank";
listItem.appendChild(downloadLink);
viewLink.textContent = ` | View ${item.name}`;
viewLink.href = item.html_url;
viewLink.target = "_blank";
listItem.appendChild(viewLink);
}
parentElement.appendChild(listItem);
}
});
})
.catch(error => console.error('Error fetching data:', error));
}
// Initial fetch
fetchItems(targetRepo, document.getElementById('item-list'));
const themeToggle = document.getElementById('theme-toggle');
let isDarkMode = true;
themeToggle.addEventListener('click', () => {
const body = document.body;
if (isDarkMode) {
body.style.setProperty('--body-bg', '#ffffff');
body.style.setProperty('--body-color', '#000000');
body.style.setProperty('--link-color', '#007bff');
body.style.setProperty('--border-color', 'rgba(0,0,0,.125)');
} else {
body.style.setProperty('--body-bg', '#1e2124');
body.style.setProperty('--body-color', '#ffffff');
body.style.setProperty('--link-color', '#9fcdff');
body.style.setProperty('--border-color', 'rgba(255,255,255,.125)');
}
isDarkMode = !isDarkMode;
});
</script>
</body>
</html>