Skip to content

Commit c55e264

Browse files
committed
added central footer js file
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
1 parent 336192b commit c55e264

57 files changed

Lines changed: 749 additions & 12839 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

FOOTER_IMPLEMENTATION.md

Lines changed: 67 additions & 0 deletions

company/about-us.html

Lines changed: 5 additions & 242 deletions
Large diffs are not rendered by default.

company/career.html

Lines changed: 5 additions & 241 deletions
Large diffs are not rendered by default.

company/get-in-touch.html

Lines changed: 5 additions & 241 deletions
Large diffs are not rendered by default.

company/media.html

Lines changed: 5 additions & 240 deletions
Large diffs are not rendered by default.

company/news.html

Lines changed: 5 additions & 247 deletions
Large diffs are not rendered by default.

company/overview.html

Lines changed: 5 additions & 240 deletions
Large diffs are not rendered by default.

convert_footer_to_js.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
import json
3+
4+
# Read the footer template
5+
with open('footer-template.html', 'r', encoding='utf-8') as f:
6+
footer_html = f.read()
7+
8+
# Escape the HTML for JavaScript
9+
footer_escaped = json.dumps(footer_html)
10+
11+
# Create the new JavaScript file
12+
js_content = f'''/**
13+
* Load footer template into all pages
14+
* Footer content is embedded directly to avoid CORS issues with file:// protocol
15+
*/
16+
(function() {{
17+
'use strict';
18+
19+
const footerHTML = {footer_escaped};
20+
21+
function loadFooter() {{
22+
const footerPlaceholder = document.getElementById('footer-placeholder');
23+
if (!footerPlaceholder) {{
24+
console.warn('Footer placeholder not found');
25+
return;
26+
}}
27+
28+
// Insert the footer HTML
29+
footerPlaceholder.innerHTML = footerHTML;
30+
31+
// Re-initialize any scripts that were in the footer
32+
const scripts = footerPlaceholder.querySelectorAll('script');
33+
scripts.forEach(oldScript => {{
34+
const newScript = document.createElement('script');
35+
Array.from(oldScript.attributes).forEach(attr => {{
36+
newScript.setAttribute(attr.name, attr.value);
37+
}});
38+
newScript.textContent = oldScript.textContent;
39+
oldScript.parentNode.replaceChild(newScript, oldScript);
40+
}});
41+
42+
// Trigger a custom event when footer is loaded
43+
document.dispatchEvent(new CustomEvent('footerLoaded'));
44+
}}
45+
46+
// Load footer when DOM is ready
47+
if (document.readyState === 'loading') {{
48+
document.addEventListener('DOMContentLoaded', loadFooter);
49+
}} else {{
50+
loadFooter();
51+
}}
52+
}})();
53+
'''
54+
55+
# Write the new JavaScript file
56+
with open('scripts/load-footer.js', 'w', encoding='utf-8') as f:
57+
f.write(js_content)
58+
59+
print('✓ Created scripts/load-footer.js with embedded footer content')
60+
print(f' Footer size: {len(footer_html)} characters')
61+
print(f' JavaScript size: {len(js_content)} characters')

de.html

Lines changed: 5 additions & 247 deletions
Large diffs are not rendered by default.

de/company/about-us.html

Lines changed: 5 additions & 242 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)