mirror of
https://github.com/seigler/dash-visualizer
synced 2025-07-27 01:36:10 +00:00
feat: add Dash logo
This commit is contained in:
parent
b84655afad
commit
601082cebe
3 changed files with 73 additions and 65 deletions
130
app.js
130
app.js
|
@ -1,71 +1,73 @@
|
|||
'use strict';
|
||||
|
||||
var socket = io("https://blockchain.masternode.io/");
|
||||
var transactionList = document.getElementById('transactionList');
|
||||
(function() {
|
||||
function playSound(url){
|
||||
var audio = document.createElement('audio');
|
||||
audio.style.display = "none";
|
||||
audio.src = url;
|
||||
audio.autoplay = true;
|
||||
audio.loop = false;
|
||||
audio.onended = function(){
|
||||
audio.remove() //Remove when played.
|
||||
};
|
||||
document.body.appendChild(audio);
|
||||
}
|
||||
|
||||
function playSound(url){
|
||||
var audio = document.createElement('audio');
|
||||
audio.style.display = "none";
|
||||
audio.src = url;
|
||||
audio.autoplay = true;
|
||||
audio.loop = false;
|
||||
audio.onended = function(){
|
||||
audio.remove() //Remove when played.
|
||||
var onTransaction = function(data) {
|
||||
console.log(data);
|
||||
playSound('assets/bell.mp3');
|
||||
var tx = document.createElement('div');
|
||||
tx.className = 'tx';
|
||||
var txValue = document.createElement('a');
|
||||
txValue.className = 'txValue';
|
||||
txValue.href = 'https://blockchain.masternode.io/tx/' + data.txid;
|
||||
txValue.target = '_blank';
|
||||
txValue.setAttribute('rel', 'noopener');
|
||||
var txOutputs = document.createElement('div');
|
||||
txOutputs.className = 'txOutputs';
|
||||
txValue.appendChild(document.createTextNode(data.valueOut));
|
||||
tx.appendChild(txValue);
|
||||
tx.appendChild(txOutputs);
|
||||
var transactions = data.vout.sort(function(a, b) { // sort descending by tx value
|
||||
return b[Object.keys(b)[0]] - a[Object.keys(a)[0]];
|
||||
});
|
||||
transactions.forEach(function(value, index, array) {
|
||||
var txOut = document.createElement('div');
|
||||
var outputSatoshis = value[Object.keys(value)[0]];
|
||||
txOut.className = 'txOut';
|
||||
txOut.style.width = (outputSatoshis * 0.00001).toFixed(4) + 'px';
|
||||
txOut.title = (value[Object.keys(value)[0]] * 0.00000001);
|
||||
txOutputs.appendChild(txOut);
|
||||
});
|
||||
transactionList.insertBefore(tx, transactionList.firstChild);
|
||||
};
|
||||
document.body.appendChild(audio);
|
||||
}
|
||||
|
||||
var onTransaction = function(data) {
|
||||
console.log(data);
|
||||
playSound('assets/bell.mp3');
|
||||
var tx = document.createElement('div');
|
||||
tx.className = 'tx';
|
||||
var txValue = document.createElement('a');
|
||||
txValue.className = 'txValue';
|
||||
txValue.href = 'https://blockchain.masternode.io/tx/' + data.txid;
|
||||
txValue.target = '_blank';
|
||||
txValue.setAttribute('rel', 'noopener');
|
||||
var txOutputs = document.createElement('div');
|
||||
txOutputs.className = 'txOutputs';
|
||||
txValue.appendChild(document.createTextNode(data.valueOut));
|
||||
tx.appendChild(txValue);
|
||||
tx.appendChild(txOutputs);
|
||||
var transactions = data.vout.sort(function(a, b) { // sort descending by tx value
|
||||
return b[Object.keys(b)[0]] - a[Object.keys(a)[0]];
|
||||
var onBlock = function(data) {
|
||||
console.log(data);
|
||||
playSound('assets/whoosh.mp3');
|
||||
var newBlock = document.createElement('a');
|
||||
newBlock.className = 'blockDivider';
|
||||
newBlock.href = 'https://blockchain.masternode.io/block/' + data;
|
||||
newBlock.target = '_blank';
|
||||
newBlock.setAttribute('rel', 'noopener');
|
||||
newBlock.appendChild(document.createTextNode(data));
|
||||
transactionList.insertBefore(newBlock, transactionList.firstChild);
|
||||
};
|
||||
|
||||
var socket = io("https://blockchain.masternode.io/");
|
||||
var transactionList = document.getElementById('transactionList');
|
||||
|
||||
socket.on('connect', function() {
|
||||
document.getElementById('connectionStatus').className = 'is-connected';
|
||||
// Join the room.
|
||||
socket.emit('subscribe', 'inv');
|
||||
})
|
||||
socket.on('tx', onTransaction);
|
||||
socket.on('block', onBlock);
|
||||
socket.on('disconnect', function() {
|
||||
document.getElementById('connectionStatus').className = 'is-disconnected';
|
||||
});
|
||||
transactions.forEach(function(value, index, array) {
|
||||
var txOut = document.createElement('div');
|
||||
var outputSatoshis = value[Object.keys(value)[0]];
|
||||
txOut.className = 'txOut';
|
||||
txOut.style.width = (outputSatoshis * 0.00001).toFixed(4) + 'px';
|
||||
txOut.title = (value[Object.keys(value)[0]] * 0.00000001);
|
||||
txOutputs.appendChild(txOut);
|
||||
socket.on('reconnecting', function() {
|
||||
document.getElementById('connectionStatus').className = 'is-connecting';
|
||||
});
|
||||
transactionList.insertBefore(tx, transactionList.firstChild);
|
||||
};
|
||||
|
||||
var onBlock = function(data) {
|
||||
console.log(data);
|
||||
playSound('assets/whoosh.mp3');
|
||||
var newBlock = document.createElement('a');
|
||||
newBlock.className = 'blockDivider';
|
||||
newBlock.href = 'https://blockchain.masternode.io/block/' + data;
|
||||
newBlock.target = '_blank';
|
||||
newBlock.setAttribute('rel', 'noopener');
|
||||
newBlock.appendChild(document.createTextNode(data));
|
||||
transactionList.insertBefore(newBlock, transactionList.firstChild);
|
||||
};
|
||||
|
||||
socket.on('connect', function() {
|
||||
document.getElementById('connectionStatus').className = 'is-connected';
|
||||
// Join the room.
|
||||
socket.emit('subscribe', 'inv');
|
||||
})
|
||||
socket.on('tx', onTransaction);
|
||||
socket.on('block', onBlock);
|
||||
socket.on('disconnect', function() {
|
||||
document.getElementById('connectionStatus').className = 'is-disconnected';
|
||||
});
|
||||
socket.on('reconnecting', function() {
|
||||
document.getElementById('connectionStatus').className = 'is-connecting';
|
||||
});
|
||||
})();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue