Revert: Update index.html

This commit is contained in:
2026-03-10 16:26:39 -07:00
parent b4d7d9e9b3
commit 50e93867d8

View File

@@ -14,51 +14,62 @@
<input id="decodeButton" type="button" name="button" value="decode from text"/> <input id="decodeButton" type="button" name="button" value="decode from text"/>
<select id="encoder"> <select id="encoder">
<optgroup label="Standard"> <optgroup label="Standard">
<option>ZWUS-3</option> <option value="ZWUS-3">ZWUS-3</option>
<option>ZWUS-6</option> <option value="ZWUS-6">ZWUS-6</option>
<option>ZWUS-8</option> <option value="ZWUS-8">ZWUS-8</option>
</optgroup> </optgroup>
<!-- <optgroup label="Depreciated"></optgroup>-->
</select> </select>
<select id="cipher"> <select id="cipher">
<optgroup label="Encryption"> <optgroup label="Encryption">
<option>PLAIN</option> <option value="PLAIN">PLAIN</option>
<option>SPECK32_64ECB</option> <option value="SPECK32_64ECB">SPECK32_64ECB</option>
</optgroup> </optgroup>
</select> </select>
<p id="notice"> <p id="notice">
notice: some platforms restrict Ø width characters. notice: some platforms restrict Ø width characters.
</p> </p>
<script type="module"> <script type="module">
import zwus from 'https://cdn.jsdelivr.net/npm/zwus'; import zwus from 'https://cdn.jsdelivr.net/npm/zwus@2.2.0/index.js';
const textarea = document.getElementById('textarea'); const textarea = document.getElementById('textarea');
const encoderDropdown = document.getElementById('encoder'); const encoderDropdown = document.getElementById('encoder');
const cipherDropdown = document.getElementById('cipher'); const cipherDropdown = document.getElementById('cipher');
const DESCRY = { const DESCRY = {
NO: { PLAIN: (ptStr, base) => zwus.encodeString(ptStr, base) }, NO: {
YES: { PLAIN: (ptStr, base) => zwus.decodeToString(ptStr, base) } PLAIN: (ptStr, base) => zwus.encodeString(ptStr, parseInt(base))
},
YES: {
PLAIN: (ptStr, base) => zwus.decodeToString(ptStr, parseInt(base))
}
}; };
['encodeButton', 'decodeButton'].forEach(id => function ACT(event) {
document.getElementById(id).addEventListener('click', event => { if (!textarea.value) {
if (!textarea.value) { textarea.value = 'The text box is empty.';
textarea.value = 'The text box is empty.'; return;
return; }
}
const op = event.target.id === 'encodeButton' ? 'NO' : 'YES'; const op = event.target.id === 'encodeButton' ? 'NO' : 'YES';
textarea.value = DESCRY[op][cipherDropdown.value]( const base = encoderDropdown.value.split('-')[1];
textarea.value, const cipher = cipherDropdown.value;
encoderDropdown.value.split('-')[1]
); // Ensure the cipher method exists in our mapping
if (DESCRY[op][cipher]) {
textarea.value = DESCRY[op][cipher](textarea.value, base);
if (op === 'NO') { if (op === 'NO') {
textarea.select(); textarea.select();
document.execCommand('copy'); document.execCommand('copy');
textarea.value = `Copied to clipboard. [${textarea.value}]`; textarea.value = 'Copied to your clipboard.\n A copy has been placed between these brackets [' + textarea.value + ']';
} }
}) } else {
); textarea.value = "Method " + cipher + " not implemented yet, Master.";
}
}
document.getElementById('encodeButton').addEventListener('click', ACT);
document.getElementById('decodeButton').addEventListener('click', ACT);
</script> </script>
</body> </body>
<style> <style>
@@ -88,8 +99,6 @@
display: block; display: block;
} }
/* ---------------------------------------------------- */
body { body {
font-family: 'Open Sans', sans-serif; font-family: 'Open Sans', sans-serif;
background-color: #002b4d; background-color: #002b4d;
@@ -165,12 +174,5 @@
color: rgb(229, 244, 255, 0.6); color: rgb(229, 244, 255, 0.6);
border-top: 1px solid rgb(0, 126, 199, .5); border-top: 1px solid rgb(0, 126, 199, .5);
} }
#versions {
color: rgb(0, 126, 199);
text-decoration: none;
}
</style> </style>
</html> </html>