Added binary decoding.
This commit is contained in:
parent
79fc530fb5
commit
5582c0909c
10
index.html
10
index.html
|
@ -310,7 +310,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function getName() {
|
function getName() {
|
||||||
const decoded = base32.decode(codeInput.value);
|
const input = codeInput.value.trim();
|
||||||
|
|
||||||
|
if (/^([01]{8}(\s|$))+/.test(input)) {
|
||||||
|
// decode binary
|
||||||
|
nameOutput.value = new TextDecoder().decode(new Int8Array(input.split(/\s+/).map((binaryLetter) => parseInt(binaryLetter, 2))));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const decoded = base32.decode(input);
|
||||||
const capitalized = decoded.split(' ').map((word) => `${word.slice(0, 1).toUpperCase()}${word.slice(1)}`).join(' ');
|
const capitalized = decoded.split(' ').map((word) => `${word.slice(0, 1).toUpperCase()}${word.slice(1)}`).join(' ');
|
||||||
|
|
||||||
nameOutput.value = capitalized.replace(/#+$/, '');
|
nameOutput.value = capitalized.replace(/#+$/, '');
|
||||||
|
|
Loading…
Reference in New Issue