Skip to content

Commit

Permalink
scroll ticker js json
Browse files Browse the repository at this point in the history
  • Loading branch information
totaro committed Apr 17, 2024
1 parent b9f0789 commit 666a789
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
16 changes: 16 additions & 0 deletions js/stock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import stocks from "/js/stocks.json" assert { type: "json" };

let stock = "<ul>";
stocks.map(
(item) =>
(stock += `<li class="${item.label}"><span class="company">${item.company}</span><span class="price">${item.price}</span><span class="change">${item.change}</span></li>`)
);
stock += "</ul><ul aria-hidden='true'>";
stocks.map(
(item) =>
(stock += `<li class="${item.label}"><span class="company">${item.company}</span><span class="price">${item.price}</span><span class="change">${item.change}</span></li>`)
);

stock += "</ul>";

document.getElementById("stockdata").innerHTML = stock;
62 changes: 62 additions & 0 deletions js/stocks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[
{
"id": 0,
"label": "minus",
"company": "AAPL",
"price": "$169.38",
"change": "-3.31 (-1.917%)"
},
{
"id": 1,
"label": "plus",
"company": "MSFT",
"price": "$414.58",
"change": "+0.94 (+0.227%)"
},

{
"id": 2,
"label": "plus",
"company": "NVDA",
"price": "$874.15",
"change": "+14.14 (+1.644%)"
},
{
"id": 3,
"label": "minus",
"company": "GOOG",
"price": "$156.00",
"change": "-0.33 (-0.211%)"
},
{
"id": 4,
"label": "minus",
"company": "AMZN",
"price": "$183.32",
"change": "-0.30 (-0.163%)"
},{
"id": 5,
"label": "plus",
"company": "AVGO",
"price": "$1,329.06",
"change": "+18.37 (+1.402%)"
},{
"id": 6,
"label": "minus",
"company": "META",
"price": "$499.76",
"change": "-0.47 (-0.094%)"
},{
"id": 7,
"label": "plus",
"company": "MA",
"price": "$459.82",
"change": "+0.03 (+0.007%)"
},{
"id": 8,
"label": "minus",
"company": "TSLA",
"price": "$157.11",
"change": "-4.37 (-2.706%)"
}
]

0 comments on commit 666a789

Please sign in to comment.