-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
88 lines (75 loc) · 2 KB
/
index.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Dyescapeify</title>
</head>
<style>
body {
font-family: "Roboto Mono", monospace;
user-select: none;
background-color: #2b2b2b;
color: #a9b7c6;
text-align: center;
}
#content {
width: 50%;
margin: auto;
}
label {
font-weight: bold;
margin-top: 1em;
display: block;
text-align: left;
}
textarea {
width: 100%;
resize: both;
overflow: hidden;
display: block;
height: 10em;
background-color: #323232;
color: #a9b7c6;
padding: 3px;
border-radius: 4px;
white-space: pre-wrap;
}
</style>
<body>
<div id="content">
<h1>Dyescapeify</h1>
<p>Turn any text into Dyescape letters</p>
<label for="input">Input</label>
<textarea placeholder="Input" id="input"></textarea>
<label for="output">Output</label>
<textarea placeholder="Output" id="output" readonly></textarea>
</div>
<script>
const input = document.getElementById('input')
const output = document.getElementById('output')
function convert(text) {
let output = ""
let currentlyInEmote = false
for (let char of text) {
switch (char) {
case ':':
currentlyInEmote = !currentlyInEmote
break;
case ' ':
char = ' '
break;
}
const alpha = /[a-zA-Z0-9]/.test(char)
output += !currentlyInEmote && alpha ? `:dyescape_${char.toLowerCase()}:` : char;
}
return output
}
input.oninput = (e) => {
output.value = convert(e.target.value);
}
</script>
</body>
</html>