-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfldr.js
211 lines (206 loc) · 7.19 KB
/
cfldr.js
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
module.exports = (Value)=>{
var res = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OFALib</title>
<link rel="stylesheet"
href="//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/styles/atom-one-dark.min.css">
<script src="//cdn.jsdelivr.net/gh/highlightjs/[email protected]/build/highlight.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap');
@import url('https://site-assets.fontawesome.com/releases/v6.3.0/css/all.css');
@import url('/modal.css');
.grid-container {
padding: 5px;
display: grid;
width: calc(100vw-15px);
grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
grid-gap: 10px;
align-items: start; /* add this line to stretch boxes vertically */
}
body {
margin: 0;
padding: 0;
background-color: #333;
color: white;
font-family: 'Roboto';
}
.grid-item {
width: auto;
height: auto;
background-color: #444;
padding: 5px;
border: 5px solid black;
box-sizing: border-box;
cursor: pointer;
}
.grid-item i {
margin-top: 10px;
}
nav {
margin: 0px;
padding-top: 30px;
padding-left: 30px;
height: 100px;
width: calc(100vw-30px);
background-color: #1a1a1a;
}
nav b {
font-size: 25px;
}
select {
border-radius: 10px; /* round the edges */
padding: 8px; /* add padding per element */
background-color: #333;
color: white;
}
input {
border-radius: 10px; /* round the edges */
padding: 8px; /* add padding per element */
background-color: #333;
color: white;
border: 1px solid #767676;
margin-left: 4px;
}
button {
cursor: pointer;
border-radius: 10px; /* round the edges */
padding: 8px; /* add padding per element */
background-color: #333;
color: white;
border: 1px solid #767676;
transition: font-size 0.25s ease;
}
button:hover {
font-size: 14px;
}
.popup {
position: absolute;
z-index: 9999;
}
footer {
position: fixed;
bottom: 0;
width: 100vw;
height: 5vh;
background-color: #555;
text-align: center;
}
a:visited {
color: lightcoral;
}
a:link {
color: coral;
}
</style>
</head>
<body>
<span class='content'>
<div class='grid-container'>
<center class='none'>
<h2>No style selected</h2>
</center>
</div>
<div class="modal m2">
<div class="modal-content">
<span class="close"><i class='fa-solid fa-circle-x'></i></span>
<h2 id='mname'>Empty</h2>
ID: <kbd id='mid'>empty</kbd><br>
Categories: <b id='mct'>a, b, c</b><br>
<h3>Use in code</h3>
HTML:
<pre><code id='mhtml'><i class="fa-empty fa-empty"></i></code></pre>
React:
<pre><code id='mreact'><i class="fa-empty fa-empty"></i></code></pre>
Vue:
<pre><code id='mvue'><i class="fa-empty fa-empty"></i></code></pre>
</div>
</div>
</span>
<footer>
<input class='search' id='search' placeholder='Search...'>
</footer>
<script async>
var arry;
async function initArry() {
await fetch('https://keho.nl/mb/codepenfiles/fontawesome/v6/v6_icons.json')
.then(res => res.json())
.then(array => arry = array)
.then(unused => {
update();
});
}
initArry();
function folder() {
return "${Value}";
}
var modals = document.querySelectorAll(".modal");
var modal = document.querySelector('.m2');
var span = document.querySelectorAll(".close");
span.forEach(elem => {
elem.onclick = function() {
for (var mdl of modals) {
mdl.style.display = "none";
}
}
});
var mname = document.querySelector('#mname');
var mid = document.querySelector('#mid');
var mreact = document.querySelector('#mreact');
var mvue = document.querySelector('#mvue');
var mhtml = document.querySelector('#mhtml');
var mct = document.querySelector('#mct');
window.onclick = function(event) {
if (modals.forEach(e => event.target == e)) {
for (var mdl of modals) {
mdl.style.display = "none";
}
}
}
function update() {
document.querySelector('.grid-container').innerHTML = '';
for (var itm of arry.data.allIcons.icons) {
console.log(itm);
if (itm.styles.includes(folder())) {
if (document.getElementById('search').value === '' ||
itm.label.toLowerCase().includes(document.getElementById('search').value.toLowerCase())) {
var elem = document.createElement('div');
elem.classList.add('grid-item');
elem.innerHTML = \`<center><b>\${itm.label}</b><br><i class='fa-\${folder()} fa-\${itm.id} fa-4x'></i></center>\`;
var il = "" + itm.label + "";
elem.onclick = function(item) {
return function() {
setIconDetails(item);
modal.style.display = 'block';
};
}(itm);
document.querySelector('.grid-container').appendChild(elem);
}
}
}
}
function setIconDetails(item) {
mname.innerHTML = 'Icon: ' + item.label + \`<i style='margin-left: 10px;' class="fa-\${folder()} fa-\${item.id} fa-2x"></i>\`;
mid.textContent = item.id;
mhtml.textContent = \`<i class="fa-\${folder()} fa-\${item.id}"></i>\`;
mreact.textContent = \`<FontAwesomeIcon icon="fa-\${folder()} fa-\${item.id}" />\`;
mvue.textContent = \`<font-awesome-icon icon="fa-\${folder()} fa-\${item.id}" />\`;
var cts = folder();
for(var ctgry of item.categories) {
cts += ', ';
cts += ctgry;
}
mct.textContent = \`\${cts}\`;
hljs.highlightAll();
}
document.querySelector('#search').addEventListener('input', (e) => {
update();
});
</script>
</body>
</html>`;
return res;
}