Обратите внимание, что большинство этих переменных используются неправильно, поэтому я спрашиваю, извините, если он не отформатирован правильно, он находится внутри моего кода, но по какой-то причине, если я вставлю его, это не так
Gerät
Status
Info
const Data_file = "api/received.json";
const refreshInterval = 999;
let firstLoad = true;
async function loadData() {
try {
const response = await fetch(`${Data_file}?_=${Date.now()}`);
const devices = (await (await fetch(devicesFile + "?_=" + Date.now())).json()).JsonDevices;
devices.forEach(device => {
const row = document.createElement("div");
row.className = "row align-items-center border-bottom py-2";
// Spalte 1: Gerätenummer
const colDevice = document.createElement("div");
colDevice.className = "col-1";
colDevice.textContent = device;
//Icon zum kopieren der Seriennummer und Softwareversion
const colIcon = document.createElement("div");
colDevice.className = "col-1";
colDevice.textContent = device;
//Status frei/besetzt kommt später!!!
const colStatus = document.createElement("div");
colDevice.className = "col-2";
//colDevice.textContent = device;
//Download aktiv ja oder nein? Mit Icons arbeiten
const colDownloadActive = document.createElement("div");
colDevice.className = "col-2";
colDevice.textContent = device;
if (downloadActive = true) {
colStatus.innerHTML =
'

';
'< span class="text-danger" >Download aktiv ';
} else {
colStatus.innerHTML =
'

';
'< span class="text-danger" >keine Downloads ';
}
//Wer lädt herunter über Token
const colDownloadFrom = document.createElement("div");
colDevice.className = "col-3 ";
colDevice.textContent = device;
//Wie Lange geht der download noch
const colDownloadDuration = document.createElement("div");
colDevice.className = "col-2";
colDevice.textContent = device;
//Anzahl der Downloads
const colNumberofDownloads = document.createElement("div");
colDevice.className = "col-1";
colDevice.textContent = device;
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const data = await response.json();
document.getElementById("output").textContent = JSON.stringify(data, null, 2);
firstLoad = false;
} catch (error) {
console.error(error);
if (firstLoad) {
document.getElementById("output").textContent = "Error" + error;
}
}
}
setInterval(loadData, refreshInterval);
loadData();
const devices = api;
Это мой php-файл:
Подробнее здесь: https://stackoverflow.com/questions/798 ... ys-in-html
Мобильная версия