Я уже кое-что написал но он не обновляет содержимое веб-сайта периодически, как должно.
Можете ли вы мне помочь?
Вот как страница выбирает и читает файл:
Код: Выделить всё
document.getElementById('file-input').addEventListener('change', function (event) {
const file = event.target.files[0];
if (file) {
lastModified = new Date(file.lastModified);
const reader = new FileReader();
reader.onload = function (e) {
fileData = new Uint8Array(e.target.result);
updateTable();
};
reader.readAsArrayBuffer(file);
}
});
function updateTable() {
if (fileData) {
const workbook = XLSX.read(fileData, { type: 'array' });
const firstSheetName = workbook.SheetNames[0];
const worksheet = workbook.Sheets[firstSheetName];
const jsonData = XLSX.utils.sheet_to_json(worksheet, { header: 1 });
const tableBody = document.getElementById('excel-data');
tableBody.innerHTML = '';
jsonData.forEach((row, rowIndex) => {
if (rowIndex === 0) return; // Skip header row
const tr = document.createElement('tr');
row.forEach(cell => {
const td = document.createElement('td');
td.className = 'py-2 px-4 border-b border-gray-200';
td.textContent = cell;
tr.appendChild(td);
});
tableBody.appendChild(tr);
});
document.getElementById('last-modified')
.textContent = `Data ultima modifica del file Excel: ${lastModified.toLocaleString()}`;
}
}
Код: Выделить всё
setInterval(() => {
if (fileData) {
updateTable();
}
}, 300000);
Код: Выделить всё
new MutationObserver(async r => {
let e = !1;
if (!cf) {
cf = new MutationObserver(async () => await pf(!0));
for (let t of document.querySelectorAll(`style[type="${uf}"]`))
Pv(t)
}
for (let t of r)
for (let i of t.addedNodes)
i.nodeType === 1 && i.tagName === "STYLE" && i.getAttribute("type") === uf && (Pv(i),
e = !0);
await pf(e)
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... updated-pe