Commit 72c2139 1 parent dc9f10a commit 72c2139 Copy full SHA for 72c2139
File tree 4 files changed +49
-10
lines changed
4 files changed +49
-10
lines changed Original file line number Diff line number Diff line change 11
11
< script src ="script.js "> </ script >
12
12
</ head >
13
13
14
- < body >
14
+ < body onload =" toggleAsn1Button() " >
15
15
< header >
16
16
< span class ="title "> Bytes formatter</ span >
17
17
< span > The purpose of this tool is to convert bytes between different representations. See < a
27
27
< option value ="ascii "> Ascii</ option >
28
28
</ select >
29
29
< span > out:</ span >
30
- < select id ="outType ">
30
+ < select id ="outType " onchange =" toggleAsn1Button() " >
31
31
< option value ="decimal "> Decimal</ option >
32
32
< option value ="decimalArray "> Decimal array</ option >
33
33
< option value ="hex " selected > Hex</ option >
45
45
< div class ="tool " onclick ="copyOutputData() ">
46
46
< img src ="../img/copy.png " alt ="copy " />
47
47
</ div >
48
+ < div id ="asn1Tool " class ="hide labeledTool " onclick ="decodeAsAsn1() ">
49
+ < img src ="../img/linking1.png " alt ="asn1 " />
50
+ < span > asn1</ span >
51
+ </ div >
48
52
</ div >
49
53
</ article >
50
54
< footer >
Original file line number Diff line number Diff line change @@ -81,14 +81,7 @@ const decode = () => {
81
81
const inData = document . getElementById ( 'inData' ) . value ;
82
82
const outData = document . getElementById ( 'outData' ) ;
83
83
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 ) ) ;
92
85
} ;
93
86
94
87
const copyOutputData = ( ) => navigator . clipboard . writeText ( document . getElementById ( 'outData' ) . value ) ;
@@ -110,3 +103,18 @@ const swap = () => {
110
103
inData . value = outData . value ;
111
104
outData . value = buf ;
112
105
}
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
+ } ;
Original file line number Diff line number Diff line change @@ -72,6 +72,8 @@ textarea {
72
72
width : 100% ;
73
73
display : inline-flex;
74
74
margin-top : 0.7em ;
75
+ gap : 0.3em ;
76
+ align-items : center;
75
77
}
76
78
77
79
.tool {
@@ -93,6 +95,31 @@ textarea {
93
95
height : 90% ;
94
96
}
95
97
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
+
96
123
footer {
97
124
width : 70% ;
98
125
display : flex;
You can’t perform that action at this time.
0 commit comments