Improvementz

This commit is contained in:
Mikko Ahlroth 2022-10-26 01:17:08 +03:00
parent cf9e49235b
commit be348e5b29
2 changed files with 6 additions and 2 deletions

View file

@ -18,7 +18,7 @@
<div id="length">Waiting...</div>
<div id="info">
v0.0.1 | © Nicd 2022 | <a href="https://gitlab.com/Nicd/tahnaroskakori" target="_blank">Source</a> | <a
v0.0.2 | © Nicd 2022 | <a href="https://gitlab.com/Nicd/tahnaroskakori" target="_blank">Source</a> | <a
href="./licenses.txt" target="_blank">Licenses</a>
</div>
</footer>

View file

@ -49,12 +49,16 @@ async function init() {
clearTimeout(compressTimeout);
}
if (codeEl.value === "") {
return;
}
compressTimeout = setTimeout(async () => {
const content = codeEl.value;
const compressed = compress(ENCODER.encode(content), { quality: QUALITY });
const encoded = BASE66CODEC.encode(compressed);
lengthEl.textContent = `Length: ${content.length} chars -> ${compressed.length} bytes -> ${encoded.length} chars`;
lengthEl.textContent = `Length: ${content.length} chars -> ${compressed.length} bytes -> ${encoded.length}/${maxHashLength()} chars`;
if (encoded.length <= maxHashLength()) {
history.replaceState(null, "", `#${encoded}`);