-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
141 lines (135 loc) · 3.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>BOLT12 Offer Decoder</title>
<style>
body {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
background-color: #1e1e1e;
margin: 0;
padding: 20px;
color: #e0e0e0;
}
.container {
display: flex;
flex-direction: column;
gap: 20px;
max-width: 800px;
margin: auto;
padding: 10px;
}
.box {
background-color: #2b2b2b;
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
border-radius: 10px;
padding: 20px;
transition: box-shadow 0.3s ease;
}
.box:hover {
box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}
textarea {
width: 100%;
padding: 12px;
border-radius: 6px;
border: 1px solid #444;
box-sizing: border-box;
min-height: 250px;
font-size: 15px;
line-height: 1.5;
background-color: #333;
color: #e0e0e0;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
textarea:focus {
border-color: #5b9bd5;
box-shadow: 0 0 5px rgba(91, 155, 213, 0.5);
outline: none;
}
.title {
margin-bottom: 10px;
color: #ffffff;
font-weight: bold;
font-size: 16px;
text-align: left;
}
/* GitHub Ribbon Styles */
.github-fork {
position: absolute;
top: 0;
right: 0;
border: 0;
}
</style>
</head>
<body>
<!-- GitHub Ribbon -->
<a
href="https://github.com/clams-tech/bolt12-decoder-app"
class="github-fork"
>
<img
decoding="async"
loading="lazy"
width="149"
height="149"
src="https://github.blog/wp-content/uploads/2008/12/forkme_right_green_007200.png?resize=149%2C149"
class="attachment-full size-full"
alt="Fork me on GitHub"
data-recalc-dims="1"
/>
</a>
<div class="container">
<div class="box">
<div class="title">Encoded BOLT12 Offer</div>
<textarea
id="encodedInput"
placeholder="Paste a BOLT12 offer here"
></textarea>
</div>
<div class="box">
<div class="title">Decoded BOLT12 Offer</div>
<textarea
id="decodedOutput"
placeholder="Decoded JSON will appear here"
readonly
></textarea>
</div>
</div>
<script type="module">
import bolt12Decoder from "bolt12-decoder";
const encodedInput = document.getElementById("encodedInput");
const decodedOutput = document.getElementById("decodedOutput");
function resizeTextarea(textarea) {
textarea.style.height = "auto";
textarea.style.height = textarea.scrollHeight + "px";
}
function decodeAndUpdate(encoded) {
try {
const decoded = bolt12Decoder.decode(encoded);
decodedOutput.value = JSON.stringify(decoded, null, 2);
resizeTextarea(decodedOutput);
} catch (e) {
decodedOutput.value = "Error decoding BOLT12: " + e.message;
resizeTextarea(decodedOutput);
}
}
encodedInput.addEventListener("input", (event) => {
decodeAndUpdate(event.target.value);
resizeTextarea(event.target);
});
// Parse the URL query string
window.addEventListener("load", () => {
const urlParams = new URLSearchParams(window.location.search);
const offer = urlParams.get("offer");
if (offer) {
encodedInput.value = offer;
decodeAndUpdate(offer);
resizeTextarea(encodedInput);
}
});
</script>
</body>
</html>