forked from vaibhavtayal6/Inventory_management
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
82 lines (75 loc) · 2.22 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Dynamic CSV Table</title>
<style>
body{
background-color: black;
}
*{
background-color: black;
border: 1px solid rgba(255, 255, 255, 0.429);
color: white;
}
table {
border-collapse: collapse;
width: 100%;
}
th, td {
border: 1px solid #dddddd7d;
text-align: left;
padding: 8px;
}
th {
background-color: #545353;
color: black;
}
</style>
</head>
<body>
<div style="height: 200px; background-repeat: no-repeat; background-position: center;background-size: contain; width: 100%; display: flex; align-items: center; justify-content: center; background-image: url(uasnmims_LITT.jpeg);"></div>
<table id="csvTable">
<!-- Table data will be populated here -->
</table>
<script>
function fetchCSV() {
fetch('local_data.csv')
.then(response => response.text())
.then(data => {
const rows = data.split('\n');
const table = document.getElementById('csvTable');
// Clear previous table data
table.innerHTML = '';
// Create table headers
const headerRow = document.createElement('tr');
rows[0].split(',').forEach(cell => {
const th = document.createElement('th');
th.textContent = cell;
headerRow.appendChild(th);
});
table.appendChild(headerRow);
// Create table rows
for (let i = 1; i < rows.length; i++) {
const rowData = rows[i].split(',');
if (rowData.length === 1 && rowData[0] === '') continue; // Skip empty rows
const row = document.createElement('tr');
rowData.forEach(cellData => {
const td = document.createElement('td');
td.textContent = cellData;
row.appendChild(td);
});
table.appendChild(row);
}
})
.catch(error => {
console.error('Error fetching the CSV file:', error);
});
}
// Fetch CSV initially
fetchCSV();
// Fetch CSV periodically (e.g., every 5 seconds)
setInterval(fetchCSV, 5000);
</script>
</body>
</html>