mirror of
https://github.com/hexahigh/games.git
synced 2025-12-11 20:15:38 +01:00
76 lines
3.1 KiB
HTML
76 lines
3.1 KiB
HTML
<head>
|
|
<link rel="stylesheet" href="style.css" Type="text/css" media="all">
|
|
<title>Base64 encoder and decoder</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
</head>
|
|
<noscript>
|
|
<div style="width: 100%; height: 100%; background-color: #ffffff; color: #27282c;">
|
|
<h1>You seem to have javascript disabled.<br> This page will not work.</h1>
|
|
</div>
|
|
</noscript>
|
|
|
|
<body style="background: #27282c;">
|
|
<div style="margin-left: 5em;">
|
|
<h1 style="color: #ffffff;">Encode/decode data to base64</h1>
|
|
<form>
|
|
<label style="color: #ffffff;">Input data</label><br>
|
|
<textarea style="width: 90%; background: #343538; color: #ffffff;" value="" rows="6" cols="80" id="input"
|
|
required></textarea><br>
|
|
<button class="button" id="encodebutton" style="--color:#1e9bff; background: bottom;" type="button"
|
|
onclick="doencode();">Encode</button>
|
|
<button type="button" id="decodebutton" style="--color: #ff1867; margin-left: 2em; background: bottom;" class="button"
|
|
onclick="dodecode();">Decode</button><br>
|
|
<label style="color: #ffffff;">Output</label><br>
|
|
<textarea style="width: 90%; background: #343538; color: #ffffff;" id="output" rows="6" cols="80"
|
|
readonly></textarea><br>
|
|
<button class="button" type="button" id="copy" style="--color:#1e9bff; background: bottom;"
|
|
onclick="docopy();">Copy</button>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
// Set delay to ms
|
|
function delay(milliseconds) {
|
|
return new Promise(resolve => {
|
|
setTimeout(resolve, milliseconds);
|
|
});
|
|
}
|
|
//Copies the text from the output
|
|
function docopy() {
|
|
document.getElementById("output").select();
|
|
document.execCommand('copy');
|
|
copytext()
|
|
}
|
|
//Takes care of the encoding
|
|
function doencode() {
|
|
var output = btoa(document.getElementById("input").value)
|
|
document.getElementById("output").value = output;
|
|
encodetext()
|
|
}
|
|
//Takes care of the decoding
|
|
function dodecode() {
|
|
var output = atob(document.getElementById("input").value)
|
|
document.getElementById("output").value = output;
|
|
decodetext()
|
|
}
|
|
//How long the text will appear in milliseconds
|
|
const textTime = 750
|
|
|
|
async function copytext() {
|
|
document.getElementById("copy").innerHTML = "Copied!"
|
|
await delay(textTime)
|
|
document.getElementById("copy").innerHTML = "Copy"
|
|
}
|
|
async function encodetext() {
|
|
document.getElementById("encodebutton").innerHTML = "Encoded!"
|
|
await delay(textTime)
|
|
document.getElementById("encodebutton").innerHTML = "Encode"
|
|
}
|
|
async function decodetext() {
|
|
document.getElementById("decodebutton").innerHTML = "Decoded!"
|
|
await delay(textTime)
|
|
document.getElementById("decodebutton").innerHTML = "Decode"
|
|
}
|
|
</script>
|
|
</body> |