Cryptocurrency price tracker with sleek Bitcoin symbol and FontAwesome icons

My assignment involved creating a function that retrieves Bitcoin trades from a JSON URL, allows users to change the interval with buttons, uses fontawesome arrows to indicate rate changes (up/down/no change), and displays the data on a website.

Everything is working great except for the fontawesome...

Here is the HTML code:

<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 seconds</p>

And here is the JS:

$("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 need help incorporating the fontawesome feature into my project.

Thank you in advance for any assistance

Answer №1

When displaying the Font Awesome arrow up, it is coded as follows:

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

To organize the HTML snippets for the arrows (up, down, and no change), I would save them in separate variables.

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

Then, when injecting the HTML in the startRefresh function, I would include them like this:

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Transferring an object from the factory to the controller

I'm currently working on setting up a factory that sends an ajax request to an API and then returns a data object. Here is the code snippet I have written: app.factory('Test', function($http, $q) { var data = {response:{}}; var getM ...

JavaScript can retrieve the default page name that is hidden within the browser's URL

When a URL is entered without a specific file name at the end, such as "www.google.com," the server typically serves a default file like "index.html" or "default.aspx." In this scenario, if the browser displays "www.google.com," I am looking to extract the ...

How to seamlessly integrate Redux into your React project using create-react-app?

Is it correct to pass a reducer as props when using a rootreducer? This is the content of my rootReducer.js file: import { combineReducers } from 'redux'; import simpleReducer from './simpleReducer'; import messageReducer from '. ...

Using JQuery to manipulate `this`, its children, its siblings, and more

Can anyone help me determine the most effective way to send data from a get request to a specific div? My challenge is to send it only to a div that is related to the one triggering the action. For example, when I click on the message_tab, I want to send t ...

Using AngularJS to dynamically populate a dropdown menu from a JSON object

I am a beginner to Angular and currently facing my first significant challenge. The JSON object below is the address data retrieved from a third-party API and added to $scope.AddressData in a controller: $scope.AddressData = [{ "Address1":"South Row", ...

Following a Node/Npm Update, Sails.js encounters difficulty locating the 'ini' module

While developing an application in Sails.js, I encountered an authentication issue while trying to create user accounts. Despite my efforts to debug the problem, updating Node and NPM only resulted in a different error. module.js:338 throw err; ...

The URL overwrites the Ajax transfer type

When making an ajax call using a generated URL from a paginator script, I encountered an issue. The URL was dynamically created as shown below: "http://192.168.1.23:8000/pricing/0/999/null/?page=9" A similar link is generated on the server: "https://xxx ...

What is the best way to achieve this in Node.js/Express using Redis? Essentially, it involves saving a callback value to a variable

Here is the data structure I have set up in redis. I am looking to retrieve all values from the list and their corresponding information from other sets. Data structure : lpush mylist test1 lpush mylist test2 lpush mylist test3 set test1 "test1 value1" ...

User interaction with a checkbox triggers a state change in Angular

Here is the code snippet I am working with, where clicking should set the checked value to false: @Component({ template: ` <input type="checkbox" [checked]="checked" (change)="onChange()"> ` }) export class AppC ...

Error in Angular Google Maps Component: Unable to access the 'nativeElement' property as it is undefined

I am currently working on creating an autofill input for AGM. Everything seems to be going smoothly, but I encountered an error when trying to integrate the component (app-agm-input) into my app.component.html: https://i.stack.imgur.com/mDtSA.png Here is ...

Using jQuery to incorporate a variable into JSON schema markup

For my current project, I am attempting to extract the meta description and incorporate it into JSON schema markup. However, I am facing difficulty in passing the variable properly into the JSON structure. My initial approach was as follows: <script&g ...

tsc and ts-node are disregarding the noImplicitAny setting

In my NodeJS project, I have @types/node, ts-node, and typescript installed as dev dependencies. In the tsconfig.json file, "noImplicitAny": true is set. There are three scripts in the package.json file: "start": "npm run build &am ...

How can we effectively reroute HTTP requests according to the information stored in a database?

When operating an express server, what is the appropriate method for redirecting incoming requests? In my application, I have two routes: POST and UPDATE. The POST route is responsible for creating a new item in the database, while the UPDATE route increa ...

Using axios to make a request from a server to itself

I'm facing an issue where I am attempting to send a request from the server to the same server using axios as a PUT method. Here is an example of what I have tried: await axios({ url: `http://localhost:4000${url}`, method: requestType, ...

Implement the geocomplete feature following an ajax event

When I click a button, it adds an input box for entering an address. To assist with auto-completion of the address, I'm using the geocomplete plugin. However, I've noticed that the geocomplete functionality only works on input boxes generated wit ...

Using Fetch API in NextJS requires pressing the Enter key twice for it to work properly

The functionality of this component should display JSON data in the console log after entering input into the search bar and hitting the enter key. However, there is a lag where the data doesn't show until the enter key is pressed a second time. Addit ...

Tips for identifying and handling a 400 bad request error in an HTTP response within an Angular 2 application

I attempted to handle the error 400 bad request in this manner: catch((error: any) => { if (error.status === 500) { return Observable.throw(new Error(error.status)); } else if (error.status === 400) { console.log( 'err ...

Ways to access and retrieve data from Vuex store values?

Combining vuex and vuejs 2 for the first time. I'm a beginner with vuex and I need to monitor changes in a store variable. Trying to implement the watch functionality within my vue component. This is my current code snippet: import Vue from ' ...

Retrieve the route.js directory using Node.js

My server.js file is located in the directory: /dir1. To start the server, I use the command node server.js. In the directory /dir1/app/, I have my file named routes.js. I am trying to find out the directory path of the server.js file. However, I am unc ...

Error code -4058 ENOENT indicates that the file or directory does not exist. This issue is usually caused when npm is unable to locate a specific file

Trying to start a react project on my D: drive while having node installed on the C: drive resulted in an error: D:\react> npm start npm ERR! code ENOENT npm ERR! syscall open npm ERR! path D:\react/package.json npm ERR! errno -4058 npm ERR! ...