-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
base64.html
40 lines (38 loc) · 1006 Bytes
/
base64.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Demo for base64.js</title>
</head>
<body>
<h1>Demo for base64.js</h1>
<table width="640"><tbody>
<tr><th width="50%">Text</th><th>Base64
(URL Safe <input id="encodeURI" type="checkbox" onclick="doit()">)</th></tr>
<tr>
<th><textarea id="srctxt" cols="32" rows="4" onkeyup="doit()">
</textarea></th>
<th><textarea id="base64" cols="32" rows="4" onkeyup="
$('srctxt').value = Base64.decode(this.value);
doit();
"></textarea></th>
</tr>
<tr><th width="50%">Roundtrip</th><th></th></tr>
<tr>
<th><textarea id="roundtrip" cols="32" rows="4" disabled></textarea></th>
<th></th>
</tr>
</tbody></table>
<script src="./base64.js"></script>
<script>
$ = function(id){ return document.getElementById(id) };
function doit(){
var encoded = Base64[
'encode' + ($('encodeURI').checked ? 'URI' : '')
]($('srctxt').value);
$('base64').value = encoded;
$('roundtrip').value = Base64.decode(encoded);
}
</script>
</body>
</html>