-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathitem-confirmation.html
More file actions
39 lines (36 loc) · 1.61 KB
/
item-confirmation.html
File metadata and controls
39 lines (36 loc) · 1.61 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
<script>
urlDependentLoadJs('itemConfirmation.js');
// We have to keep this code outside the itemConfirmation.js file so that it's run before the webflow code is loaded
// otherwise the slider does not work.
function initializeSlider(item) {
const images = item?.images;
document.getElementById('slider').style.display = 'block';
const slide = document.getElementById('frontImageSlide');
const cloneSlide = slide.cloneNode(true);
const sliderMask = document.getElementById('sliderMask');
sliderMask.innerHTML = '';
for (const imageName of ['modelImage', 'frontImage', 'enhancedFrontImage', 'brandTagImage', 'materialTagImage', 'extraImage', 'defectImage']) {
if (images[imageName]) {
if (imageName === 'frontImage' && images['enhancedFrontImage']) {
continue;
}
const newSlide = cloneSlide.cloneNode(true);
newSlide.id = imageName;
newSlide.firstChild.src = window.innerWidth <= 350 ? (images[`${imageName}Small`] || images[imageName]): images[imageName];
sliderMask.appendChild(newSlide);
}
}
}
const params = getParamsObject();
if (params.id) {
getItem(params.id).then(initializeSlider)
.catch(e => location.href = '/private');
} else {
item = JSON.parse(localStorage.getItem('latestItemCreated'));
if (!item) {
console.error("No recently created item found");
location.href = '/private';
}
initializeSlider(item);
}
</script>