Change websocket examples.
This commit is contained in:
parent
1eedcf900b
commit
a0624df06b
@ -3429,16 +3429,16 @@ export class ApiDocsComponent implements OnInit {
|
||||
ws.addEventListener('message', function incoming({data}) {
|
||||
const res = JSON.parse(data.toString());
|
||||
if (res.blocks) {
|
||||
document.getElementById("result").textContent = JSON.stringify(res.blocks, undefined, 2);
|
||||
document.getElementById("result-blocks").textContent = JSON.stringify(res.blocks, undefined, 2);
|
||||
}
|
||||
if (res.mempoolInfo) {
|
||||
document.getElementById("result").textContent = JSON.stringify(res.mempoolInfo, undefined, 2);
|
||||
document.getElementById("result-mempool-info").textContent = JSON.stringify(res.mempoolInfo, undefined, 2);
|
||||
}
|
||||
if (res.transactions) {
|
||||
document.getElementById("result").textContent = JSON.stringify(res.transactions, undefined, 2);
|
||||
document.getElementById("result-transactions").textContent = JSON.stringify(res.transactions, undefined, 2);
|
||||
}
|
||||
if (res.mempoolBlocks) {
|
||||
document.getElementById("result").textContent = JSON.stringify(res.mempoolBlocks, undefined, 2);
|
||||
document.getElementById("result-mempool-blocks").textContent = JSON.stringify(res.mempoolBlocks, undefined, 2);
|
||||
}
|
||||
});
|
||||
`,
|
||||
|
@ -172,6 +172,14 @@ init();`;
|
||||
importText = `<script src="https://liquid.network/liquid.js"></script>`;
|
||||
}
|
||||
|
||||
let resultHtml = '<pre id="result"></pre>';
|
||||
if (this.method === 'websocket') {
|
||||
resultHtml = `<pre id="result-blocks"></pre>
|
||||
<pre id="result-mempool-info"></pre>
|
||||
<pre id="result-transactions"></pre>
|
||||
<pre id="result-mempool-blocks"></pre>`;
|
||||
}
|
||||
|
||||
return `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
@ -184,7 +192,7 @@ init();`;
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="result"></pre>
|
||||
${resultHtml}
|
||||
</body>
|
||||
</html>`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user