-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpackgen.html
362 lines (310 loc) · 12.1 KB
/
packgen.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
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Click Pack Generator</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<link rel="icon" href="./.images/favicon.png" type="image/png">
<meta property="og:title" content="Click Sounds: Pack Generator">
<meta property="og:description" content="A tool to make packs for the Click Sounds Index">
<meta property="og:image" content="https://raw.githubusercontent.com/clicksounds/clicks/refs/heads/main/.images/fullres-logo.png">
<meta property="og:url" content="https://clicksounds.xyz/packgen.html">
<meta property="og:type" content="website">
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #1e1e2f;
color: #f5f5f5;
margin: 0;
padding: 0;
line-height: 1.6;
}
h1, h2 {
color: #85ccf5;
}
h1 {
text-align: center;
margin-top: 100px;
font-size: 2.5em;
}
h2 {
margin-bottom: 0px;
}
section {
background-color: #2a2a3d;
border-radius: 10px;
padding: 20px;
margin: 20px auto;
max-width: 600px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
label {
display: block;
margin: 10px 0 5px;
}
label.required::after {
content: " *";
color: red;
}
.footnote {
color: #999999;
margin-top: 0px;
display: block;
}
input[type="text"],
input[type="number"],
input[type="file"] {
width: calc(100% - 20px);
padding: 10px;
margin-bottom: 15px;
margin-right: 10px;
border: none;
border-radius: 5px;
background-color: #3a3a50;
color: #fff;
}
input[type="radio"] {
margin-right: 5px;
display: inline-block;
}
label[for="typeUseful"],
label[for="typeMeme"] {
display: inline-block;
margin-right: 10px;
}
input[type="file"] {
border: 2px dashed #85ccf5;
text-align: center;
margin-top: 12px;
}
button {
display: block;
width: 100%;
padding: 15px;
margin-top: 15px;
border: none;
border-radius: 10px;
background-color: #555;
color: #1e1e2f;
font-size: 1rem;
cursor: not-allowed;
transition: background-color 0.3s, transform 0.2s;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
button:hover {
background-color: #6ea7c7;
}
button:enabled {
background-color: #6ee873;
cursor: pointer;
}
button:enabled:hover {
background-color: #4abf5f;
transform: translateY(-2px);
}
ul {
list-style: none;
padding: 0;
}
li {
background-color: #3a3a50;
margin: 5px 0;
padding: 10px;
border-radius: 5px;
}
p {
font-size: 0.9rem;
}
#generatePack:disabled {
background-color: #555;
cursor: not-allowed;
}
@media (max-width: 600px) {
section {
margin: 10px;
}
h1 {
font-size: 1.5rem;
}
}
/* Navbar styles */
nav {
width: 100%;
background-color: rgba(0, 0, 0, 0.8); /* Dark background for the navbar */
padding: 10px 20px;
position: absolute;
top: 0;
left: 0;
z-index: 10;
display: flex;
justify-content: center; /* centers the navbar items */
align-items: center; /* vertically aligns the navbar items */
}
/* Navigation links */
nav a {
color: #00aaff;
text-decoration: none;
font-size: 1.2em;
margin-right: 20px;
display: inline-block;
transition: all 0.3s ease;
}
nav a:hover {
background: #00aaff;
color: #fff;
padding: 5px 10px;
border-radius: 5px;
}
</style>
</head>
<body>
<nav>
<a href="./list.html">List</a>
<a href="./">Home</a>
<a href="./addsoundhelp.html">Add Sound</a>
<a href="./download.html">Download</a>
</nav>
<h1>Click Pack Generator</h1>
<section>
<h2>Pack Details</h2>
<label for="packName" class="required">Pack Name:</label>
<input type="text" id="packName" placeholder="Enter pack name" required><br>
<small class="footnote" style="color: red;">The author's name and account ID is for the original creator of the sound(s).</small>
<label for="authorName" class="required">Author Name:</label>
<input type="text" id="authorName" placeholder="Enter author name" required><br>
<label for="gdAccountID">Geometry Dash Account ID (optional):</label>
<input type="text" id="gdAccountID" placeholder="Enter GD account ID"><br>
<label class="required">Type:</label>
<input type="radio" id="typeUseful" name="packType" value="Useful">
<label for="typeUseful" style="display: inline-block;">Useful</label>
<input type="radio" id="typeMeme" name="packType" value="Meme">
<label for="typeMeme" style="display: inline-block;">Meme</label>
</section>
<section>
<h2>Click Sounds (max 25)</h2>
<small class="footnote">Files will automatically convert to .ogg when accepted.</small>
<input type="file" id="clickFiles" multiple accept=".mp3,.ogg,.wav">
<p id="clickCount">Uploaded: 0/25</p>
<ul id="clickList"></ul>
</section>
<section>
<h2>Release Sounds (max 25)</h2>
<small class="footnote">Files will automatically convert to .ogg when accepted.</small>
<input type="file" id="releaseFiles" multiple accept=".mp3,.ogg,.wav">
<p id="releaseCount">Uploaded: 0/25</p>
<ul id="releaseList"></ul>
</section>
<section style="display: flex; justify-content: center; align-items: center; height: 100%;">
<button id="generatePack" disabled>Download Pack</button>
</section>
<script>
const clickFiles = [];
const releaseFiles = [];
document.getElementById('clickFiles').addEventListener('change', (e) => {
const files = Array.from(e.target.files);
if (clickFiles.length + files.length > 25) {
alert('You can only upload up to 25 click sounds.');
return;
}
clickFiles.push(...files);
updateList('click', clickFiles);
});
document.getElementById('releaseFiles').addEventListener('change', (e) => {
const files = Array.from(e.target.files);
if (releaseFiles.length + files.length > 25) {
alert('You can only upload up to 25 release sounds.');
return;
}
releaseFiles.push(...files);
updateList('release', releaseFiles);
});
document.getElementById('gdAccountID').addEventListener('input', (e) => {
const value = e.target.value;
if (!/^[0-9]*$/.test(value)) {
e.target.value = value.replace(/\D/g, '');
}
});
function updateList(type, files) {
const list = document.getElementById(`${type}List`);
const count = document.getElementById(`${type}Count`);
list.innerHTML = '';
files.forEach((file, index) => {
const li = document.createElement('li');
li.textContent = `${index + 1}. ${file.name}`;
list.appendChild(li);
});
count.textContent = `Uploaded: ${files.length}/25`;
checkGenerateButton();
}
function checkGenerateButton() {
const generateButton = document.getElementById('generatePack');
const packName = document.getElementById('packName').value.trim();
const authorName = document.getElementById('authorName').value.trim();
const typeSelected = document.querySelector('input[name="packType"]:checked');
generateButton.disabled = !(packName && authorName && typeSelected) || clickFiles.length === 0 && releaseFiles.length === 0;
}
window.addEventListener('load', () => {
checkGenerateButton();
});
document.getElementById('generatePack').addEventListener('click', async () => {
const packName = document.getElementById('packName').value.trim();
const authorName = document.getElementById('authorName').value.trim();
const gdAccountID = document.getElementById('gdAccountID').value.trim();
const packType = document.querySelector('input[name="packType"]:checked').value;
const zip = new JSZip();
const clicksFolder = zip.folder('Clicks');
const releasesFolder = zip.folder('Releases');
clickFiles.forEach((file, index) => {
clicksFolder.file(`${index + 1}.${file.name.split('.').pop()}`, file);
});
releaseFiles.forEach((file, index) => {
releasesFolder.file(`${index + 1}.${file.name.split('.').pop()}`, file);
});
const id = `${authorName.toLowerCase().replace(/\s+/g, '-')}.${packName.toLowerCase().replace(/\s+/g, '-')}`;
const packJson = {
"$schema": "https://clicksounds.github.io/clicks/pack.schema.json",
"id": id,
"type": packType,
"name": packName,
"authors": [
{
"name": authorName,
...(gdAccountID && { "gdAccountID": parseInt(gdAccountID, 10) })
}
]
};
zip.file('pack.json', JSON.stringify(packJson, null, 4));
const content = await zip.generateAsync({ type: 'blob' });
const a = document.createElement('a');
a.href = URL.createObjectURL(content);
a.download = `${id}.packgen.zip`;
a.click();
});
document.getElementById('packName').addEventListener('input', checkGenerateButton);
document.getElementById('authorName').addEventListener('input', checkGenerateButton);
document.querySelectorAll('input[name="packType"]').forEach(input => {
input.addEventListener('change', checkGenerateButton);
});
window.addEventListener('beforeunload', () => {
document.getElementById('packName').value = '';
document.getElementById('authorName').value = '';
document.getElementById('gdAccountID').value = '';
document.getElementById('clickFiles').value = '';
document.getElementById('releaseFiles').value = '';
document.querySelector('input[name="packType"]:checked').checked = false;
});
document.querySelectorAll('input[type="text"]').forEach(input => {
input.addEventListener('input', (e) => {
const value = e.target.value;
if (!/^[a-zA-Z0-9-_ ]*$/.test(value)) {
alert('Only alphanumeric characters, spaces, dashes (-), and underscores (_) are allowed.');
e.target.value = value.replace(/[^a-zA-Z0-9-_ ]/g, '');
}
});
});
document.documentElement.style.overflowX = 'hidden';
document.body.style.overflowX = 'hidden';
</script>
</body>
</html>