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) {
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const supportedLangs = ['de', 'en', 'it', 'fr'];
|
||||
|
||||
// Globale Config aus PHP-Partial (app_config.php)
|
||||
const cfg = window.usbConfig || {};
|
||||
const cfgLang = (cfg.lang || '').toLowerCase();
|
||||
|
||||
function resolveCurrentLang() {
|
||||
const url = new URL(window.location.href);
|
||||
const urlLang = (url.searchParams.get('lang') || '').toLowerCase();
|
||||
const docLang = (document.documentElement.getAttribute('lang') || '').toLowerCase();
|
||||
const globalLang = (window.currentLang || '').toLowerCase();
|
||||
const url = new URL(window.location.href);
|
||||
const urlLang = (url.searchParams.get('lang') || '').toLowerCase();
|
||||
const docLang = (document.documentElement.getAttribute('lang') || '').toLowerCase();
|
||||
|
||||
if (supportedLangs.includes(urlLang)) return urlLang;
|
||||
if (supportedLangs.includes(globalLang)) return globalLang;
|
||||
if (supportedLangs.includes(cfgLang)) return cfgLang;
|
||||
if (supportedLangs.includes(docLang)) return docLang;
|
||||
return 'de';
|
||||
}
|
||||
@@ -27,7 +30,6 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
const currentQuery = window.location.search || '';
|
||||
const redirect = currentPath + currentQuery;
|
||||
|
||||
// Sprache aus URL / globalem State ableiten
|
||||
const lang = resolveCurrentLang();
|
||||
|
||||
// Wenn wir bereits auf /login sind → nur zum #auth scrollen
|
||||
|
||||
Reference in New Issue
Block a user