mirror of
https://github.com/hexahigh/bitlong.git
synced 2025-12-11 20:15:10 +01:00
made b64 the default method and fixed the binary method
This commit is contained in:
parent
a531bbeb60
commit
4f25adfcd2
@ -1,11 +1,11 @@
|
||||
function stringToBinary(str) {
|
||||
return str.split('').map(function (char) {
|
||||
return char.charCodeAt(0).toString(2);
|
||||
}).join(' ');
|
||||
}).join('-');
|
||||
}
|
||||
|
||||
function binaryToString(binary) {
|
||||
return binary.split(' ').map(function (bin) {
|
||||
return binary.split('-').map(function (bin) {
|
||||
return String.fromCharCode(parseInt(bin, 2));
|
||||
}).join('');
|
||||
}
|
||||
@ -6,16 +6,19 @@ const method = document.getElementById("method")
|
||||
createButton.addEventListener("click", create)
|
||||
|
||||
function create() {
|
||||
out = createMethod()
|
||||
output.value = "https://thisisaveryshortdomain.asso.eu.org?url=" + out
|
||||
out, type = createMethod()
|
||||
output.value = "https://thisisaveryshortdomain.asso.eu.org?type=" + type + "&url=" + out
|
||||
}
|
||||
|
||||
function createMethod() {
|
||||
var out2
|
||||
var type2
|
||||
if (method.value == "binary") {
|
||||
out2 = stringToBinary(urlInput.value)
|
||||
type2 = "binary"
|
||||
} else if (method.value == "b64") {
|
||||
out2 = btoa(urlInput.value)
|
||||
type2 = "binary"
|
||||
}
|
||||
return out2
|
||||
return out2, type
|
||||
}
|
||||
@ -20,8 +20,8 @@
|
||||
<label for="method">Select a method</label>
|
||||
<br>
|
||||
<select id="method">
|
||||
<option value="binary">Binary</option>
|
||||
<option value="b64">Base 64</option>
|
||||
<option value="binary">Binary</option>
|
||||
</select>
|
||||
<br>
|
||||
<button id="createButton">Create url</button>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user