forked from Izzzio/BlockExplorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitcoenProvider.js
More file actions
56 lines (47 loc) · 1.35 KB
/
bitcoenProvider.js
File metadata and controls
56 lines (47 loc) · 1.35 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
47
48
49
50
51
52
53
54
55
56
/**
iZ³ | Izzzio blockchain - https://izzz.io
@author: Andrey Nedobylsky (admin@twister-vl.ru)
*/
(function () {
var candy;
var readyCallback = false;
var nodes = ["wss://bitcoen.io/blockchain/", "ws://localhost:6013", "ws://node1.bitcoen.io:6013", "ws://node2.bitcoen.io:6013", "ws://node3.bitcoen.io:6013", "ws://node4.bitcoen.io:6013"];
function startProvider() {
if(Candy) {
candy = new Candy(nodes).start();
candy.onready = function () {
if(readyCallback) {
readyCallback();
}
}
} else {
throw 'Candy not loaded';
}
}
var script = document.createElement('script');
script.onload = function () {
startProvider();
};
script.src = '//explorer.bitcoen.io/candy.js';
document.head.appendChild(script);
window.bitcoen = {
ready: function (cb) {
if(typeof cb !== 'undefined') {
readyCallback = cb;
}
},
getHeight: function () {
if(candy) {
return candy.blockHeight;
}
return 0;
},
getNodes: function () {
if(candy) {
return candy.getActiveConnections();
}
return [];
},
candy: candy
};
})();