up
This commit is contained in:
@@ -1,22 +1,23 @@
|
||||
// /public/assets/js/fakecheck.js
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const baseUrl = window.fakecheckBaseUrl || "";
|
||||
const locale = window.fakecheckLocale || "en";
|
||||
// Zentrale Config aus PHP (app_config.php o.ä.)
|
||||
const cfg = window.usbConfig || {};
|
||||
const baseUrl = cfg.baseUrl || "";
|
||||
const locale = (cfg.lang || "en").toLowerCase();
|
||||
|
||||
// Neu: API-Basis-URL (prod/staging) – über Config oder Fallback anhand Host
|
||||
const apiBaseUrl = window.fakecheckApiBaseUrl || detectApiBaseUrl();
|
||||
|
||||
function detectApiBaseUrl() {
|
||||
// Fallback, falls in usbConfig nichts hinterlegt ist
|
||||
const host = window.location.hostname || "";
|
||||
// einfache Heuristik: staging-Domain → staging-API
|
||||
if (host === "staging.usbcheck.it" || host.endsWith(".staging.usbcheck.it")) {
|
||||
return "https://api.staging.usbcheck.it";
|
||||
}
|
||||
// default: production
|
||||
return "https://api.usbcheck.it";
|
||||
}
|
||||
|
||||
const apiBaseUrl = cfg.apiBaseUrl || detectApiBaseUrl();
|
||||
|
||||
const root = document.getElementById("fc-root");
|
||||
if (!root) {
|
||||
// Auf anderen Seiten eingebunden? Dann einfach nichts tun.
|
||||
@@ -51,9 +52,8 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
const btnCancel = $("#fc-btn-cancel-tests");
|
||||
const modeTiles = $$("#fc-mode-grid .fc-mode-tile");
|
||||
|
||||
// Falls du einen Login-Indikator hast, kannst du ihn global setzen,
|
||||
// z. B. window.fakecheckIsLoggedIn = true/false
|
||||
if (window.fakecheckIsLoggedIn) {
|
||||
// Login-Indikator aus usbConfig
|
||||
if (cfg.isLoggedIn && saveHint) {
|
||||
saveHint.style.display = "block";
|
||||
}
|
||||
|
||||
@@ -661,7 +661,6 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
// --- Backend-Speicherung ------------------------------------------------
|
||||
|
||||
async function saveReportToBackend(report) {
|
||||
// Absoluter Pfad – dein Script liegt oberhalb des public-Roots:
|
||||
const url = "/api/result/browser-quick-test.php";
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
@@ -674,7 +673,6 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
// 401 => nicht eingeloggt; 500 => Fehler etc.
|
||||
const msg = "HTTP " + response.status;
|
||||
logLine("Backend: Konnte Ergebnis nicht speichern (" + msg + ").", "warn");
|
||||
if (response.status >= 500 && saveError) {
|
||||
|
||||
Reference in New Issue
Block a user