213 lines
5.6 KiB
HTML
213 lines
5.6 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<title>Base64</title>
|
|
<meta property="og:title" content="Base64" />
|
|
<meta property="og:image" content="http://shots.wayl.one/shot/?url=https://b64.wayl.one/&height=630&width=1200&scaled_width=1200&scaled_height=630&selectors=" />
|
|
<meta property="og:description" content="It's just a Base64, thats it, thats all it needs to do, it generates, displays and copies the Base64" />
|
|
<meta property="og:url" content="https://b64.wayl.one/" />
|
|
<meta property="og:type" content="website" />
|
|
<meta property="og:site_name" content="Base64" />
|
|
<meta name="twitter:card" content="summary_large_image" />
|
|
<meta name="twitter:title" content="Base64" />
|
|
<meta name="twitter:description" content="It's just a Base64, thats it, thats all it needs to do, it generates, displays and copies the Base64" />
|
|
<meta name="twitter:image" content="http://shots.wayl.one/shot/?url=https://b64.wayl.one/&height=630&width=1200&scaled_width=1200&scaled_height=640&selectors=" />
|
|
<style>
|
|
body {
|
|
background: black;
|
|
color: lime;
|
|
font-family: sans-serif;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
height: 100vh;
|
|
margin: 0;
|
|
}
|
|
.container {
|
|
text-align: center;
|
|
font-size: 4rem;
|
|
line-height: 1.2;
|
|
}
|
|
#b64 {
|
|
min-width: 100vw;
|
|
min-height: 5rem;
|
|
max-width: 100vw;
|
|
list-style: none;
|
|
padding: 0;
|
|
margin: 0;
|
|
font-size: 6rem;
|
|
margin-top: 1rem;
|
|
color: lime;
|
|
word-break: break-all;
|
|
}
|
|
/* Modal styles */
|
|
.modal-overlay {
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100vw;
|
|
height: 100vh;
|
|
background: rgba(0, 0, 0, 0.75);
|
|
display: none;
|
|
justify-content: center;
|
|
align-items: center;
|
|
z-index: 1000;
|
|
}
|
|
.modal {
|
|
box-shadow: 0 0 3rem 1rem #00ff0017;
|
|
background: black;
|
|
border: 2px solid lime;
|
|
border-radius: 0.5rem;
|
|
padding: 2rem;
|
|
max-width: 90%;
|
|
color: lime;
|
|
text-align: left;
|
|
font-size: 1.5rem;
|
|
}
|
|
.modal h2 {
|
|
margin-top: 0;
|
|
color: #008e00;
|
|
}
|
|
.modal ul {
|
|
color: #00ae00;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div id="b64" contenteditable="true"></div>
|
|
</div>
|
|
|
|
<!-- Modal -->
|
|
<div id="modal-overlay" class="modal-overlay">
|
|
<div class="modal">
|
|
<h2>Help</h2>
|
|
<p>
|
|
It's just a Base64, thats it, thats all it needs to do, it generates,
|
|
displays and copies the Base64. Start typing or paste your input, escape
|
|
and press <code>e</code> to encode, or <code>d</code> to decode.
|
|
</p>
|
|
<ul>
|
|
<li>
|
|
Paste values in with <kbd>Ctrl</kbd> + <kbd>v</kbd>
|
|
</li>
|
|
<li>
|
|
Copy with <kbd>Ctrl</kbd> + <kbd>c</kbd>
|
|
</li>
|
|
<li>
|
|
Decode with <kbd>d</kbd>
|
|
</li>
|
|
<li>
|
|
Encode with <kbd>e</kbd>
|
|
</li>
|
|
<li>
|
|
Escape with <kbd>Esc</kbd>
|
|
</li>
|
|
<li>
|
|
<kbd>?</kbd> for help
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
// Display
|
|
b64_el = document.getElementById('b64');
|
|
// on control c put uuid on clipboard
|
|
|
|
// ---- Modal logic ----
|
|
const overlay = document.getElementById('modal-overlay');
|
|
|
|
function toggleModal() {
|
|
if (overlay.style.display === 'none') {
|
|
overlay.style.display = 'flex';
|
|
document.activeElement.blur();
|
|
overlay.focus();
|
|
|
|
} else {
|
|
overlay.style.display = 'none';
|
|
}
|
|
}
|
|
function hideModal() {
|
|
overlay.style.display = 'none';
|
|
}
|
|
|
|
overlay.addEventListener('click', e => {
|
|
if (e.target === overlay) hideModal();
|
|
});
|
|
document.addEventListener('keydown', e => {
|
|
if (e.key === '?') {
|
|
toggleModal();
|
|
}
|
|
});
|
|
|
|
async function getClipboardContents() {
|
|
try {
|
|
return await navigator.clipboard.readText();
|
|
} catch (err) {
|
|
console.error('Failed to read clipboard contents: ', err);
|
|
}
|
|
}
|
|
|
|
document.addEventListener('keydown', e => {
|
|
if (overlay.style.display === 'flex' && e.key === 'Escape') {
|
|
hideModal();
|
|
}
|
|
else if (overlay.style.display === 'flex') {
|
|
}
|
|
else if (e.key === 'Escape' && document.activeElement === b64_el) {
|
|
b64_el.blur();
|
|
}
|
|
else if (document.activeElement === b64_el) {
|
|
}
|
|
else if (e.key === 'c' && e.ctrlKey) {
|
|
navigator.clipboard.writeText(b64_el.textContent);
|
|
}
|
|
|
|
else if (e.key === 'v' && e.ctrlKey) {
|
|
clipboardContents = getClipboardContents();
|
|
clipboardContents.then(contents => {
|
|
b64_el.textContent = contents;
|
|
});
|
|
}
|
|
else if (e.key === 'd') {
|
|
content = b64_el.textContent;
|
|
decoded = atob(content);
|
|
b64_el.textContent = decoded;
|
|
}
|
|
else if (e.key === 'e') {
|
|
content = b64_el.textContent;
|
|
encoded = btoa(content);
|
|
b64_el.textContent = encoded;
|
|
}
|
|
else if (e.key === '?') {
|
|
toggleModal();
|
|
}
|
|
else if (e.key === 'Escape' && overlay.style.display === 'flex') {
|
|
hideModal();
|
|
}
|
|
else if (e.key === 'Enter') {
|
|
b64_el.blur();
|
|
}
|
|
else if (e.key === 'Escape') {
|
|
b64_el.blur();
|
|
}
|
|
else if (e.ctrlKey) {
|
|
}
|
|
else if (e.shiftKey) {
|
|
}
|
|
else {
|
|
b64_el.focus();
|
|
}
|
|
}
|
|
|
|
)
|
|
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|