Skip to content

Instantly share code, notes, and snippets.

@Frankenmint
Created July 16, 2016 09:23
Show Gist options
  • Save Frankenmint/a3ce3dab7eafa57db959236834c52dcc to your computer and use it in GitHub Desktop.
Save Frankenmint/a3ce3dab7eafa57db959236834c52dcc to your computer and use it in GitHub Desktop.
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script><div id="tickerBox"></div>
<script>
var tickerBox = document.getElementById('tickerBox');
var divTicker = document.createElement('div');
divTicker.setAttribute("id", "ticker");
tickerBox.appendChild(divTicker);
divTicker.style.fontSize="4rem";
divTicker.style.fontWeight="bold";
divTicker.style.letterSpacing="2px";
var checked = document.createElement('div');
checked.setAttribute("id", "checked");
tickerBox.appendChild(checked);
var dataLast;
function priceData (){
var ticker = document.getElementById('ticker');
var lastUpdated = document.getElementById('checked');
var datetime = "Last Updated: <br/>" + new Date().toLocaleTimeString();
//https://api.bitcoinaverage.com/ticker/global/USD/last
$.get(
"https://api.coinmarketcap.com/v1/ticker/steem/",
function(data) {
data = data[0].price_usd;
if (data > dataLast) {
divTicker.style.color = "green";
} else {
divTicker.style.color = "red";
}
ticker.innerHTML = "$" + data.toFixed(2)+" <span id='super'>USD</span>";
superscript = document.getElementById('super');
superscript.style.fontSize="xx-small";
superscript.style.verticalAlign="top";
superscript.style.letterSpacing="0px";
checked.innerHTML = datetime;
dataLast = data;
}
);
}
priceData();
setInterval(priceData, 5000);
checked.style.paddingLeft="10px";
checked.style.marginTop="-14px";
checked.style.color="black";
checked.style.textShadow="2px 2px 1px #4ba2f2";
checked.style.float="right";
ticker.style.textShadow="1px 2px 2px black";
ticker.style.paddingLeft="10px";
tickerBox.style.width="13rem";
tickerBox.style.height="10rem";
ticker.style.paddingTop="1rem";
ticker.style.paddingBottom=".5rem";
tickerBox.style.borderRadius="5px";
tickerBox.style.backgroundImage="url('https://puu.sh/q1VUF/d9e60eef32.png')";
tickerBox.style.backgroundSize="contain";
//tickerBox.style.backgroundPosition="40px 0px";
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment