Skip to content

Instantly share code, notes, and snippets.

@come25136
Created November 6, 2018 16:18
Show Gist options
  • Select an option

  • Save come25136/334a4739d1a0156603ae1004c9a8b8c6 to your computer and use it in GitHub Desktop.

Select an option

Save come25136/334a4739d1a0156603ae1004c9a8b8c6 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>BitZenyBlockHeight</title>
<style>
.center {
text-align: center;
}
</style>
</head>
<body>
<div class="center">
<h1>BitZeny BlockHeight CheckTool</h1>
<h4>リアルタイム情報</h4>
正規チェーン
<p id="blockheight_1">読み込み中...</p><br />
非正規チェーン
<p id="blockheight_2">読み込み中...</p><br />
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.slim.js" integrity="sha256-0YA7ixx4+I4GrLichcjWSQHIUSQiI8ojTDqsK7AZ5zU=" crossorigin="anonymous"></script>
<script>
const eventToListenTo = "block";
const room = "inv";
const regular_chain_server_address = "https://insight.bitzeny.jp";
const non_regular_chain_server_address = "https://zeny.insight.monaco-ex.org";
const blockheight_1 = document.getElementById("blockheight_1");
const blockheight_2 = document.getElementById("blockheight_2");
fetch(`${regular_chain_server_address}/api/status`)
.then(res => res.json())
.then(({ info }) => {
blockheight_1.innerText = `${info.blocks} Block`;
});
const regular_chain_socket = io(regular_chain_server_address);
regular_chain_socket.on("connect", () =>
regular_chain_socket.emit("subscribe", room)
);
regular_chain_socket.on(eventToListenTo, block_id =>
fetch(`${regular_chain_server_address}/api/block/${block_id}`)
.then(res => res.json())
.then(({ height }) => {
blockheight_1.innerText = `${height} Block`;
})
);
fetch(`${non_regular_chain_server_address}/api/status`)
.then(res => res.json())
.then(({ info }) => {
blockheight_2.innerText = `${info.blocks} Block`;
});
const non_regular_chain_socket = io(non_regular_chain_server_address);
non_regular_chain_socket.on("connect", () => socket2.emit("subscribe", room));
non_regular_chain_socket.on(eventToListenTo, block_id =>
fetch(`${non_regular_chain_server_address}/api/block/${block_id}`)
.then(res => res.json())
.then(({ height }) => {
blockheight_2.innerText = `${height} Block`;
})
);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment