Bitcoin ticker fontawesome

0 votes

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!!

Apr 6, 2022 in Blockchain by Rahul
• 9,680 points
734 views

1 answer to this question.

0 votes

Font Awesome arrow up is displayed like this:

<i class="fa fa-arrow-up"></i>

I would store all those HTML snippets into their own variables.

upArrow = '<i class="fa fa-arrow-up"></i>'

And then inject them when you inject the HTML in the startRefresh function like this:

$("#buy").html(upArrow + data.PLN.buy);

answered Apr 12, 2022 by Soham
• 9,710 points

Related Questions In Blockchain

0 votes
1 answer

PHP. Bitcoin to Ukrainian Hrivna price ticker

nstead of dividing the values - i ...READ MORE

answered Sep 11, 2018 in Blockchain by slayer
• 29,370 points
941 views
0 votes
1 answer

PHP. Bitcoin to Ukrainian Hrivna price ticker

I would suggest, that instead of dividing ...READ MORE

answered Apr 7, 2022 in Blockchain by Aditya
• 7,680 points
624 views
+1 vote
1 answer
0 votes
1 answer

How do I query Blockchain bitcoin locally?

You could use json RPC provided by ...READ MORE

answered Apr 19, 2018 in Blockchain by Christine
• 15,790 points
1,672 views
+1 vote
1 answer

Protocols used in a distributed/dlt system for the nodes to establish communication

yes all are over TCP/IP connections secured ...READ MORE

answered Aug 6, 2018 in Blockchain by aryya
• 7,460 points
1,458 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,941 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,466 views
0 votes
1 answer

SHA256 Hash doesn't match the one listed on Bitcoin Wiki

The problem occurring here is that you ...READ MORE

answered Feb 28, 2022 in Blockchain by Soham
• 9,710 points
783 views
0 votes
1 answer

Bitcoin Core on external SSD in OS X

 In order to do so, assuming you ...READ MORE

answered Feb 28, 2022 in Blockchain by Soham
• 9,710 points
1,435 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP