-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbase64_encode.html
64 lines (64 loc) · 2.11 KB
/
base64_encode.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
<div class="supertool">
<style>
.supertool textarea{
white-space: pre;
overflow: auto;
border: solid #ddd 2px;
width: 100%;
}
.supertool a, .supertool button {
background-color: #d0d0d0;
border: none;
color: #5b5b57 !important;
padding: 10px 8px;
text-align: center;
text-decoration: none;
display: inline-block;
cursor: pointer;
margin-top: 2px;
margin-bottom: 2px;
font-size: 14px;
}
.supertool a:hover, .supertool button:hover{
background-color: #757575;
color: #fff !important;
}
</style>
<div class="col-md-12">
<textarea autocomplete="off" id="code" cols="80" rows="10" name="code" placeholder="Enter plan text..." spellcheck="false"></textarea><br>
<button type="button" id="convert" name="convert" value="convert">Encode</button>
<button type="button" name="reload" onclick="location.reload()" value="reload">Reload</button>
</div>
<div class="col-md-12">
<textarea autocomplete="off" id="result" cols="80" rows="10" name="result" placeholder="Result..." readonly></textarea><br>
<button type="button" id="copy" name="copy" value="Copy">Copy</button>
<a type="button" id="download" name="download" >Download</a>
<span id="status" ></span>
</div>
<script>
const converter = document.querySelector('#convert');
converter.addEventListener("click", function () {
var code = document.querySelector('#code'), result = document.querySelector('#result');
result.value = btoa(code.value);
});
const copy = document.querySelector('#copy');
copy.addEventListener("click", function() {
elm = document.querySelector("#result");
elm.select();
elm.setSelectionRange(0,99999);
document.execCommand('copy');
});
const download = document.querySelector('#download');
download.addEventListener("click", function () {
var code = document.querySelector('#code'), file;
this.download='encode_text.txt'; //download
file = btoa(code.value);
var blobData = new Blob([file], {type: 'text/plain'});
var url = window.URL.createObjectURL(blobData);
this.href = url;
});
const superTools = {
title: "Base64 Encode"
};
</script>
</div>