Skip to content

Commit 5e169e4

Browse files
add button for sharing (construct and copy url with parameters)
1 parent 72c2139 commit 5e169e4

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

img/share.png

642 Bytes
Loading

src/index.html

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
<div class="tool" onclick="copyOutputData()">
4646
<img src="../img/copy.png" alt="copy" />
4747
</div>
48+
<div id="share" class="tool" onclick="share()">
49+
<img src="../img/share.png" alt="share" />
50+
</div>
4851
<div id="asn1Tool" class="hide labeledTool" onclick="decodeAsAsn1()">
4952
<img src="../img/linking1.png" alt="asn1" />
5053
<span>asn1</span>

src/script.js

+11
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,14 @@ const toggleAsn1Button = () => {
118118
document.getElementById('asn1Tool').classList.add('hide');
119119
}
120120
};
121+
122+
const share = () => {
123+
const inType = document.getElementById('inType').selectedOptions[0].value;
124+
const outType = document.getElementById('outType').selectedOptions[0].value;
125+
const data = document.getElementById('inData').value;
126+
127+
const url = `?in=${inType}&out=${outType}&data=${encodeURIComponent(data)}`;
128+
129+
window.history.pushState(url, url, url);
130+
navigator.clipboard.writeText(window.location.href);
131+
};

0 commit comments

Comments
 (0)