-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool-16-UUID-Generator.html
More file actions
552 lines (463 loc) · 20.3 KB
/
tool-16-UUID-Generator.html
File metadata and controls
552 lines (463 loc) · 20.3 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
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
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tool 16 - UUID Generator - Developer Toolbox</title>
<link rel="stylesheet" href="assets/core.css">
<style>
.uuid-container {
max-width: 800px;
margin: 2rem auto;
position: relative;
z-index: 10;
}
.generator-panel {
background: rgba(0, 0, 0, 0.4);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
padding: 2rem;
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.controls-row {
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
align-items: flex-end;
background: rgba(255, 255, 255, 0.02);
padding: 1.5rem;
border-radius: var(--radius-sm);
border: 1px solid rgba(255, 255, 255, 0.05);
}
.control-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.control-group label {
font-size: 0.9rem;
color: var(--text-secondary);
font-weight: bold;
text-transform: uppercase;
letter-spacing: 1px;
}
.control-group select,
.control-group input[type="number"] {
padding: 0.8rem;
background: var(--bg-main);
border: 1px solid var(--border-color);
color: var(--text-primary);
border-radius: var(--radius-sm);
font-family: var(--font-mono);
outline: none;
min-width: 150px;
}
.control-group input[type="number"] {
width: 100px;
min-width: unset;
}
.control-group select:focus,
.control-group input[type="number"]:focus {
border-color: var(--accent-primary);
}
/* UUID v5 specific inputs */
#v5-inputs {
display: none;
width: 100%;
gap: 1.5rem;
margin-top: 1rem;
flex-wrap: wrap;
}
#v5-inputs.active {
display: flex;
}
#v5-inputs input[type="text"] {
flex: 1;
padding: 0.8rem;
background: rgba(0, 0, 0, 0.3);
border: 1px solid var(--border-color);
border-radius: var(--radius-sm);
color: var(--text-primary);
font-family: var(--font-mono);
}
/* Results Area */
.results-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 1rem;
margin-bottom: 0.5rem;
}
.uuid-list {
background: rgba(0, 0, 0, 0.3);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
max-height: 400px;
overflow-y: auto;
display: flex;
flex-direction: column;
}
.uuid-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem 1.5rem;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
font-family: var(--font-mono);
font-size: 1.1rem;
transition: background-color 0.2s;
}
.uuid-item:last-child {
border-bottom: none;
}
.uuid-item:hover {
background: rgba(255, 255, 255, 0.05);
}
.uuid-text {
word-break: break-all;
color: var(--text-primary);
}
.btn-copy-item {
opacity: 0.5;
transition: opacity 0.2s;
background: transparent;
border: 1px solid var(--border-color);
padding: 0.4rem 0.8rem;
border-radius: var(--radius-sm);
color: var(--text-secondary);
cursor: pointer;
font-size: 0.8rem;
}
.uuid-item:hover .btn-copy-item {
opacity: 1;
color: var(--text-primary);
border-color: var(--accent-primary);
}
/* 3D background container */
#canvas-container {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
opacity: 0.6;
pointer-events: none;
}
</style>
</head>
<body class="theme-dark">
<div id="canvas-container"></div>
<main class="main-content" style="position: relative; z-index: 10;">
<div class="container">
<div class="tool-header">
<div>
<a href="index.html" class="back-link">← Back to Toolbox</a>
<h1>16. UUID Generator</h1>
<p style="color: var(--text-secondary); margin-top: 0.5rem;">Generate standards-compliant v1, v4,
and v5 Universally Unique Identifiers.</p>
</div>
<div>
<select id="theme-select" aria-label="Select Theme">
<option value="dark">Dark Theme</option>
<option value="light">Light Theme</option>
<option value="solarized">Solarized</option>
<option value="neon">Neon Glow</option>
<option value="highcontrast">High Contrast</option>
</select>
</div>
</div>
<div class="uuid-container">
<div class="generator-panel glass-panel">
<div class="controls-row">
<div class="control-group">
<label for="uuid-version">Version</label>
<select id="uuid-version">
<option value="v4" selected>Version 4 (Random)</option>
<option value="v1">Version 1 (Time-based)</option>
<option value="v5">Version 5 (Namespace/Name)</option>
</select>
</div>
<div class="control-group">
<label for="uuid-count">Quantity</label>
<input type="number" id="uuid-count" value="5" min="1" max="500">
</div>
<!-- V5 Specific Inputs -->
<div id="v5-inputs">
<div class="control-group" style="flex:1;">
<label for="v5-namespace">Namespace (UUID)</label>
<!-- Using DNS namespace UUID as default placeholder -->
<input type="text" id="v5-namespace" value="6ba7b810-9dad-11d1-80b4-00c04fd430c8"
placeholder="e.g. 6ba7b810-9dad-11d1-80b4-00c04fd430c8">
</div>
<div class="control-group" style="flex:1;">
<label for="v5-name">Name (String)</label>
<input type="text" id="v5-name" value="example.com" placeholder="e.g. example.com">
</div>
</div>
<div class="control-group" style="flex: 1; align-items: flex-end;">
<button id="btn-generate" class="btn btn-primary"
style="font-size: 1.1rem; padding: 0.8rem 2rem; width: 100%; justify-content: center; background: #BB86FC; color: #000;">Generate
UUIDs</button>
</div>
</div>
<div class="results-container">
<div class="results-header">
<h3 style="margin:0;">Generated Output <span id="gen-count" class="text-secondary"
style="font-size: 0.9rem; font-weight: normal;">(5)</span></h3>
<button id="btn-copy-all" class="btn">Copy All to Clipboard</button>
</div>
<div class="uuid-list" id="uuid-list">
<!-- UUIDs will be inserted here -->
</div>
</div>
</div>
</div>
</div>
</main>
<!-- Three.js and GSAP for 3D Background -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<!-- UUID Library CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.3.2/uuid.min.js"></script>
<script src="assets/core.js"></script>
<script>
// --- Core UUID Logic ---
const versionSelect = document.getElementById('uuid-version');
const countInput = document.getElementById('uuid-count');
const v5Inputs = document.getElementById('v5-inputs');
const nsInput = document.getElementById('v5-namespace');
const nameInput = document.getElementById('v5-name');
const btnGenerate = document.getElementById('btn-generate');
const btnCopyAll = document.getElementById('btn-copy-all');
const uuidListEl = document.getElementById('uuid-list');
const genCountEl = document.getElementById('gen-count');
// Toggle V5 inputs
versionSelect.addEventListener('change', (e) => {
if (e.target.value === 'v5') {
v5Inputs.classList.add('active');
// For V5, usually you generate just 1 based on name+ns, but we'll allow multiple though they'll be identical if name/ns don't change.
countInput.value = 1;
} else {
v5Inputs.classList.remove('active');
}
});
// Ensure count is valid
countInput.addEventListener('change', (e) => {
let val = parseInt(e.target.value);
if (isNaN(val) || val < 1) val = 1;
if (val > 500) val = 500;
e.target.value = val;
});
function generateUUIDs() {
const version = versionSelect.value;
const count = parseInt(countInput.value) || 1;
const list = [];
try {
if (version === 'v4') {
for (let i = 0; i < count; i++) list.push(uuid.v4());
}
else if (version === 'v1') {
for (let i = 0; i < count; i++) list.push(uuid.v1());
}
else if (version === 'v5') {
const ns = nsInput.value.trim();
const name = nameInput.value.trim();
// Basic validation for namespace
if (!ns || !name) throw new Error("Namespace and Name required for V5");
// Generate (they will be identical if inputs are the same, which is correct for v5)
for (let i = 0; i < count; i++) {
list.push(uuid.v5(name, ns));
}
}
renderList(list);
// Trigger 3D Animation
if (window.triggerSpawn) window.triggerSpawn(Math.min(count, 50)); // limit 3D spawns to 50 for perf
} catch (err) {
alert("Error generating UUID: " + err.message);
}
}
function renderList(list) {
uuidListEl.innerHTML = '';
genCountEl.textContent = `(${list.length})`;
list.forEach(id => {
const row = document.createElement('div');
row.className = 'uuid-item';
const span = document.createElement('span');
span.className = 'uuid-text';
span.textContent = id;
const btn = document.createElement('button');
btn.className = 'btn-copy-item';
btn.textContent = 'Copy';
btn.onclick = (e) => {
navigator.clipboard.writeText(id);
const orig = btn.textContent;
btn.textContent = 'Copied!';
btn.style.color = 'var(--accent-primary)';
btn.style.borderColor = 'var(--accent-primary)';
if (window.highlightTag) window.highlightTag();
setTimeout(() => {
btn.textContent = orig;
btn.style.color = '';
btn.style.borderColor = '';
}, 1000);
};
row.appendChild(span);
row.appendChild(btn);
uuidListEl.appendChild(row);
});
}
btnGenerate.addEventListener('click', generateUUIDs);
btnCopyAll.addEventListener('click', () => {
const items = document.querySelectorAll('.uuid-text');
if (items.length === 0) return;
const textToCopy = Array.from(items).map(item => item.textContent).join('\n');
navigator.clipboard.writeText(textToCopy);
const orig = btnCopyAll.textContent;
btnCopyAll.textContent = 'Copied All!';
setTimeout(() => btnCopyAll.textContent = orig, 1500);
});
// Generate initial set
generateUUIDs();
// --- 3D Background Setup (Floating UUID Tags) ---
let scene, camera, renderer, tagGroup;
let tags = [];
// Use a canvas to create text textures for the tags
const createTextTexture = () => {
const canvas = document.createElement('canvas');
canvas.width = 512;
canvas.height = 128;
const ctx = canvas.getContext('2d');
ctx.fillStyle = '#1e1e1e'; // bg almost invisible naturally
ctx.fillRect(0, 0, canvas.width, canvas.height);
// Random pseudo UUID string for visual
const chars = '0123456789abcdef';
let str = '';
for (let i = 0; i < 32; i++) {
if (i == 8 || i == 12 || i == 16 || i == 20) str += '-';
str += chars.charAt(Math.floor(Math.random() * chars.length));
}
ctx.font = '24px monospace';
ctx.fillStyle = '#BB86FC';
ctx.textAlign = 'center';
ctx.textBaseline = 'middle';
ctx.fillText(str, canvas.width / 2, canvas.height / 2);
const tex = new THREE.CanvasTexture(canvas);
return tex;
};
const init3D = () => {
const container = document.getElementById('canvas-container');
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 30;
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(Math.min(window.devicePixelRatio, 2));
container.appendChild(renderer.domElement);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.9);
scene.add(ambientLight);
tagGroup = new THREE.Group();
scene.add(tagGroup);
// Create pool of tags
const maxTags = 100;
const geo = new THREE.PlaneGeometry(8, 2);
for (let i = 0; i < maxTags; i++) {
const mat = new THREE.MeshBasicMaterial({
map: createTextTexture(),
transparent: true,
opacity: 0, // start invisible
depthWrite: false,
blending: THREE.AdditiveBlending
});
const mesh = new THREE.Mesh(geo, mat);
// Hide offscreen
mesh.position.set(0, -50, 0);
mesh.userData = { active: false };
tags.push(mesh);
tagGroup.add(mesh);
}
// Animation triggers
window.triggerSpawn = (count) => {
// Find inactive tags
let activeCount = 0;
tags.forEach(t => {
// Quick fade out existing active ones making room
if (t.userData.active) {
gsap.to(t.material, { opacity: 0, duration: 0.5, onComplete: () => { t.userData.active = false; } });
}
});
// Spawn new ones
const inactiveTags = tags.filter(t => !t.userData.active);
for (let i = 0; i < Math.min(count, inactiveTags.length); i++) {
const mesh = inactiveTags[i];
mesh.userData.active = true;
// Give new texture
mesh.material.map = createTextTexture();
mesh.material.needsUpdate = true;
// Random start pos below screen
const startX = (Math.random() - 0.5) * 40;
const startZ = (Math.random() - 0.5) * 20 - 10;
const endY = (Math.random() - 0.5) * 20;
mesh.position.set(startX, -20, startZ);
mesh.rotation.set(0, (Math.random() - 0.5) * 0.5, (Math.random() - 0.5) * 0.2);
// Float up and fade in
gsap.to(mesh.position, {
y: endY,
duration: 1.5 + Math.random(),
ease: "back.out(1.2)",
delay: i * 0.05 // stagger
});
// Fade in to ~0.7 then pulse
gsap.to(mesh.material, {
opacity: 0.7 + (Math.random() * 0.2),
duration: 1,
delay: i * 0.05
});
}
};
window.highlightTag = () => {
// Flash a random active tag
const activeTags = tags.filter(t => t.userData.active);
if (activeTags.length > 0) {
const tag = activeTags[Math.floor(Math.random() * activeTags.length)];
const origScale = tag.scale.x;
gsap.to(tag.scale, { x: origScale * 1.5, y: origScale * 1.5, duration: 0.2, yoyo: true, repeat: 1 });
gsap.to(tag.material, { opacity: 1, duration: 0.2, yoyo: true, repeat: 1 });
}
};
const animate = () => {
requestAnimationFrame(animate);
// Idle floating
const time = Date.now() * 0.001;
tags.forEach((t, i) => {
if (t.userData.active) {
t.position.y += Math.sin(time + i) * 0.01;
t.rotation.z = Math.sin(time * 0.5 + i) * 0.05;
}
});
// Slow camera pan
camera.position.x = Math.sin(time * 0.2) * 5;
camera.lookAt(0, 0, 0);
renderer.render(scene, camera);
};
animate();
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
if (window.innerWidth < 900) {
camera.position.z = 40;
} else {
camera.position.z = 30;
}
});
window.dispatchEvent(new Event('resize'));
};
if (document.getElementById('canvas-container')) {
init3D();
}
</script>
</body>
</html>