mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-27 05:55:15 +02:00
- Improved OIDC variable definitions (12_oidc.yml) - Added account/security/profile URLs - Restructured web-app-desktop tasks and JS handling - Introduced oidc.js and iframe.js with runtime loader - Fixed nginx.conf, LDAP, and healthcheck templates spacing - Improved Lua injection for CSP and snippets - Fixed typos (WordPress, receive, etc.) - Added silent-check-sso nginx location Conversation: https://chatgpt.com/share/68ae0060-4fac-800f-9f02-22592a4087d3
47 lines
1.7 KiB
Django/Jinja
47 lines
1.7 KiB
Django/Jinja
// ===== Runtime loader for external JS files (no Jinja includes) =====
|
|
(function () {
|
|
// 1) Values injected by Ansible/Jinja
|
|
// Base URL where your files were deployed (e.g. CDN), made safe w/o trailing slash
|
|
const BASE_URL = ("{{ DESKTOP_JS_BASE_URL }}").replace(/\/+$/, "");
|
|
// List of files to load, in order
|
|
const FILES = [
|
|
{% for f in DESKTOP_JS_FILES -%}
|
|
"{{ f }}"{% if not loop.last %},{% endif %}
|
|
{%- endfor %}
|
|
];
|
|
// Cache buster (highest mtime computed during deploy)
|
|
const VERSION = "{{ javascript_file_version }}";
|
|
|
|
// 2) Helper to load a <script> with proper query param
|
|
function loadScriptSequential(url) {
|
|
return new Promise((resolve, reject) => {
|
|
const s = document.createElement("script");
|
|
// Append ?v=... (or &v=... if there are already params)
|
|
s.src = url + (url.includes("?") ? "&" : "?") + "v=" + encodeURIComponent(VERSION);
|
|
// Keep execution order: do not set async/defer
|
|
s.onload = () => resolve();
|
|
s.onerror = () => reject(new Error("Failed to load " + url));
|
|
document.head.appendChild(s);
|
|
});
|
|
}
|
|
|
|
// 3) Load all files in order
|
|
async function loadAll() {
|
|
for (const name of FILES) {
|
|
const fullUrl = BASE_URL + "/" + name.replace(/^\/+/, "");
|
|
await loadScriptSequential(fullUrl);
|
|
}
|
|
// Optional: hook after everything is ready
|
|
if (typeof window.onDesktopJsLoaded === "function") {
|
|
try { window.onDesktopJsLoaded(); } catch {}
|
|
}
|
|
}
|
|
|
|
// 4) Start after DOM is ready (safe point to inject <script> tags)
|
|
if (document.readyState === "loading") {
|
|
document.addEventListener("DOMContentLoaded", loadAll);
|
|
} else {
|
|
loadAll();
|
|
}
|
|
})();
|