Created
February 22, 2018 23:37
-
-
Save mshll/984838d740d550c3f5c25b502d209d71 to your computer and use it in GitHub Desktop.
Bitcoin + Litecoin ticker js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function httpGet(theUrl) | |
{ | |
var xmlHttp = null; | |
xmlHttp = new XMLHttpRequest(); | |
xmlHttp.open( "GET", theUrl, false ); | |
xmlHttp.send( null ); | |
return xmlHttp.responseText; | |
} | |
function FormatNumberLength(num, length) { | |
var r = "" + num; | |
while (r.length < length) { | |
r = "0" + r; | |
} | |
return r; | |
} | |
crypt_multi_background_color = typeof crypt_multi_background_color == "undefined" ? "#FFFFFF" : crypt_multi_background_color; | |
crypt_multi_transperency = typeof crypt_multi_transperency == "undefined" ? true : crypt_multi_transperency; | |
crypt_multi_border_width = typeof crypt_multi_border_width == "undefined" ? 1 : crypt_multi_border_width; | |
crypt_multi_border_color = typeof crypt_multi_border_color == "undefined" ? "#CCCCCC" : crypt_multi_border_color; | |
crypt_multi_border_corners = typeof crypt_multi_border_corners == "undefined" ? "rounded" : crypt_multi_border_corners; | |
crypt_multi_font_family = typeof crypt_multi_font_family == "undefined" ? "Arial" : crypt_multi_font_family; | |
crypt_multi_font_size = typeof crypt_multi_font_size == "undefined" ? "medium" : crypt_multi_font_size; | |
crypt_multi_font_color = typeof crypt_multi_font_color == "undefined" ? "#000000" : crypt_multi_font_color; | |
crypt_multi_display_time = typeof crypt_multi_display_time == "undefined" ? true : crypt_multi_display_time; | |
if (crypt_multi_transperency) | |
crypt_multi_background_color = 'transparent'; | |
switch (crypt_multi_font_size) { | |
case 'small': | |
crypt_multi_font_size = "90%"; | |
break; | |
case 'medium': | |
crypt_multi_font_size = "100%"; | |
break; | |
case 'large': | |
crypt_multi_font_size = "150%"; | |
break; | |
} | |
crypt_multi_style = 'background: ' + crypt_multi_background_color + | |
'; border: ' + crypt_multi_border_width + 'px solid ' + crypt_multi_border_color + ';' + | |
'font-family: ' + crypt_multi_font_family +'; font-size: ' + crypt_multi_font_size + | |
'; color: ' + crypt_multi_font_color + ';'; | |
if (crypt_multi_border_corners == "square") { | |
crypt_multi_style += "-webkit-border-radius: 0 !important; -moz-border-radius: 0 !important; border-radius: 0 !important;"; | |
} | |
document.write('\ | |
<div class="cryptonatorwidget" style="border-radius:4px;' + crypt_multi_style + '">\ | |
'); | |
for (var i = 0; i < crypt_multi_num_cur; ++i) { | |
n1 = eval("crypt_base_cur_" + i); | |
n2 = eval("crypt_target_cur_" + i); | |
//ADDED BY MESHAL: | |
var cur = '<font style="color:#FFFFFF;font-weight:heavy;">☒</font>'; | |
if (n1 == eval("crypt_base_cur_" + 0)) { | |
cur = '<font style="color:#FFFFFF;font-weight:heavy;">₿</font>'; | |
} | |
else if (n1 == eval("crypt_base_cur_" + 1)) { | |
cur = '<font style="color:#FFFFFF;font-weight:heavy;">Ł</font>'; | |
//𝘓 | |
} | |
getPar = eval('(' + httpGet("https://api.cryptonator.com/api/ticker/" + | |
n1.toLowerCase().match(/.*?\(([0-9a-z]+)\)/i)[1] + "-" + n2.toLowerCase().match(/.*?\(([0-9a-z]+)\)/i)[1]) + ')'); | |
if (getPar.success != false) { | |
if (getPar.ticker.price > 1) | |
price = Math.round(getPar.ticker.price * 100) / 100; | |
else | |
price = getPar.ticker.price; | |
var text_style = '<font style="color:#CF3A24;font-weight:heavy;"><b>▾</b></font>'; | |
if (getPar.ticker.change >= 0) { | |
text_style = '<font style="color:#26C281;font-weight:heavy;"><b>▴</b></font>'; | |
} | |
var price_colored = '<font style="color:#E3E3E3;">' + price + '</font>'; | |
document.write('<div ' + ';padding:10px;">\ | |
<font style="font-size:110%;">' + '</font>\ | |
<b>' + cur + ' ' + ' ' + price_colored + '$' + '\ | |
' + text_style + '</b> ' + '\ | |
'); | |
// + n2.match(/.*?\(([0-9a-z]+)\)/i)[1] | |
document.write('</div>'); | |
} | |
else { | |
document.write('<div style="border-bottom: 1px solid ' + crypt_multi_border_color + ';padding:10px;">No price available</div>'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment