-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathinspect.html
62 lines (62 loc) · 1.27 KB
/
inspect.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
<html>
<head>
<style>
body {
margin: 0;
}
textarea:focus {
outline: none;
}
textarea {
padding: 10px;
background: rgba(0,0,0,0.9);
color: burlywood;
font-family: Menlo, monaco, monospace;
border: none;
width: 100%;
height: 100%;
font-size: 11px;
}
</style>
<script>
let params = (new URL(document.location)).searchParams;
let uri = params.get("uri");
let tx = params.get("tx");
const header = { headers: { key: "16JaLJ8b5UvQp355Gva2qhuTS65NkowhPr " } };
const g = function(query, cb) {
var b64 = btoa(JSON.stringify(query));
var url = "https://genesis.bitdb.network/q/1FnauZ9aUH2Bex6JzdcV4eNX7oLSSEbxtN/" + b64;
fetch(url, header).then(function(r) {
return r.json()
}).then(function(r) {
cb(r)
})
}
document.addEventListener("DOMContentLoaded", function(e) {
if (uri) {
fetch(uri).then(function(res) {
return res.text();
}).then(function(res) {
document.querySelector("textarea").value = res
})
} else if (tx) {
g({
v: 3,
q: {
find: { "tx.h": tx }
}
}, function(r) {
let res = r.u.concat(r.c).filter(function(k) {
return k
})
document.querySelector("textarea").value = JSON.stringify(res, null, 2)
})
}
})
</script>
</head>
<body>
<textarea>
</textarea>
</body>
</html>