-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestfiles.html
More file actions
61 lines (56 loc) · 1.63 KB
/
testfiles.html
File metadata and controls
61 lines (56 loc) · 1.63 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
<!DOCTYPE html>
<html>
<head>
<title>Live Data Display</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.box {
width: calc(25% - 20px);
margin: 10px;
padding: 20px;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div id="dataContainer"></div>
<script>
function fetchData() {
// Mock API endpoint
let url = 'https://jsonplaceholder.typicode.com/posts';
fetch(url)
.then(response => response.json())
.then(data => {
updateData(data);
})
.catch(error => console.error('Error:', error));
}
function updateData(data) {
let dataContainer = document.getElementById("dataContainer");
dataContainer.innerHTML = "";
for (let i = 0; i < Math.min(data.length, 16); i++) {
let box = document.createElement("div");
box.className = "box";
box.textContent = data[i].title;
dataContainer.appendChild(box);
}
}
// Fetch data and update every second
setInterval(fetchData, 1000);
// Initial fetch
fetchData();
</script>
</body>
</html>