-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlayout.js
More file actions
108 lines (101 loc) · 4.18 KB
/
layout.js
File metadata and controls
108 lines (101 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/**
* Paavan marketplace — shared chrome (Amazon / Flipkart–style header & footer).
* Replace LEGAL_NAME and domain in footer for your production domain.
*/
(function (global) {
var LEGAL_NAME = 'Paavan Retail GmbH';
var SHOP_TAGLINE = 'Paavan.de';
var nav = [
{ href: 'index.html', id: 'home', label: 'Home' },
{ href: 'catalog.html', id: 'catalog', label: 'All products' },
{ href: 'catalog.html?category=Electronics', id: 'elec', label: 'Electronics' },
{ href: 'catalog.html?category=Fashion', id: 'fash', label: 'Fashion' },
{ href: 'catalog.html?category=Home', id: 'homecat', label: 'Home' },
{ href: 'catalog.html?category=Sports', id: 'sport', label: 'Sports' },
];
function cartCount() {
try {
var raw = localStorage.getItem('Paavan-cart');
var cart = raw ? JSON.parse(raw) : [];
return cart.reduce(function (n, line) {
return n + (line.qty || 0);
}, 0);
} catch (e) {
return 0;
}
}
function headerHtml(activeId) {
var c = cartCount();
var catLinks = nav
.map(function (item) {
var cls = item.id === activeId ? ' class="nav-cat is-active"' : ' class="nav-cat"';
return '<a href="' + item.href + '"' + cls + '>' + item.label + '</a>';
})
.join('');
return (
'<div class="top-bar">' +
'<div class="top-bar-inner wrap">' +
'<span class="top-bar-msg">Ships to <strong>Germany & EU</strong> · Free delivery from €29</span>' +
'<span class="top-bar-msg">' +
'<a href="shipping.html">Shipping</a> · <a href="returns.html">Returns</a> · <a href="contact.html">Help</a>' +
'</span></div></div>' +
'<div class="main-header wrap">' +
'<a href="index.html" class="logo"><span class="logo-mark">P</span><span class="logo-text">aavan</span></a>' +
'<form class="search-bar" action="catalog.html" method="get" role="search">' +
'<input type="search" name="q" placeholder="Search fashion, electronics, home…" aria-label="Search products" />' +
'<button type="submit" class="search-btn">Search</button></form>' +
'<div class="header-actions">' +
'<a href="cart.html" class="cart-link" aria-label="Shopping cart">' +
'<span class="cart-icon">🛒</span> <span>Cart</span>' +
(c ? '<span class="cart-badge">' + c + '</span>' : '') +
'</a></div></div>' +
'<nav class="category-nav wrap" aria-label="Product categories">' +
catLinks +
'</nav>'
);
}
function footerHtml() {
return (
'<div class="footer-grid wrap">' +
'<div><h4>Get to know us</h4><ul>' +
'<li><a href="about.html">About ' + LEGAL_NAME + '</a></li>' +
'<li><a href="contact.html">Contact & imprint</a></li>' +
'<li><a href="features.html">CleverPush engagement</a></li>' +
'</ul></div>' +
'<div><h4>Shop with confidence</h4><ul>' +
'<li><a href="shipping.html">Shipping rates & times</a></li>' +
'<li><a href="returns.html">Returns & refunds</a></li>' +
'<li><a href="contact.html">Track your order</a></li>' +
'</ul></div>' +
'<div><h4>Legal</h4><ul>' +
'<li><a href="contact.html#imprint">Imprint</a></li>' +
'<li><a href="returns.html">Withdrawal policy</a></li>' +
'<li>Payments: cards, PayPal, Klarna (where available)</li>' +
'</ul></div></div>' +
'<div class="footer-bottom wrap">' +
'<p>© ' +
new Date().getFullYear() +
' <strong>' +
LEGAL_NAME +
'</strong> · ' +
SHOP_TAGLINE +
' · We sell <strong>tangible physical products</strong> only. CleverPush is used for customer notifications; all orders are fulfilled by ' +
LEGAL_NAME +
'.</p></div>'
);
}
function inject(activeId) {
var h = document.getElementById('site-header');
var f = document.getElementById('site-footer');
var nav = activeId || (document.body && document.body.getAttribute('data-nav-active')) || 'home';
if (h) h.innerHTML = headerHtml(nav);
if (f) f.innerHTML = footerHtml();
}
global.ShopLayout = {
inject: inject,
legalName: LEGAL_NAME,
refreshCartBadge: function () {
inject();
},
};
})(typeof window !== 'undefined' ? window : this);