-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtool-3-URL-Encoder-Decoder.html
More file actions
416 lines (349 loc) · 15.1 KB
/
tool-3-URL-Encoder-Decoder.html
File metadata and controls
416 lines (349 loc) · 15.1 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tool 3 - URL Encoder Decoder - Developer Toolbox</title>
<link rel="stylesheet" href="assets/core.css">
<style>
.layout-split {
display: grid;
grid-template-columns: 1fr;
gap: 2rem;
}
@media (min-width: 900px) {
.layout-split {
grid-template-columns: 1fr 1fr;
}
}
.io-container {
display: flex;
flex-direction: column;
height: 100%;
}
.io-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}
.io-textarea {
flex: 1;
width: 100%;
min-height: 250px;
resize: vertical;
font-family: var(--font-mono);
font-size: 0.9rem;
padding: 1rem;
background: var(--bg-main);
color: var(--text-primary);
border: 1px solid var(--border-color);
border-radius: var(--radius-md);
margin-bottom: 1rem;
}
.io-textarea:focus {
border-color: var(--accent-primary);
outline: none;
}
.controls-bar {
background: var(--bg-surface);
padding: 1rem;
border-radius: var(--radius-md);
margin-bottom: 2rem;
display: flex;
gap: 2rem;
align-items: center;
border: 1px solid var(--border-color);
}
.toggle-group {
display: flex;
align-items: center;
gap: 0.5rem;
}
.toggle-label {
font-size: 0.9rem;
color: var(--text-secondary);
}
/* Direction Switcher */
.switcher-container {
display: flex;
justify-content: center;
align-items: center;
padding: 1rem 0;
}
@media (min-width: 900px) {
.switcher-container {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
z-index: 10;
padding: 0;
}
}
.btn-switch {
background: var(--bg-elevated);
border: 2px solid var(--accent-primary);
color: var(--text-primary);
width: 50px;
height: 50px;
border-radius: 50%;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
font-size: 1.5rem;
transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}
.btn-switch:hover {
transform: scale(1.1) rotate(180deg);
}
.mode-decode {
flex-direction: row-reverse !important;
}
/* 3D Container */
#canvas-container {
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: -1;
opacity: 0.4;
pointer-events: none;
}
</style>
</head>
<body class="theme-dark">
<div id="canvas-container"></div>
<main class="main-content">
<div class="container relative">
<div class="tool-header">
<div>
<a href="index.html" class="back-link">← Back to Toolbox</a>
<h1>3. URL Encoder Decoder</h1>
</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="controls-bar">
<div class="toggle-group">
<span class="toggle-label">Mode:</span>
<label>
<input type="radio" name="url-mode" value="component" checked> encodeURIComponent
</label>
<label>
<input type="radio" name="url-mode" value="full"> encodeURI
</label>
</div>
<div class="text-secondary" style="font-size: 0.8rem;">
<em>component</em> encodes special characters like ?, =, &, / <br>
<em>full</em> leaves them intact (good for entire URLs).
</div>
</div>
<div class="layout-split position-relative" id="main-layout">
<!-- Left Column (Input) -->
<div class="glass-panel io-container">
<div class="io-header">
<h3 id="label-primary">Plain Text</h3>
<button class="btn" id="btn-clear"
style="padding: 0.2rem 0.6rem; font-size: 0.8rem;">Clear</button>
</div>
<textarea class="io-textarea" id="text-input"
placeholder="Type or paste URL or text here... https://example.com/?q=hello world"></textarea>
</div>
<!-- Center Switcher -->
<div class="switcher-container">
<button class="btn-switch" id="btn-switch" title="Swap Encode/Decode">⇄</button>
</div>
<!-- Right Column (Output) -->
<div class="glass-panel io-container">
<div class="io-header">
<h3 id="label-secondary">URL Encoded Output</h3>
<button class="btn btn-primary" id="btn-copy"
style="padding: 0.2rem 0.6rem; font-size: 0.8rem;">Copy</button>
</div>
<textarea class="io-textarea" id="text-output" readonly
placeholder="Result will appear here..."></textarea>
</div>
</div>
</div>
</main>
<footer class="global-footer">
<div class="container">
Made with ❤️ by <a href="https://github.com/Aliriyaj007" target="_blank">Aliriyaj007</a>
</div>
</footer>
<script src="assets/core.js"></script>
<script>
// State
let currentAction = 'encode'; // 'encode' or 'decode'
// DOM
const mainLayout = document.getElementById('main-layout');
const labelPrimary = document.getElementById('label-primary');
const labelSecondary = document.getElementById('label-secondary');
const textInput = document.getElementById('text-input');
const textOutput = document.getElementById('text-output');
const btnClear = document.getElementById('btn-clear');
const btnCopy = document.getElementById('btn-copy');
const btnSwitch = document.getElementById('btn-switch');
const radioModes = document.querySelectorAll('input[name="url-mode"]');
const processContent = () => {
const raw = textInput.value;
const useComponent = document.querySelector('input[name="url-mode"]:checked').value === 'component';
try {
if (currentAction === 'encode') {
textOutput.value = useComponent ? encodeURIComponent(raw) : encodeURI(raw);
// trigger 3d
if (raw && window.trigger3DAnimation) window.trigger3DAnimation('join');
} else {
textOutput.value = useComponent ? decodeURIComponent(raw) : decodeURI(raw);
if (raw && window.trigger3DAnimation) window.trigger3DAnimation('split');
}
} catch (e) {
textOutput.value = "Error: Malformed URI sequence.";
if (window.trigger3DAnimation) window.trigger3DAnimation('error');
}
if (!raw && window.trigger3DAnimation) {
window.trigger3DAnimation('idle');
}
};
textInput.addEventListener('input', processContent);
radioModes.forEach(r => r.addEventListener('change', processContent));
btnClear.addEventListener('click', () => {
textInput.value = '';
textOutput.value = '';
if (window.trigger3DAnimation) window.trigger3DAnimation('idle');
});
btnCopy.addEventListener('click', () => {
navigator.clipboard.writeText(textOutput.value).then(() => {
if (window.AppCore) AppCore.showToast('Copied to clipboard!');
});
});
btnSwitch.addEventListener('click', () => {
currentAction = currentAction === 'encode' ? 'decode' : 'encode';
if (currentAction === 'decode') {
mainLayout.classList.add('mode-decode');
labelPrimary.textContent = "URL Encoded Text";
labelSecondary.textContent = "Decoded Output";
textInput.placeholder = "Paste encoded URL here... https%3A%2F%2Fexample.com%2F%3Fq%3Dhello%20world";
} else {
mainLayout.classList.remove('mode-decode');
labelPrimary.textContent = "Plain Text";
labelSecondary.textContent = "URL Encoded Output";
textInput.placeholder = "Type or paste URL or text here... https://example.com/?q=hello world";
}
// swap values
const temp = textInput.value;
textInput.value = textOutput.value;
textOutput.value = temp;
processContent();
});
</script>
<!-- Three.js Scene: 3D Chain Link -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script>
let scene, camera, renderer, linkGroup, link1, link2;
const init3D = () => {
const container = document.getElementById('canvas-container');
if (!container || !window.THREE) return;
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(50, window.innerWidth / window.innerHeight, 0.1, 1000);
camera.position.z = 12;
renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
const dirLight = new THREE.DirectionalLight(0xffffff, 0.8);
dirLight.position.set(5, 5, 5);
scene.add(dirLight);
linkGroup = new THREE.Group();
scene.add(linkGroup);
const themeColor = new THREE.Color(getComputedStyle(document.body).getPropertyValue('--accent-primary').trim() || '#BB86FC');
// Create Torus geometry for chain links
const geometry = new THREE.TorusGeometry(2, 0.5, 16, 100);
// Link 1 Material
const mat1 = new THREE.MeshPhongMaterial({
color: themeColor,
shininess: 100,
transparent: true,
opacity: 0.8
});
// Link 2 Material (slightly different tint)
const mat2 = new THREE.MeshPhongMaterial({
color: 0x33d9b2,
shininess: 100,
transparent: true,
opacity: 0.8
});
link1 = new THREE.Mesh(geometry, mat1);
link2 = new THREE.Mesh(geometry, mat2);
// Connect them initially
link1.position.x = -1.5;
link2.position.x = 1.5;
link2.rotation.x = Math.PI / 2; // rotated to interlock
linkGroup.add(link1);
linkGroup.add(link2);
// Tilt the whole group visually
linkGroup.rotation.z = Math.PI / 6;
linkGroup.rotation.y = Math.PI / 8;
window.addEventListener('themechanged', () => {
setTimeout(() => {
const c = new THREE.Color(getComputedStyle(document.body).getPropertyValue('--accent-primary').trim() || '#BB86FC');
link1.material.color = c;
}, 50);
});
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
animate();
};
let currentAnimState = 'idle';
window.trigger3DAnimation = (state) => {
if (!scene || currentAnimState === state) return;
currentAnimState = state;
if (state === 'join') {
gsap.to(link1.position, { x: -1.5, duration: 0.5, ease: "back.out(1.5)" });
gsap.to(link2.position, { x: 1.5, duration: 0.5, ease: "back.out(1.5)" });
gsap.to(link1.material, { color: link1.material.color.getHex(), opacity: 0.8 }); // reset error color if any
}
else if (state === 'split') {
gsap.to(link1.position, { x: -3, duration: 0.5, ease: "power2.out" });
gsap.to(link2.position, { x: 3, duration: 0.5, ease: "power2.out" });
gsap.to(link1.material, { color: link1.material.color.getHex(), opacity: 0.8 });
}
else if (state === 'idle') {
gsap.to(link1.position, { x: -1.5, duration: 1, ease: "power2.inOut" });
gsap.to(link2.position, { x: 1.5, duration: 1, ease: "power2.inOut" });
}
else if (state === 'error') {
// Shake and flash red
gsap.to(linkGroup.position, { x: 0.5, yoyo: true, repeat: 5, duration: 0.05 });
gsap.to(link1.material, { color: 0xff5252, duration: 0.2 });
}
};
const animate = () => {
requestAnimationFrame(animate);
if (linkGroup) {
// Gentle continuous rotation
linkGroup.rotation.x += 0.005;
linkGroup.rotation.y += 0.002;
}
renderer.render(scene, camera);
};
document.addEventListener('DOMContentLoaded', init3D);
</script>
</body>
</html>