Skip to content

Commit

Permalink
New: Copy as pretty
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Burgmaier committed Jan 29, 2024
1 parent 36dd239 commit 01b1525
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="icon" type="image/svg+xml" sizes="192x192" href="favicon.svg">
</head>
<body>
<div id="contextmenu" onmouseleave="this.style.visibility = 'hidden';"><button id="btnCopyHex">Copy as HEX</button><br><button id="btnCopyString">Copy as String</button></div>
<div id="contextmenu" onmouseleave="this.style.visibility = 'hidden';"><button id="btnCopyHex">Copy as HEX</button><br><button id="btnCopyString">Copy as String</button><br><button id="btnCopyPretty">Copy as Pretty</button></div>
<header>
<div class="title">
<h1>ASN.1 JavaScript decoder</h1>
Expand Down
11 changes: 11 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,15 @@ document.getElementById('btnCopyString').onclick = function (event) {
event.stopPropagation();
};

document.getElementById('btnCopyPretty').onclick = function (event) {
let contextMenu = document.getElementById('contextmenu');
let node = contextMenu.node;
const pos = parseInt(node.getAttribute('pos'));
const end = parseInt(node.getAttribute('end'));
let result = ASN1.decode(window.derBuffer.subarray(pos, end));
navigator.clipboard.writeText(result.toPrettyString());
contextMenu.style.visibility = 'hidden';
event.stopPropagation();
};

});

0 comments on commit 01b1525

Please sign in to comment.