-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
58 lines (50 loc) · 1.51 KB
/
Copy pathmain.js
File metadata and controls
58 lines (50 loc) · 1.51 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
// main.js
import config from './config.js';
import CompareSystem from './compare-system.js';
import ProductManager from './product-manager.js';
class App {
constructor() {
this.compareSystem = new CompareSystem();
this.productManager = new ProductManager();
}
async init() {
await this.productManager.init();
if (config.isProductPage) {
const productId = window.location.pathname.split('/')[2];
await this.productManager.renderProductPage(productId);
} else if (config.isComparePage) {
await this.productManager.renderComparePage();
} else {
await this.productManager.renderProducts();
}
// Inicjalizacja dodatkowych funkcji
this.initBarcode();
this.initLightbox();
}
initBarcode() {
const barcodeElement = document.getElementById('barcode');
if (barcodeElement && window.JsBarcode) {
const ean = barcodeElement.dataset.ean;
JsBarcode("#barcode", ean, {
format: "EAN13",
width: 2,
height: 100,
displayValue: true
});
}
}
initLightbox() {
if (window.lightbox) {
lightbox.option({
'resizeDuration': 200,
'wrapAround': true
});
}
}
}
// Inicjalizacja aplikacji
document.addEventListener('DOMContentLoaded', () => {
const app = new App();
app.init();
});
export default App;