-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
92 lines (73 loc) · 2.04 KB
/
index.html
File metadata and controls
92 lines (73 loc) · 2.04 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
<!doctype html>
<html>
<head>
<meta charset='utf-8'>
<title>base64 decode & encode strings (all local)</title>
<style>
body {
padding: 20px;
margin-bottom: 20px;
}
textarea {
width: 80%;
height: 300px;
padding: 4px;
margin-left: 1rem;
}
textarea.error {
outline: 2px solid crimson;
}
.container {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 20px;
}
.leading {
grid-column: 1;
}
.trailing {
grid-column: 2;
}
footer {
padding: 20px;
}
</style>
</head>
<body>
<h1>base64 decode & encode (all local)</h1>
<p>We do not record anything. All logic is done on the client side.</p>
<div class="container">
<div class="leading">
<h2>decoded text (edit me)</h2>
<textarea id="decoded">Hello world</textarea>
</div>
<div class="trailing">
<h2>encoded base64 (edit me)</h2>
<textarea id="encoded"></textarea>
</div>
<footer>
<a href="https://rexfeng.com">xta</a> 2024 - 2026 <a href="https://github.com/xta/base64-decode-encode">view on
github</a>
</footer>
</div>
</body>
<script type="module">
import { encode, decode } from './base64.js';
const decodedEl = document.getElementById('decoded');
const encodedEl = document.getElementById('encoded');
decodedEl.addEventListener('input', () => {
encodedEl.value = encode(decodedEl.value);
encodedEl.classList.remove('error');
});
encodedEl.addEventListener('input', () => {
try {
decodedEl.value = decode(encodedEl.value);
encodedEl.classList.remove('error');
} catch {
encodedEl.classList.add('error');
}
});
// initialize
encodedEl.value = encode(decodedEl.value);
</script>
</html>