key updates
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
9788baa322
commit
9f51669735
2 changed files with 19 additions and 1 deletions
|
@ -36,9 +36,15 @@
|
||||||
|
|
||||||
<label for="bech32">hex key</label>
|
<label for="bech32">hex key</label>
|
||||||
<input type="text" class="u-full-width" placeholder="" id="hex-key">
|
<input type="text" class="u-full-width" placeholder="" id="hex-key">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h2>Links</h2>
|
||||||
|
<a id="note-link" href="">Damus Note Link</a><br/>
|
||||||
|
<a id="profile-link" href="">Damus Profile Link</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="bech32.js" ></script>
|
<script src="bech32.js" ></script>
|
||||||
<script src="key.js" ></script>
|
<script src="key.js?v=3" ></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
12
key/key.js
12
key/key.js
|
@ -21,12 +21,24 @@ function hex_encode(buf)
|
||||||
function go() {
|
function go() {
|
||||||
const el = document.querySelector("#damus-key")
|
const el = document.querySelector("#damus-key")
|
||||||
const hex_el = document.querySelector("#hex-key")
|
const hex_el = document.querySelector("#hex-key")
|
||||||
|
const note_link_el = document.querySelector("#note-link")
|
||||||
|
const profile_link_el = document.querySelector("#profile-link")
|
||||||
|
|
||||||
el.addEventListener("input", () => {
|
el.addEventListener("input", () => {
|
||||||
const decoded = bech32.decode(el.value)
|
const decoded = bech32.decode(el.value)
|
||||||
const bytes = fromWords(decoded.words)
|
const bytes = fromWords(decoded.words)
|
||||||
hex_el.value = hex_encode(bytes)
|
hex_el.value = hex_encode(bytes)
|
||||||
|
update_note_link(hex_el.value)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
hex_el.addEventListener("input", () => {
|
||||||
|
update_note_link(hex_el.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
function update_note_link(id) {
|
||||||
|
note_link_el.href = `nostr:e:${id}`
|
||||||
|
profile_link_el.href = `nostr:p:${id}`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
go()
|
go()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue