22 lines
1.0 KiB
JavaScript
22 lines
1.0 KiB
JavaScript
|
|
// ═══════════════════════════════════════════════════════
|
||
|
|
// Text Encoder / Decoder
|
||
|
|
// ═══════════════════════════════════════════════════════
|
||
|
|
async function encodeText(method) {
|
||
|
|
const text = document.getElementById('textencInput').value;
|
||
|
|
if (!text) return setStatus('textencStatus', 'error', 'Enter some text first.');
|
||
|
|
const d = await apiPost('/api/text/encode', { text, method });
|
||
|
|
if (d.success) {
|
||
|
|
document.getElementById('textencOutput').value = d.result;
|
||
|
|
setStatus('textencStatus', 'success', `Encoded with ${method} ✓`);
|
||
|
|
} else setStatus('textencStatus', 'error', d.error);
|
||
|
|
}
|
||
|
|
|
||
|
|
function swapTextEnc() {
|
||
|
|
const input = document.getElementById('textencInput');
|
||
|
|
const output = document.getElementById('textencOutput');
|
||
|
|
const tmp = input.value;
|
||
|
|
input.value = output.value;
|
||
|
|
output.value = tmp;
|
||
|
|
}
|
||
|
|
|