My task was to write a function that gets Bitcoin trades from JSON link, change interval with buttons, add a font awesome arrow up/down/line depending on if the rate went up/down/no change and display it on the website.
I have everything except font awesome...
My HTML code is:
<h3>Bitcoin to PLN</h3> <h4>Buy</h4> <div id="buy"><p></p></div> <h4>Sell</h4> <div id="sell"><p></p></div> <h4>Refresh in:</h4> <form name="timerBtn"> <input type="button" class="button" id="btn5" value="5 s"> <input type="button" class="button" id="btn10" value="10 s"> <input type="button" class="button" id="btn30" value="30 s"> <input type="button" class="button" id="btn60" value="60 s"> </form> <p id="timer">Refreshing in 5 sekund</p>
And the JS code:
$("form").click( function(getTimer) { if (getTimer.target.className === 'button') { $("p#timer").empty(); var timer = $("p#timer").append( "Refresh in " + getTimer.target.value); } return timer }); function startRefresh() { $.getJSON("https://blockchain.info/pl/ticker", function (data) { $("#buy").html(data.PLN.buy); $("#sell").html(data.PLN.sell); console.log ("reupload"); }); } setTimer = setInterval(startRefresh, 5000); $("input#btn5").click( function() { clearInterval(setTimer); setTimer = setInterval(startRefresh, 5000); }); $("input#btn10").click( function() { clearInterval(setTimer); setTimer = setInterval(startRefresh, 10000); }); $("input#btn30").click( function() { clearInterval(setTimer); setTimer = setInterval(startRefresh, 30000); }); $("input#btn60").click( function() { clearInterval(setTimer); setTimer = setInterval(startRefresh, 60000) });
I don't know how to deal with the font awesome part
Thanks in advance for any tips!!