Skip to content

Commit 72c2139

Browse files
can go to asn1 parser for hex and base64
1 parent dc9f10a commit 72c2139

File tree

4 files changed

+49
-10
lines changed

4 files changed

+49
-10
lines changed

img/linking1.png

441 Bytes
Loading

src/index.html

+6-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<script src="script.js"></script>
1212
</head>
1313

14-
<body>
14+
<body onload="toggleAsn1Button()">
1515
<header>
1616
<span class="title">Bytes formatter</span>
1717
<span>The purpose of this tool is to convert bytes between different representations. See <a
@@ -27,7 +27,7 @@
2727
<option value="ascii">Ascii</option>
2828
</select>
2929
<span>out:</span>
30-
<select id="outType">
30+
<select id="outType" onchange="toggleAsn1Button()">
3131
<option value="decimal">Decimal</option>
3232
<option value="decimalArray">Decimal array</option>
3333
<option value="hex" selected>Hex</option>
@@ -45,6 +45,10 @@
4545
<div class="tool" onclick="copyOutputData()">
4646
<img src="../img/copy.png" alt="copy" />
4747
</div>
48+
<div id="asn1Tool" class="hide labeledTool" onclick="decodeAsAsn1()">
49+
<img src="../img/linking1.png" alt="asn1" />
50+
<span>asn1</span>
51+
</div>
4852
</div>
4953
</article>
5054
<footer>

src/script.js

+16-8
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,7 @@ const decode = () => {
8181
const inData = document.getElementById('inData').value;
8282
const outData = document.getElementById('outData');
8383

84-
console.dir({ inType, outType, inData });
85-
86-
const bytes = parsers[inType](inData);
87-
const value = formatters[outType](bytes);
88-
89-
console.log({ bytes, value });
90-
91-
outData.value = value;
84+
outData.value = formatters[outType](parsers[inType](inData));
9285
};
9386

9487
const copyOutputData = () => navigator.clipboard.writeText(document.getElementById('outData').value);
@@ -110,3 +103,18 @@ const swap = () => {
110103
inData.value = outData.value;
111104
outData.value = buf;
112105
}
106+
107+
const decodeAsAsn1 = () => window.open(
108+
`https://lapo.it/asn1js/#${document.getElementById('outData').value}`,
109+
'_blank'
110+
).focus();
111+
112+
const toggleAsn1Button = () => {
113+
const outType = document.getElementById('outType').value;
114+
115+
if (outType === 'hex' || outType === 'base64') {
116+
document.getElementById('asn1Tool').classList.remove("hide");
117+
} else {
118+
document.getElementById('asn1Tool').classList.add('hide');
119+
}
120+
};

src/style.css

+27
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ textarea {
7272
width: 100%;
7373
display: inline-flex;
7474
margin-top: 0.7em;
75+
gap: 0.3em;
76+
align-items: center;
7577
}
7678

7779
.tool {
@@ -93,6 +95,31 @@ textarea {
9395
height: 90%;
9496
}
9597

98+
.hide {
99+
display: none !important;
100+
}
101+
102+
.labeledTool {
103+
display: inline-flex;
104+
cursor: pointer;
105+
height: 1.5em;
106+
width: fit-content;
107+
padding: 0.1em 0.2em 0.1em 0.2em;
108+
border-radius: 0.2em;
109+
border: 2px solid black;
110+
justify-content: center;
111+
align-items: center;
112+
gap: 0.2em;
113+
}
114+
115+
.labeledTool:hover {
116+
background-color: aliceblue;
117+
}
118+
119+
.labeledTool>img {
120+
height: 80%;
121+
}
122+
96123
footer {
97124
width: 70%;
98125
display: flex;

0 commit comments

Comments
 (0)