Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
192 lines (172 loc) · 4.52 KB
/
Copy pathindex.html
File metadata and controls
192 lines (172 loc) · 4.52 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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!--
Angel/Azrae was here :3
So was Moodle :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 {
--bg-primary: #0f0e11;
--bg-secondary: #080608;
--txt: #fbfbfb;
--accent: #c2789b;
--link-color: #ffbaf2;
--border-color: #4f3b47;
}
body {
background-image: url(https://raw.githubusercontent.com/Rairof/Discord-Theme/main/Wallpapers/RosieDarkBG.png);
size: 150%;
}
.font-group {
padding: 10px;
background-color: transparent;
border: 1px solid var(--border-color);
border-radius: 20px;
margin-bottom: 10px;
}
.title {
color: var(--txt);
text-align: center;
padding-top: 15px;
}
.font-title {
text-align: center;
padding-bottom: 10px;
}
.container {
margin-top: 50px;
color: var(--txt);
}
.preview-container {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-column-gap: 5px;
grid-row-gap: 25px;
}
.img-wrapper {
max-width: 75%;
width: 100%;
}
.copy-snippet-url {
border-radius: 25px;
background-color: var(--accent);
color: var(--txt);
border: none;
width: 100%;
height: 35px;
}
.summary-text {
text-align: center;
padding-top: 5px;
border-radius: 25px;
background-color: #2b232f;
color: var(--txt);
border: 1.5px solid #39343f;
width: 100%;
height: 35px;
margin-top: 10px;
}
@media screen and (max-width: 800px) {
.preview-container {
grid-template-columns: repeat(1, 1fr);
}
.img-wrapper {
flex: 50%;
max-width: 50%;
}
}
/* Responsive layout - makes the two columns stack on top of each other instead of next to each other */
@media screen and (max-width: 600px) {
.img-wrapper {
flex: 100%;
max-width: 100%;
}
}
</style>
</head>
<body>
<div class="title">
<h2>
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>
</h2>
</div>
<div class="container">
<div id="font-list"></div>
</div>
</body>
<script>
// PS: I suck at JS
// IDK if im doing this in a good way and online docs are hard ~ Moodle
const manifestUrl = `${window.location.href}manifest.json`;
fetchItems();
async function fetchItems() {
try {
const response = await fetch(manifestUrl);
if (!response.ok) {
throw new Error("Error fetching data");
}
const data = await response.json();
const fontContainer = document.getElementById("font-list");
fontContainer.innerHTML = "";
data.forEach(async (item) => {
const snippetUrl = `${window.location.href}${item.manifest}`;
console.log(snippetUrl);
const fontEl = document.createElement("div");
fontEl.classList.add("font-group");
fontEl.innerHTML = `
<h4 class="font-title">${item.name}</h4>
<button class="copy-snippet-url">Copy Link</button>
`;
fontContainer.appendChild(fontEl);
const buttonEl = fontEl.querySelector(".copy-snippet-url");
buttonEl.addEventListener("click", () => {
navigator.clipboard.writeText(snippetUrl);
});
if (item?.previews?.length > 0) {
const previewContainer = document.createElement("div");
previewContainer.classList.add("preview-container");
fontEl.appendChild(previewContainer);
const detailsEl = document.createElement("details");
const summaryEl = document.createElement("summary");
summaryEl.classList.add("summary-text");
summaryEl.textContent = "Preview";
detailsEl.appendChild(summaryEl);
detailsEl.appendChild(previewContainer);
fontEl.appendChild(detailsEl);
for (let i = 0; i < item.previews.length; i++) {
const imgEl = document.createElement("img");
imgEl.classList.add("img-wrapper");
imgEl.src = `${window.location.href}${item.previews[i]}`;
previewContainer.appendChild(imgEl);
}
}
});
} catch (error) {
console.error(error);
}
}
</script>
</html>