-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
46 lines (44 loc) · 1.42 KB
/
Copy pathindex.html
File metadata and controls
46 lines (44 loc) · 1.42 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Jade Time QR Generator</title>
<style>
body { font-family: sans-serif; text-align: center; margin-top: 2em; }
canvas { margin: 1em 0; }
pre { background: #f4f4f4; padding: 1em; border-radius: 5px; display: inline-block; }
</style>
<script src="https://cdn.jsdelivr.net/npm/cbor-js@0.1.0/cbor.js"></script>
<script src="https://cdn.jsdelivr.net/npm/qrious@4.0.2/dist/qrious.min.js"></script>
</head>
<body>
<h1>Jade Time QR</h1>
<canvas id="qr"></canvas>
<p>BC-UR string (scan with Jade):</p>
<pre id="ur"></pre>
<script>
function toUR(type, cborBytes) {
let hex = "";
for (let b of cborBytes) hex += b.toString(16).padStart(2, "0");
return `ur:${type}/${hex}`;
}
window.onload = function () {
const now = Math.floor(Date.now() / 1000);
const cborObj = {
id: String(Math.floor(Math.random() * 1000000)),
method: "set_epoch",
params: { epoch: now } // Fixed: changed from 'timestamp' to 'epoch'
};
// Convert ArrayBuffer to Uint8Array for iteration
const cborData = new Uint8Array(CBOR.encode(cborObj));
const urString = toUR("jade-msg", cborData);
document.getElementById("ur").textContent = urString;
new QRious({
element: document.getElementById("qr"),
value: urString,
size: 256
});
};
</script>
</body>
</html>