83 lines
2.9 KiB
JavaScript
83 lines
2.9 KiB
JavaScript
// utils/loadWindowVariables.js
|
|
|
|
export async function loadWindowVariables(apiUrl) {
|
|
return new Promise((resolve, reject) => {
|
|
// Funktion zum Laden eines Skripts und Setzen der `window`-Variablen
|
|
const loadScript = (src) => {
|
|
return new Promise((resolve, reject) => {
|
|
const script = document.createElement("script");
|
|
script.src = `${apiUrl}/CPL?${src}`;
|
|
script.async = true;
|
|
script.onload = () => {
|
|
resolve();
|
|
};
|
|
script.onerror = (error) => {
|
|
reject(error);
|
|
};
|
|
document.head.appendChild(script);
|
|
});
|
|
};
|
|
|
|
// Lade das Skript, das alle Variablen enthält
|
|
loadScript("last20Messages.acp")
|
|
.then(() => {
|
|
// Prüfen, ob alle Variablen verfügbar sind und sie in die Konsole ausgeben
|
|
if (window.last20Messages) {
|
|
console.log("Systemvariablen geladen:", {
|
|
// last20Messages.acp
|
|
last20Messages: window.last20Messages,
|
|
// System.acp Variablen
|
|
deviceName: window.deviceName,
|
|
mac1: window.mac1,
|
|
mac2: window.mac2,
|
|
ip: window.ip,
|
|
subnet: window.subnet,
|
|
gateway: window.gateway,
|
|
datetime: window.datetime,
|
|
// de.acp Variablen
|
|
de: window.de,
|
|
counter: window.counter,
|
|
flutter: window.flutter,
|
|
// kueConfig.acp Variablen
|
|
kueOnline: window.kueOnline,
|
|
kueID: window.kueID,
|
|
//kueIso: window.kueIso, von SERVICE/kueConfig.acp also von window.kueIso
|
|
// kuedetail.acp Variablen
|
|
kueValid: window.kueValid,
|
|
kueAlarm1: window.kueAlarm1,
|
|
kueAlarm2: window.kueAlarm2,
|
|
kueRes: window.kueRes,
|
|
kueCableBreak: window.kueCableBreak,
|
|
kueGroundFault: window.kueGroundFault,
|
|
kueLimit1: window.kueLimit1,
|
|
kueLimit2Low: window.kueLimit2Low,
|
|
kueLimit2High: window.kueLimit2High,
|
|
kueDelay1: window.kueDelay1,
|
|
kueLoopInterval: window.kueLoopInterval,
|
|
kueVersion: window.kueVersion,
|
|
tdrAtten: window.tdrAtten,
|
|
tdrPulse: window.tdrPulse,
|
|
tdrSpeed: window.tdrSpeed,
|
|
tdrAmp: window.tdrAmp,
|
|
tdrTrigger: window.tdrTrigger,
|
|
tdrLocation: window.tdrLocation,
|
|
tdrActive: window.tdrActive,
|
|
kueOverflow: window.kueOverflow,
|
|
kue100V: window.kue100V,
|
|
kueResidence: window.kueResidence,
|
|
tdrLastMeasurement: window.tdrLastMeasurement,
|
|
kueBooting: window.kueBooting,
|
|
appVersion: window.appVersion,
|
|
});
|
|
|
|
resolve();
|
|
} else {
|
|
reject(new Error("Konnte last20Messages nicht finden."));
|
|
}
|
|
})
|
|
.catch((error) => {
|
|
reject(error);
|
|
});
|
|
});
|
|
}
|