-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcoinscript.js
More file actions
113 lines (75 loc) · 2.37 KB
/
coinscript.js
File metadata and controls
113 lines (75 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const fs = require('fs');
const options = {
headers: {
'x-access-token': 'coinrankingff642de6922ea15f6e86ee101fed8be6fc77756262b8eec2',
},
};
const apiUrl = 'https://api.coinranking.com/v2/coins'
setInterval(() => {
async function fetchData() {
const non_json = await fetch(apiUrl, options)
const json = await non_json.json()
const apiData = json.data
const coinData = apiData.coins
// console.log(coinData)
var Content = document.getElementById('content')
Content.innerHTML=''
coinData.forEach(user => {
var marketcap = numberWithCommas(user.marketCap)
var price = numberWithCommas(user.price)
var logo = user.iconUrl
var name = user.name
var symbol = user.symbol
var rank = user.rank
var color = user.color
const trow = document.createElement("tr")
trow.classList.add("box")
trow.innerHTML = `
<td>${rank}</td>
<td><img src="${logo}" alt="logo" width="30vw"></td>
<td class="coinName">${name} <span id="symbol">${symbol}</span></td>
<td>$ ${marketcap}</td>
<td>$ ${price}</td>
`
trow.color = color
trow.addEventListener("click", () => {
window.location.href = `${name}.html`
// return {name: user.name, symbol: user.symbol, element: trow}
})
Content.appendChild(trow);
// function searcherFunc(){
// searcher=coinData.map(element =>{
// // var naam = element.name
// // var symbo = element.symbol
// return {name: element.name, symbol: element.symbol }
// })
// }
// searcherFunc()
});
}
fetchData()
}, 2000);\
// Array of "pages" to create
const pageNames = ['Page1', 'Page2', 'Page3'];
pageNames.forEach(name => {
// Create HTML content for each page
const content = `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${name}</title>
</head>
<body>
<h1>Welcome to ${name}</h1>
<p>This is content for ${name}.</p>
</body>
</html>
`;
// Write the HTML content to a new file
fs.writeFile(`${name}.html`, content, (err) => {
if (err) throw err;
console.log(`${name}.html created successfully!`);
});
});