Staging to Production #51

Merged
claude merged 165 commits from main into production 2026-06-08 18:28:46 +00:00
Showing only changes of commit d0bba19a17 - Show all commits
+14 -24
View File
@@ -4,29 +4,15 @@
* Dynamically injects a common header (topbar) and language-aware footer
* into all 6 legal pages to eliminate HTML duplication.
*
* Footer content depends on page language (EN vs RO).
* Language links use event delegation so they work on injected elements.
* Reuses language detection and switching utilities from shared modules.
* Uses event delegation for language links so they work on injected elements.
*/
(function(){
"use strict";
// Local constant for storing page language preference in localStorage
var LANG_KEY = "legalLang";
/**
* Detect browser language preference (EN or RO).
*/
function browserLang(){
var lang = (navigator.language || navigator.userLanguage || 'en').toLowerCase();
return lang.indexOf('ro') === 0 ? 'ro' : 'en';
}
/**
* Get stored language preference, fall back to browser detection.
*/
function getLang(){
return localStorage.getItem(LANG_KEY) || browserLang();
}
/**
* Build URL to alternate language page.
* Supports both -en.html and -ro.html naming patterns.
@@ -57,6 +43,7 @@
/**
* Inject topbar with logo and language switcher.
* Uses pageLang() to determine current page language and set active state.
*/
function injectTopbar(){
var base = basePage();
@@ -79,13 +66,11 @@
}
/**
* Inject language-aware footer.
* EN: "©2026 myAi. All rights reserved."
* RO: "©2026 myAi. Toate drepturile sunt rezervate."
* Inject language-aware footer with copyright and legal links.
* Footer text and links vary by current page language (EN vs RO).
*/
function injectFooter(){
var lang = pageLang();
var base = basePage();
var copyrightText = lang === 'ro' ? '©2026 myAi. Toate drepturile sunt rezervate.' : '©2026 myAi. All rights reserved.';
var linksHtml = '';
if(lang === 'ro'){
@@ -105,7 +90,7 @@
}
/**
* Initialize language persistence and topbar injection.
* Initialize language persistence and inject topbar/footer.
*/
function init(){
localStorage.setItem(LANG_KEY, pageLang());
@@ -115,7 +100,8 @@
/**
* Handle language link clicks with event delegation.
* Works on both static and injected links.
* Works on both static and dynamically injected language links.
* Updates localStorage and navigates to the target language page.
*/
document.addEventListener('click', function(e){
var link = e.target.closest('.lang-link');
@@ -125,7 +111,11 @@
window.location.href = targetPage(window.location.pathname, link.getAttribute('data-lang'));
});
// Run on page load
/* ============================================================
PAGE INITIALIZATION
============================================================ */
// Initialize topbar and footer injection on DOM ready
if(document.readyState === 'loading'){
document.addEventListener('DOMContentLoaded', init);
} else {