Skip to content

Commit 468fabf

Browse files
authored
Merge pull request #5 from RiddleAndCode/eckelj/footer
Eckelj/footer
2 parents a0e2f36 + 99fbf1c commit 468fabf

75 files changed

Lines changed: 25421 additions & 32859 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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Footer Implementation
2+
3+
## Overview
4+
The footer section (starting from line 620) has been extracted into a reusable component that's loaded dynamically via JavaScript.
5+
6+
## Files Created
7+
8+
### 1. `footer-template.html`
9+
Contains the complete footer HTML including:
10+
- Footer navigation menu
11+
- Social media links
12+
- Legal links
13+
- Cookie consent banner
14+
- All footer scripts (jQuery, Webflow, Swiper, Google Tag Manager)
15+
16+
### 2. `scripts/load-footer.js`
17+
JavaScript module that:
18+
- Automatically calculates the correct relative path based on page depth
19+
- Fetches the footer template
20+
- Injects it into the `#footer-placeholder` div
21+
- Re-initializes any scripts within the footer
22+
- Triggers a `footerLoaded` event when complete
23+
24+
## Implementation
25+
26+
All HTML files (52 total) have been updated to replace the footer section with:
27+
28+
```html
29+
<--read-inspelnings Footer loaded dynamically -->
30+
<div id="footer-placeholder"></div>
31+
<script src="scripts/load-footer.js"></script>
32+
</body>
33+
</html>
34+
```
35+
36+
The script automatically handles relative paths:
37+
- Root level files: `scripts/load-footer.js`
38+
- One level deep: `../scripts/load-footer.js`
39+
- Two levels deep: `../../scripts/load-footer.js`
40+
41+
## Benefits
42+
43+
1. **Single source of truth**: Footer content is maintained in one file
44+
2. **Easy updates**: Changes to footer affect all pages automatically
45+
3. **Reduced file size**: Each HTML file is ~245 lines smaller
46+
4. **Maintainability**: No need to update 52 files when changing footer
47+
5. **Consistency**: Ensures footer is identical across all pages
48+
49+
## Files Updated
50+
51+
- 52 HTML files across root, /de, /company, /product, /news, /showcase, /energy-community directories
52+
- 3 presentation files in /slides were skipped (they don't have the standard footer)
53+
54+
## Testing
55+
56+
To test if the footer loads correctly:
57+
1. Open any page in a browser
58+
2. Check browser console for any errors
59+
3. Verify footer content appears at the bottom
60+
4. Test footer links and functionality
61+
5. Verify cookie consent banner works
62+
63+
## Rollback
64+
65+
If needed, you can rollback by:
66+
1. Delete `footer-template.html` and `scripts/load-footer.js`
67+
2. Use git to restore the original HTML files

company/about-us.html

Lines changed: 191 additions & 452 deletions
Large diffs are not rendered by default.

company/career.html

Lines changed: 296 additions & 556 deletions
Large diffs are not rendered by default.

company/get-in-touch.html

Lines changed: 157 additions & 417 deletions
Large diffs are not rendered by default.

company/media.html

Lines changed: 191 additions & 450 deletions
Large diffs are not rendered by default.

company/news.html

Lines changed: 547 additions & 798 deletions
Large diffs are not rendered by default.

company/overview.html

Lines changed: 169 additions & 428 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')

0 commit comments

Comments
 (0)