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 * Dynamically injects a common header (topbar) and language-aware footer
* into all 6 legal pages to eliminate HTML duplication. * into all 6 legal pages to eliminate HTML duplication.
* *
* Footer content depends on page language (EN vs RO). * Reuses language detection and switching utilities from shared modules.
* Language links use event delegation so they work on injected elements. * Uses event delegation for language links so they work on injected elements.
*/ */
(function(){ (function(){
"use strict"; "use strict";
// Local constant for storing page language preference in localStorage
var LANG_KEY = "legalLang"; 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. * Build URL to alternate language page.
* Supports both -en.html and -ro.html naming patterns. * Supports both -en.html and -ro.html naming patterns.
@@ -57,6 +43,7 @@
/** /**
* Inject topbar with logo and language switcher. * Inject topbar with logo and language switcher.
* Uses pageLang() to determine current page language and set active state.
*/ */
function injectTopbar(){ function injectTopbar(){
var base = basePage(); var base = basePage();
@@ -79,13 +66,11 @@
} }
/** /**
* Inject language-aware footer. * Inject language-aware footer with copyright and legal links.
* EN: "©2026 myAi. All rights reserved." * Footer text and links vary by current page language (EN vs RO).
* RO: "©2026 myAi. Toate drepturile sunt rezervate."
*/ */
function injectFooter(){ function injectFooter(){
var lang = pageLang(); var lang = pageLang();
var base = basePage();
var copyrightText = lang === 'ro' ? '©2026 myAi. Toate drepturile sunt rezervate.' : '©2026 myAi. All rights reserved.'; var copyrightText = lang === 'ro' ? '©2026 myAi. Toate drepturile sunt rezervate.' : '©2026 myAi. All rights reserved.';
var linksHtml = ''; var linksHtml = '';
if(lang === 'ro'){ if(lang === 'ro'){
@@ -105,7 +90,7 @@
} }
/** /**
* Initialize language persistence and topbar injection. * Initialize language persistence and inject topbar/footer.
*/ */
function init(){ function init(){
localStorage.setItem(LANG_KEY, pageLang()); localStorage.setItem(LANG_KEY, pageLang());
@@ -115,7 +100,8 @@
/** /**
* Handle language link clicks with event delegation. * 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){ document.addEventListener('click', function(e){
var link = e.target.closest('.lang-link'); var link = e.target.closest('.lang-link');
@@ -125,7 +111,11 @@
window.location.href = targetPage(window.location.pathname, link.getAttribute('data-lang')); 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'){ if(document.readyState === 'loading'){
document.addEventListener('DOMContentLoaded', init); document.addEventListener('DOMContentLoaded', init);
} else { } else {