-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZalgoGen.html
More file actions
150 lines (130 loc) · 4.84 KB
/
ZalgoGen.html
File metadata and controls
150 lines (130 loc) · 4.84 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Zalgo Generator - 0x7274</title>
<style>
body {
font-family: sans-serif;
display: flex;
flex-direction: column;
align-items: center;
padding: 40px;
background: #f9f9f9;
}
.container {
display: flex;
justify-content: space-between;
width: 80%;
max-width: 800px;
}
textarea {
width: 45%;
height: 200px;
font-size: 1rem;
padding: 10px;
resize: vertical;
}
input[type=range] {
width: 80%;
margin-top: 20px;
}
label {
margin-top: 10px;
font-weight: bold;
}
.toggle-container {
margin-top: 20px;
display: flex;
align-items: center;
gap: 10px;
}
</style>
</head>
<body>
<h1>Zalgo Text Generator</h1>
<div class="container">
<textarea id="input" placeholder="Enter your text here..."></textarea>
<textarea id="output" placeholder="Zalgo output..." readonly></textarea>
</div>
<label for="zalgoRange">Diacritics per character: <span id="count">0</span></label>
<input type="range" id="zalgoRange" min="0" max="9999" value="0">
<div class="toggle-container">
<label><input type="checkbox" id="toggleUp" checked> Top (Up)</label>
<label><input type="checkbox" id="toggleDown" checked> Bottom (Down)</label>
<label><input type="checkbox" id="toggleMid"> Middle (Chaos)</label>
</div>
<script>
const input = document.getElementById('input');
const output = document.getElementById('output');
const range = document.getElementById('zalgoRange');
const count = document.getElementById('count');
const fullChaosToggle = document.getElementById('fullChaos');
// Diacritic sets
const zalgoUp = [
'\u030d', '\u030e', '\u0304', '\u0305', '\u033f', '\u0311', '\u0306',
'\u0310', '\u0352', '\u0357', '\u0351', '\u0307', '\u0308', '\u030a',
'\u0342', '\u0343', '\u0344', '\u034a', '\u034b', '\u034c', '\u0303',
'\u0302', '\u030c', '\u0350', '\u0300', '\u0301', '\u030b', '\u030f',
'\u0312', '\u0313', '\u0314', '\u033d', '\u0309', '\u0363', '\u0364',
'\u0365', '\u0366', '\u0367', '\u0368', '\u0369', '\u036a', '\u036b',
'\u036c', '\u036d', '\u036e', '\u036f'
];
const zalgoDown = [
'\u0316', '\u0317', '\u0318', '\u0319', '\u031c', '\u031d', '\u031e',
'\u031f', '\u0320', '\u0324', '\u0325', '\u0326', '\u0329', '\u032a',
'\u032b', '\u032c', '\u032d', '\u032e', '\u032f', '\u0330', '\u0331',
'\u0332', '\u0333', '\u0339', '\u033a', '\u033b', '\u033c', '\u0345',
'\u0347', '\u0348', '\u0349', '\u034d', '\u034e', '\u0353', '\u0354',
'\u0355', '\u0356', '\u0359', '\u035a'
];
const zalgoMid = [
'\u0315', '\u031b', '\u0340', '\u0341', '\u0358', '\u0321', '\u0322',
'\u0327', '\u0328', '\u0334', '\u0335', '\u0336', '\u034f', '\u035c',
'\u035d', '\u035e', '\u035f', '\u0360', '\u0361', '\u0489'
];
function getZalgoChar(char, intensity, useUp, useDown, useMid) {
let result = char;
const directions = [];
if (useUp) directions.push('up');
if (useDown) directions.push('down');
if (useMid) directions.push('mid');
if (directions.length === 0 || intensity === 0) return result;
for (let i = 0; i < intensity; i++) {
const dir = directions[Math.floor(Math.random() * directions.length)];
if (dir === 'up') {
result += zalgoUp[Math.floor(Math.random() * zalgoUp.length)];
} else if (dir === 'down') {
result += zalgoDown[Math.floor(Math.random() * zalgoDown.length)];
} else if (dir === 'mid') {
result += zalgoMid[Math.floor(Math.random() * zalgoMid.length)];
}
}
return result;
}
function generateZalgo() {
const intensity = parseInt(range.value, 10);
const useUp = document.getElementById('toggleUp').checked;
const useDown = document.getElementById('toggleDown').checked;
const useMid = document.getElementById('toggleMid').checked;
const text = input.value;
let zalgoText = '';
for (let char of text) {
if (char.trim() === '') {
zalgoText += char;
} else {
zalgoText += getZalgoChar(char, intensity, useUp, useDown, useMid);
}
}
output.value = zalgoText;
count.textContent = intensity;
}
input.addEventListener('input', generateZalgo);
range.addEventListener('input', generateZalgo);
fullChaosToggle.addEventListener('change', generateZalgo);
document.getElementById('toggleUp').addEventListener('change', generateZalgo);
document.getElementById('toggleDown').addEventListener('change', generateZalgo);
document.getElementById('toggleMid').addEventListener('change', generateZalgo);
</script>
</body>
</html>