CoinCap.io Websocket

Developer
Size
4,654 Kb
Views
38,456

How do I make an coincap.io websocket?

Work in Progress.. socket.io-1.7.3.js websocket @ coincap.io forex data from nrb.org.np/exportForexJSON.php. What is a coincap.io websocket? How do you make a coincap.io websocket? This script and codes were developed by Nepal Bitcoin on 06 December 2022, Tuesday.

CoinCap.io Websocket Previews

CoinCap.io Websocket - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CoinCap.io Websocket</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel='stylesheet prefetch' href='http://cdnjs.cloudflare.com/ajax/libs/motion-ui/1.2.2/motion-ui.min.css'>
<link rel='stylesheet prefetch' href='http://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.1/css/foundation.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <span id="status">Retrieving forex data from http://nrb.org.np</span> <div id="coins"> <table id="" class="responsive hover"> <thead class="sticky" data-sticky> <tr> <th data-sort-default>#</th> <th data-sort="NAME">Name (Symbol)</th> <th data-sort="NPR" onclick="sortBy=NPR;">Price (NPR)</th> <th>24h</th> <th>1 NPR</th> <th>Vol/Market</th> <th>Volume(NPR)</th> <th>Market Cap(NPR)</th> <th>Total Supply</th> </tr> </thead> <tbody class="list" id="cList"> <tr id="ETH"> <td class="SN"></td> <td class="NAME"></td> <td class="PRICE"></td> <td class="VOL"></td> <td class="CAP"></td> <td class="VOL_CAP"></td> <td class="SUPPLY"></td> <td class="CHANGE"></td> <td class="NPR"></td> </tr> </tbody> </table>
</div> <script src='http://cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/socket.io/1.7.3/socket.io.slim.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/what-input/4.1.1/what-input.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/motion-ui/1.2.2/motion-ui.min.js'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.1/js/foundation.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

CoinCap.io Websocket - Script Codes CSS Codes

table { text-align: center;
}
table thead th { font-weight: 800; text-align: center;
} .up { color: green;
}
.down { color: red;
}
/*@-webkit-keyframes down { from { background-color: rgba(255, 0, 0, 0.20); } to { background-color: inherit; }
}
@-moz-keyframes down { from { background-color: rgba(255, 0, 0, 0.20); } to { background-color: inherit; }
}
@-o-keyframes down { from { background-color: rgba(255, 0, 0, 0.20); } to { background-color: inherit; }
}
@keyframes down { from { background-color: rgba(255, 0, 0, 0.20); } to { background-color: inherit; }
}
.down { -webkit-animation: down 0.5s 1; /* Safari 4+ * / -moz-animation: down 0.5s 1; /* Fx 5+ * / -o-animation: down 0.5s 1; /* Opera 12+ * / animation: down 0.5s 1; /* IE 10+ * /
}
@-webkit-keyframes up { from { background-color: rgba(0, 255, 0, 0.20); } to { background-color: inherit; }
}
@-moz-keyframes up { from { background-color: rgba(0, 255, 0, 0.20); } to { background-color: inherit; }
}
@-o-keyframes up { from { background-color: rgba(0, 255, 0, 0.20); } to { background-color: inherit; }
}
@keyframes up { from { background-color: rgba(0, 255, 0, 0.20); } to { background-color: inherit; }
}
.up { -webkit-animation: up 0.5s 1; /* Safari 4+ * / -moz-animation: up 0.5s 1; /* Fx 5+ * / -o-animation: up 0.5s 1; /* Opera 12+ * / animation: up 0.5s 1; /* IE 10+ * /
}*/

CoinCap.io Websocket - Script Codes JS Codes

var options = { valueNames: ['SN', 'NAME', 'PRICE', 'CHANGE', 'NPR', 'VOL_CAP', 'VOL', 'CAP', 'SUPPLY']
};
var sortBy = "SN";
var xTable = new List('coins', options);
var socket = io.connect('https://coincap.io');
var stat = document.getElementById("status");
var USDNPR = 106.33;
var NP_NUM; // = new NeNum();
$(document).ready(function() { var TS = new Date(); NP_NUM = new NeNum(); $.getJSON("https://runkit.io/nepalbitcoin/nrb-forex-json/0.0.2").done(function(NRB) { var forex = NRB.result.Conversion.Currency[1]; if (forex.TargetBuy && forex.TargetSell) { stat.innerHTML = "Connecting to https://coincap websocket.."; USDNPR = ((1 * forex.TargetBuy + 1 * forex.TargetSell) / 2).toFixed(3); } market(); })
})
var market = function() { socket.on('trades', function(tradeMsg) { MotionUI.animateIn('#' + tradeMsg.message.coin, 'fade-out fast'); var msgx = tradeMsg.message.msg; var Price = msgx.price * USDNPR; stat.innerHTML = "Last updated : " + msgx.long + ' \(' + msgx.short + '\)'; var xdata = [msgx.position24, msgx.long + ' \(' + msgx.short + '\)', NP_NUM.convert(Price.toFixed(Price < 1 ? 8 : 2)), msgx.cap24hrChange, NP_NUM.convert((1 / Price).toFixed(8)), NP_NUM.convert((((msgx.volume * USDNPR).toFixed(0) / (msgx.mktcap * USDNPR).toFixed(0)) * 100).toFixed(3)), NP_NUM.convert((msgx.volume * USDNPR).toFixed(0)), NP_NUM.convert((msgx.mktcap * USDNPR).toFixed(0)), NP_NUM.convert(msgx.supply) ]; var Y = document.getElementById(tradeMsg.message.coin); if (Y == null) { xTR = document.getElementById('cList').insertRow(); xTR.id = tradeMsg.message.coin; Y = document.getElementById(tradeMsg.message.coin); } MotionUI.animateIn('#' + tradeMsg.message.coin, 'fade-in slow'); //Y.className +=" wiggle "+((Number(msgx.cap24hrChange) < 0 ? "down" : "up")); //var tooltip = ' data-tooltip aria-haspopup="true" data-disable-hover="true" class="has-tip left" title="'; Y.innerHTML = '<td class="SN">' + xdata[0] + '</td><td class="NAME">' + xdata[1] + '</td><td class="PRICE" title="' + xdata[2][2] + '">' + xdata[2][1] + '</td> <td class="CHANGE ' + (Number(msgx.cap24hrChange) < 0 ? "down" : "up") + '">' + msgx.cap24hrChange + '%</td> <td class="NPR">' + xdata[4][1] + ' ' + msgx.short + '</td><td class="VOL_CAP" title="' + xdata[5][2] + '">' + (xdata[5][1]) + '%</td><td class="VOL" title="' + xdata[6][2] + '">' + xdata[6][1] + '</td><td class="CAP" title="' + xdata[7][2] + '">' + xdata[7][1] + '</td><td class="SUPPLY">' + xdata[8][1] + ' ' + msgx.short + '</td>'; xTable.reIndex(); xTable.sort(sortBy, { order: "asc" }); })
};
/*
xTable.add({
SN: xdata[0],
NAME: xdata[1],
PRICE: xdata[2][1],
VOL: xdata[3][1],
CAP: xdata[4][1],
VOL_CAP: xdata[5] + "%",
SUPPLY: xdata[6][1] + " " + msgx.short,
CHANGE: xdata[7] + "%",
NPR: xdata[8][1] + " " + msgx.short
});
*/
/***
Nepali Number word format js
Minified **/
var NeNum = function(r) { function e(r) { if ("number" != typeof Number(r) || Number(r) < 0 || isNaN(Number(r)) || r >= 1e20) return !1; var e = r.toString().split("."), f = "0"; e[1] > 0 && (f = e[1]); for (var c = 0 == e[0] ? [0] : e[0].split("").reverse(), a = [], l = [], s = 0, v = 0; v < c.length; v++) 0 == v ? (a[s] = (c[v + 1] >= 0 ? c[v + 1] : "") + "" + c[v], l[s] = o[1 * a[s]], v++) : (2 == v || "undefined" == typeof c[v + 1] ? a[s] = c[v] : (a[s] = c[v + 1] + "" + c[v], v++), l[s] = Number(a[s]) > 0 ? o[Number(a[s])] + " " + i[s] : ""), s++; return [r.toString(), t(a, f), n(l.reverse().join(" ") + u(f, e[0]))] } function n(r) { for (; r.includes(" ");) r = r.replace(" ", " "); return r } function t(r, e) { var n = r.reverse().join(","); return "," == n.charAt(n.length - 3) && (n = n.slice(0, -3) + n.slice(-2)), n + (0 == e ? "" : "." + e) } function u(r, e) { for (var n = r.split(""), t = "", u = 0; u < n.length; u++) t += "0" == n[u] ? " शून्य" : " " + o[n[u]]; return 1 > e ? "शुन्य दशमलव" + t : 0 == r ? "" : " दशमलव" + t } var i = ["", "सय", "हजार", "लाख", "करोड", "अर्ब", "खर्ब", "निल", "पद्म", "संख्य"], o = ["", "एक", "दुई", "तीन", "चार", "पाँच", "छ", "सात", "आठ", "नौँ", "दश", "एघार", "बाह्र", "तेह्र", "चौध", "पन्ध्र", "सोह्र", "सत्र", "अठार", "उन्नाइस", "बीस", "एक्काइस", "बाइस", "तेईस", "चौबीस", "पच्चिस", "छब्बिस", "सत्ताइस", "अठ्ठाइस", "उन्नतीस", "तीस", "एकतीस", "बत्तीस", "तेत्तिस", "चौतीस", "पैँतीस", "छत्तिस", "सैँतीस", "अठतीस", "उन्नचालीस", "चालीस", "एकचालीस", "बयालीस", "त्रिचालिस", "चौवालीस", "पैँतालीस", "छयालीस", "सतचालिस", "अठचालीस", "उन्नपचास", "पचास", "एकाउन्न", "बाउन्न", "त्रिपन्न", "चौवन्न", "पचपन्न", "छपन्न", "सन्ताउन्न", "अन्ठाउन्न", "उन्नसाठी", "साठी", "एकसठ्ठी", "बैसठ्ठी", "त्रिसठ्ठी", "चौसठ्ठी", "पैसठ्ठी", "छैसठ्ठी", "सतसठ्ठी", "अठसठ्ठी", "उनान्सत्तरी", "सत्तरी", "एकहत्तर", "बहत्तर", "तिरहत्तर", "चौरहत्तर", "पचहत्तर", "छहत्तर", "सतहत्तर", "अठहत्तर", "उनानसी", "असी", "एकासी", "बयासी", "त्रियासी", "चौरासी", "पचासी", "छयासी", "सतासी", "अठासी", "उनान्नब्बे", "नब्बे", "एकानब्बे", "बयानब्बे", "त्रियानब्बे", "चौरानब्बे", "पन्चानब्बे", "छयानब्बे", "सन्तानब्बे", "अन्ठानब्बे", "उनान्सय"]; return { convert: function(r) { return e(r) }, format: function() { return !0 } }
};
/*
-- -- --
*/
CoinCap.io Websocket - Script Codes
CoinCap.io Websocket - Script Codes
Home Page Home
Developer Nepal Bitcoin
Username nepalbitcoin
Uploaded December 06, 2022
Rating 3
Size 4,654 Kb
Views 38,456
Do you need developer help for CoinCap.io Websocket?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Nepal Bitcoin (nepalbitcoin) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!