Skip to content

Commit dc9f10a

Browse files
add swap button
1 parent 0aaa2b3 commit dc9f10a

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

img/replace1.png

1.06 KB
Loading

src/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
<option value="base64">Base64</option>
3535
<option value="ascii">Aescii</option>
3636
</select>
37+
<div class="paramTool" onclick="swap()">
38+
<img src="../img/replace1.png" alt="copy" />
39+
</div>
3740
</div>
3841
<textarea id="inData" placeholder="Input data..." rows="7"></textarea>
3942
<button onclick="decode()">convert</button>

src/script.js

+18
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,21 @@ const decode = () => {
9292
};
9393

9494
const copyOutputData = () => navigator.clipboard.writeText(document.getElementById('outData').value);
95+
96+
const swap = () => {
97+
const inType = document.getElementById('inType');
98+
const outType = document.getElementById('outType');
99+
100+
let buf = inType.selectedOptions[0].value;
101+
102+
inType.value = outType.selectedOptions[0].value;
103+
outType.value = buf;
104+
105+
const inData = document.getElementById('inData');
106+
const outData = document.getElementById('outData');
107+
108+
buf = inData.value;
109+
110+
inData.value = outData.value;
111+
outData.value = buf;
112+
}

src/style.css

+20
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ article {
3434
display: inline-flex;
3535
margin-top: 1em;
3636
gap: 0.5em;
37+
align-items: center;
38+
}
39+
40+
.paramTool {
41+
display: inline-flex;
42+
cursor: pointer;
43+
height: 1.5em;
44+
width: fit-content;
45+
padding: 0.2em;
46+
border-radius: 0.3em;
47+
justify-content: center;
48+
align-items: center;
49+
}
50+
51+
.paramTool:hover {
52+
background-color: aliceblue;
53+
}
54+
55+
.paramTool>img {
56+
height: 90%;
3757
}
3858

3959
button {

0 commit comments

Comments
 (0)