PageSourceSearch

https://www.chocolatehill.cz/user/documents/upload/scripts/script.fixed.js

js chocolatehill.cz collected 2026-10-02 23:00:01 UTC 26,770 bytes, 831 lines download raw bytes

1/**
2 * Utility
3 */
4
5let attribute = {
6  name: null,
7  value: null,
8}
9
10function addChildren(
11  childTag = '',
12  parent = HTMLElement,
13  options = {
14    attributes: attribute || Array().fill(attribute),
15    classes: null,
16    listItemsNumber: null,
17    siblingAfter: null,
18    text: null,
19}) {
20  const attributes = options.attributes;
21  const child = document.createElement(childTag);
22  const classes = options.classes;
23  const listItemsNumber = options.listItemsNumber;
24  const siblingAfter = options.siblingAfter;
25  const text = options.text;
26
27  if (attributes) {
28    if (Array.isArray(attributes) && attributes.length > 0) {
29      attributes.forEach(attribute => {
30        child.setAttribute(attribute.name, attribute.value);
31      });
32    }
33    
34    else if (attributes.name && attributes.value) {
35      child.setAttribute(attributes.name, attributes.value);
36    }
37  }
38
39  if (classes) {
40    if (Array.isArray(classes) && classes.length > 0) {
41      child.classList.add(...classes);
42    }
43    
44    else {
45      child.classList.add(classes);
46    }
47  }
48
49  if (childTag === 'ul' && listItemsNumber) {
50    for (let i = 0; i < listItemsNumber; i++) {
51      const listItem = document.createElement('li');
52      child.appendChild(listItem);
53    }
54  }
55
56  if (text) {
57    child.innerText = text;
58  }
59
60  if (siblingAfter) {
61    siblingAfter.parentNode.insertBefore(child, siblingAfter);
62  }
63  
64  else {
65    parent.appendChild(child);
66  }
67
68  return child;
69}
70
71function limitTextToLength(
72  text = '',
73  characterLimit = 0,
74) {
75  let shortenedText = text;
76
77  if (shortenedText.length > characterLimit) {
78    shortenedText = `${shortenedText.slice(0, characterLimit)}...`;
79  }
80
81  return shortenedText;
82}
83
84/**
85 * Variables
86 */
87const chocolatehillImagesPath = '/user/documents/upload/assets/images/chocolatehill-only/';
88
89/**
90 * Header
91 */
92
93const overallWrapper = document.getElementsByClassName('overall-wrapper')[0];
94const siteMsgInformation = document.getElementsByClassName('site-msg information')[0];
95const topNavigationBar = document.getElementsByClassName('top-navigation-bar')[0];
96const projectPhone = topNavigationBar?.getElementsByClassName('project-phone')[0];
97const topNavigationTools = topNavigationBar?.getElementsByClassName('top-navigation-tools')[0];
98const headerTop = document.getElementsByClassName('header-top')[0];
99const search = headerTop?.getElementsByClassName('search')[0];
100
101if (siteMsgInformation) {
102  siteMsgInformation.remove();
103  topNavigationBar?.parentNode.insertBefore(siteMsgInformation, topNavigationBar);
104}
105
106// TODO add registration link to mobile menu too
107const registrationLink = addChildren('a', topNavigationTools, {
108  attributes: {
109    name: 'href',
110    value: '/registrace',
111  },
112  classes: 'top-navigation-tools__restration-link',
113  text: 'Registrace',
114});
115
116const headerContacts = addChildren('div', headerTop, {
117  classes: 'header-top__contacts',
118  siblingAfter: search?.nextSibling,
119});
120
121projectPhone?.remove();
122headerContacts.appendChild(projectPhone);
123
124const openingHours = addChildren('span', headerContacts, {
125  classes: 'header-top__contacts__opening-hours',
126  text: 'Po-pá (13:00 - 18:00)',
127});
128
129/**
130 * middle-banners section
131 */
132
133const middleBannersWrapper = document.getElementsByClassName('middle-banners-wrapper')[0];
134const middleBannersContainer = middleBannersWrapper?.getElementsByClassName('container')[0];
135const bodyBanners = middleBannersWrapper?.getElementsByClassName('body-banners')[0];
136
137if (bodyBanners) {
138  bodyBanners.remove();
139
140  const categoryList = addChildren('ul', middleBannersContainer, {
141    classes: 'category-list',
142    listItemsNumber: 8,
143  });
144
145  const categoryListItems = categoryList?.getElementsByTagName('li');
146
147  const categoryListItemsData = [
148    {
149      alt: 'Čokoládové tyčinky',
150      fileName: 'category-cokoladove-tycinky',
151      link: 'vazena-cokolada',
152    },{
153      alt: 'Ořechové krémy s čokoládou',
154      fileName: 'category-orechove-kremy-s-cokoladou',
155      link: 'cokoladove-kremy',
156    },{
157      alt: 'Čokolády bez přidaných cukrů',
158      fileName: 'category-cokolady-bez-pridanych-cukru',
159      link: 'cokolady-bez-cukru-low-carb',
160    },{
161      alt: 'Bio čokolády',
162      fileName: 'category-bio-cokolady',
163      link: 'bio-cokolady',
164    },{
165      alt: 'Tabulkové čokolády s posypem',
166      fileName: 'category-tabulkove-cokolady-s-posypem',
167      link: 'cokolady-s-posypem',
168    },{
169      alt: 'Kakaové boby',
170      fileName: 'category-kakaove-boby',
171      link: 'kakaove-boby',
172    },{
173      alt: 'Darková balení čokolád',
174      fileName: 'category-darkova-baleni-cokolad',
175      link: 'cokoladove-darky',
176    },{
177      alt: 'Výroba čokolád na míru',
178      fileName: 'category-vyroba-cokolad-na-miru',
179      link: 'vyroba-cokolad',
180    },
181  ];
182
183  for (let i = 0; i < categoryListItems?.length; i++) {
184    const categoryListItem = categoryListItems[i];
185    
186    categoryListItem.classList.add('category-list__item');
187
188    const categoryListItemLink = addChildren('a', categoryListItem, {
189      attributes: {
190        name: 'href',
191        value: `/${categoryListItemsData[i].link}`,
192      },
193      classes: 'category-list__item__link',
194    });
195
196    const categoryListItemPicture = addChildren('picture', categoryListItemLink);
197
198    const categoryListItemImg = addChildren('img', categoryListItemPicture, {
199      attributes: [{
200        name:  'src',
201        value: `${chocolatehillImagesPath}${categoryListItemsData[i].fileName}.png`,
202      },{
203        name:  'alt',
204        value: categoryListItemsData[i].alt, 
205      }],
206      classes: 'category-list__item__image',
207    });
208  }
209}
210
211/**
212 * product groups sections
213 */
214
215const productCollection = document.getElementsByClassName('product');
216
217for (let i = 0; i < productCollection.length; i++) {
218  const product = productCollection[i];
219
220  const productAvailability = product.getElementsByClassName('availability')[0];
221  const productAvailabilityTitle = productAvailability.getElementsByTagName('span')[0];
222
223  if (productAvailabilityTitle &&
224    productAvailabilityTitle.innerHTML.toLowerCase().trim() == 'skladem'
225  ) {
226    productAvailabilityTitle.style.color = '';
227    productAvailability.classList.add('availability--in-stock');
228  }
229  
230  productAvailability.remove();
231
232  const productPrice = product.getElementsByClassName('price')[0];
233  productPrice.remove();
234
235  const productName = product.getElementsByClassName('name')[0];
236  
237  const productIn = product.getElementsByClassName('p-in')[0];
238  const productInTop = addChildren('div', productIn, {
239    classes: 'product-in__top',
240    siblingAfter: productName,
241  });
242
243  productInTop.appendChild(productAvailability);
244  productInTop.appendChild(productPrice);
245}
246
247/**
248 * process section
249 */
250
251const homepageProductsHeading4 = document.getElementsByClassName('homepage-products-heading-4')[0];
252const homepageProductsContainer = homepageProductsHeading4?.parentNode;
253
254if (homepageProductsContainer) {
255  const processSection = addChildren('section', homepageProductsContainer, {
256    classes: 'process-section',
257    siblingAfter: homepageProductsHeading4,
258  });
259
260  const processSectionContent = addChildren('div', processSection, {
261    classes: 'process-section__content'
262  });
263
264  const processSectionHeading = addChildren('h4', processSectionContent, {
265    classes: [
266      'process-section__heading',
267      'base-heading',
268    ],
269    text: 'Jak pro vás vyrábíme čokoládu',
270  });
271
272  const processSectionList = addChildren('ul', processSectionContent, {
273    classes: 'process-section__list',
274    listItemsNumber: 4,
275  });
276
277  const processSectionItems = processSectionList?.getElementsByTagName('li');
278  const processSectionItemsData = [
279    {
280      alt: 'Kakaové boby třídíme a čistíme',
281      fileName: 'process-kakaove-boby-tridime-a-cistime',
282      link: 'vyroba-cokolady/#cisteni',
283    },{
284      alt: 'Pak je jemně upražíme',
285      fileName: 'process-pak-je-jemne-uprazime',
286      link: 'vyroba-cokolady/#prazeni',
287    },{
288      alt: 'Odslupkujeme a rozdrtíme na kousky',
289      fileName: 'process-odslupkujeme-a-rozdrtime-na-kousky',
290      link: 'vyroba-cokolady/#drceni',
291    },{
292      alt: 'Minimálně 72 hodin meleme',
293      fileName: 'process-minimalne-72-hodin-meleme',
294      link: 'vyroba-cokolady/#mleti',
295    },
296  ];
297
298  for (let i = 0; i < processSectionItems.length; i++) {
299    const processSectionItem = processSectionItems[i];
300
301    processSectionItem.classList.add('process-section__item');
302    
303    const processSectionItemLink = addChildren('a', processSectionItem, {
304      attributes: [{
305        name: 'href',
306        value: `/${processSectionItemsData[i].link}`,
307      }],
308      classes: 'process-section__item__link',
309    });
310
311    const processSectionItemHeader = addChildren('header', processSectionItemLink, {
312      classes: 'process-section__item__header',
313    });
314    const processSectionItemNumber = addChildren('span', processSectionItemHeader, {
315      classes: 'process-section__item__number',
316      text: `0${i + 1}`,
317    });
318    const processSectionItemHeading = addChildren('h5', processSectionItemHeader, {
319      classes: 'process-section__item__title',
320      text: processSectionItemsData[i].alt,
321    });
322    const processSectionItemImage = addChildren('div', processSectionItemLink, {
323      classes: 'process-section__item__image',
324    });
325    const processSectionItemPicture = addChildren('picture', processSectionItemImage);
326    const processSectionItemImg = addChildren('img', processSectionItemPicture, {
327      attributes: [{
328        name:  'src',
329        value: `${chocolatehillImagesPath}${processSectionItemsData[i].fileName}.png`,
330      },{
331        name:  'alt',
332        value: processSectionItemsData[i].alt, 
333      }],
334    });
335  }
336}
337
338/**
339 * welcome section
340 */
341
342const welcomeHomepageBox = document.getElementsByClassName('homepage-box welcome-wrapper')[0];
343const welcomeWrapper = welcomeHomepageBox?.getElementsByClassName('welcome-wrapper')[0];
344const blogWrapper = document.getElementsByClassName('blog-wrapper')[0];
345
346welcomeHomepageBox?.remove();
347
348blogWrapper?.parentNode?.insertBefore(welcomeWrapper, blogWrapper);
349
350/**
351 * blog section
352 */
353
354if (blogWrapper) {
355  const blogButtons = addChildren('div', blogWrapper, {
356    classes: 'blog-buttons',
357  });
358
359  const blogButton = addChildren('a', blogButtons, {
360    attributes: {
361      name: 'href',
362      value: '/blog',
363    },
364    classes: [
365      'blog-button',
366      'base-button',
367    ],
368    text: 'Ochutnat více',
369  });
370}
371
372/**
373 * follow section
374 */
375
376const footer = document.getElementById('footer');
377const followSectionWrapperIn = addChildren('div', footer?.parentNode);
378const followSection = addChildren('section', followSectionWrapperIn, {
379  classes: [
380    'follow-section',
381    'container',
382  ],
383  siblingAfter: footer,
384});
385
386if (followSection) {
387  const followSectionContainer = addChildren('div', followSection, {
388    classes: 'follow-section__container',
389  });
390
391  const followSectionHeading = addChildren('h4', followSectionContainer, {
392    classes: [
393      'follow-section__heading',
394      'base-heading',
395    ],
396    text: 'Sledujte nás na',
397  });
398
399  const followSectionInstagramLink = addChildren('a', followSectionContainer, {
400    attributes: [{
401      name: 'href',
402      value: 'https://www.instagram.com/chocolatehillcz',
403    },{
404      name: 'target',
405      value: '_blank',
406    }],
407    classes: 'follow-section__instagram-link',
408    text: 'chocolatehillcz',
409  });
410
411  const followSectionImagesList = addChildren('ul', followSectionContainer, {
412      classes: 'follow-section__images',
413      listItemsNumber: 5,
414    });
415
416  const followSectionImagesListItems = followSectionImagesList?.getElementsByTagName('li');
417
418  const followSectionImagesListItemsData = [
419    {
420      alt: 'Chocolatehill instagram 01',
421      fileName: 'follow-section-instagram-01',
422      link: 'https://www.instagram.com/chocolatehillcz/p/DGx_NZWMvvR/'
423    },{
424      alt: 'Chocolatehill instagram 02',
425      fileName: 'follow-section-instagram-02',
426      link: 'https://www.instagram.com/chocolatehillcz/p/DN6AXSHDWk7/',
427    },{
428      alt: 'Chocolatehill instagram 03',
429      fileName: 'follow-section-instagram-03',
430      link: 'https://www.instagram.com/chocolatehillcz/p/C6ahoz0rtqq/',
431    },{
432      alt: 'Chocolatehill instagram 04',
433      fileName: 'follow-section-instagram-04',
434      link: 'https://www.instagram.com/chocolatehillcz/p/DQelV7gErvQ/',
435    },{
436      alt: 'Chocolatehill instagram 05',
437      fileName: 'follow-section-instagram-05',
438      link: 'https://www.instagram.com/chocolatehillcz/p/DQXEtCSDZZQ/',
439    },
440  ];
441
442  for (let i = 0; i < followSectionImagesListItems?.length; i++) {
443    const followSectionImagesListItem = followSectionImagesListItems[i];
444    
445    followSectionImagesListItem.classList.add('follow-section__images__item');
446
447    const followSectionImagesListItemLink = addChildren('a', followSectionImagesListItem, {
448      attributes: [{
449        name: 'href',
450        value: followSectionImagesListItemsData[i].link,
451      },{
452        name: 'target',
453        value: '_blank'
454      }],
455      classes: 'follow-section__images__item__link',
456    });
457
458    const followSectionImagesListItemPicture = addChildren('picture', followSectionImagesListItemLink);
459
460    const followSectionImagesListItemImg = addChildren('img', followSectionImagesListItemPicture, {
461      attributes: [{
462        name:  'src',
463        value: `${chocolatehillImagesPath}${followSectionImagesListItemsData[i].fileName}.png`,
464      },{
465        name:  'alt',
466        value: followSectionImagesListItemsData[i].alt, 
467      }],
468      classes: 'follow-section__images__item__image',
469    });
470  }
471}
472
473/**
474 * footer
475 */
476
477const siteName = footer?.getElementsByClassName('site-name')[0];
478if (siteName) {
479  siteName.remove();
480}
481
482const footerCustomerLinks = footer?.getElementsByClassName('custom-footer__contact')[0];
483footerCustomerLinks?.classList.add('custom-footer__customer-links');
484footerCustomerLinks?.classList.remove('custom-footer__contact');
485
486if (footerCustomerLinks) {
487  //  const footerCustomerLinksHeadingText = footerCustomerLinks.getElementsByTagName('h4')[0]?.getElementsByTagName('span')[0];
488  const footerCustomerLinksHeadingText = footerCustomerLinks.getElementsByClassName('pageElement__heading')[0]?.getElementsByTagName('span')[0];
489
490  if (footerCustomerLinksHeadingText && typeof footerCustomerLinksHeadingText !== undefined) {
491    footerCustomerLinksHeadingText.innerText = 'Pro zákazníky';
492  }
493
494  const footerCustomerLinksContactBox = footerCustomerLinks.getElementsByClassName('contact-box')[0];
495  footerCustomerLinksContactBox.remove();
496
497  const footerCustomerList = addChildren('ul', footerCustomerLinks, {
498    classes: 'custom-footer__list',
499    listItemsNumber: 7,
500  });
501
502  const footerCustomerListItems = footerCustomerList?.getElementsByTagName('li');
503
504  const footerCustomerListItemsData = [
505    {
506      title: 'Čokoláda jako firemní dárky',
507      link: 'cokolada-jako-firemni-darky',
508    },{
509      title: 'O nás',
510      link: 'o-nas',
511    },{
512      title: 'Velkoobchod',
513      link: 'velkoobchod',
514    },{
515      title: 'Blog',
516      link: 'blog',
517    },{
518      title: 'BIO čokoláda a její výroba',
519      link: 'bio-cokolada-a-jeji-vyroba',
520    },{
521      title: 'Výroba čokolády',
522      link: 'vyroba-cokolady',
523    },{
524      title: 'Kontakty',
525      link: 'kontakty',
526    },
527  ];
528
529  for (let i = 0; i < footerCustomerListItems.length; i++) {
530    const footerCustomerListItem = footerCustomerListItems[i];
531    
532    const footerCustomerListLink = addChildren('a', footerCustomerListItem, {
533      attributes: {
534        name: 'href',
535        value: `/${footerCustomerListItemsData[i].link}`,
536      },
537      text: footerCustomerListItemsData[i].title,
538    });
539  }
540}
541
542const footerArticlesLinks = footer?.getElementsByClassName('custom-footer__articles')[0];
543
544if (footerArticlesLinks) {
545  const footerArticlesList = footerArticlesLinks.getElementsByTagName('ul')[0];
546  footerArticlesList.classList.add('custom-footer__list');
547
548  // const footerArticlesLinksHeadingText = footerArticlesLinks.getElementsByTagName('h4')[0]?.getElementsByTagName('span')[0];
549  const footerArticlesLinksHeadingText = footerArticlesLinks.getElementsByClassName('pageElement__heading')[0]?.getElementsByTagName('span')[0];
550
551  if (footerArticlesLinksHeadingText && typeof footerArticlesLinksHeadingText !== undefined) {
552    footerArticlesLinksHeadingText.innerText = 'Informace';
553  }
554}
555
556const footerPaymentAndShipping = footer?.getElementsByClassName('custom-footer__onlinePayments')[0];
557
558if (footerPaymentAndShipping) {
559  footerPaymentAndShipping.classList.add('custom-footer__payments-and-shipping');
560  footerPaymentAndShipping.classList.remove('custom-footer__onlinePayments');
561
562  // const footerPaymentsHeading = footerPaymentAndShipping.getElementsByTagName('h4')[0];
563  const footerPaymentsHeading = footerPaymentAndShipping.getElementsByClassName('pageElement__heading')[0];
564
565  if (footerPaymentsHeading && typeof footerPaymentsHeading !== undefined) {
566    footerPaymentsHeading.innerText = 'Platební metody';
567  }
568
569  const footerPaymentAndShippingText = footerPaymentAndShipping.getElementsByClassName('text-center')[0];
570  footerPaymentAndShippingText.remove();
571
572  const footerPayments = addChildren('ul', footerPaymentAndShipping, {
573    classes: 'custom-footer__payments',
574    listItemsNumber: 4,
575  });
576
577  const footerPaymentsItems = footerPayments.getElementsByTagName('li');
578
579  const footerPaymentsItemsData = [
580    {
581      alt: 'Comgate',
582      fileName: 'payments-comgate',
583    },{
584      alt: 'Visa',
585      fileName: 'payments-visa',
586    },{
587      alt: 'Mastercard',
588      fileName: 'payments-mastercard',
589    },{
590      alt: 'Maestro',
591      fileName: 'payments-maestro',
592    },
593  ];
594
595  for (let i = 0; i < footerPaymentsItems.length; i++) {
596    const footerPaymentsItem = footerPaymentsItems[i];
597    
598    const footerPaymentsItemPicture = addChildren('picture', footerPaymentsItem);
599
600    const footerPaymentsItemImage = addChildren('img', footerPaymentsItemPicture, {
601      attributes: [
602      {
603        name: 'src',
604        value: `${chocolatehillImagesPath}common/${footerPaymentsItemsData[i].fileName}.png`,
605      },{
606        name: 'alt',
607        value: footerPaymentsItemsData[i].alt,
608      }]
609    });
610  }
611
612  const footerShippingHeading = addChildren('h4', footerPaymentAndShipping, {
613    text: 'Způsob doručení',
614  });
615
616  const footerShipping = addChildren('ul', footerPaymentAndShipping, {
617    classes: 'custom-footer__shipping',
618    listItemsNumber: 4,
619  });
620
621  const footerShippingItems = footerShipping.getElementsByTagName('li');
622
623  const footerShippingItemsData = [
624    {
625      alt: 'Zásilkovna',
626      fileName: 'shipping-packeta',
627    },{
628      alt: 'Česká pošta',
629      fileName: 'shipping-cpost',
630    },{
631      alt: 'PPL',
632      fileName: 'shipping-ppl',
633    },{
634      alt: 'GLS',
635      fileName: 'shipping-gls',
636    },
637  ];
638
639  for (let i = 0; i < footerShippingItems.length; i++) {
640    const footerShippingItem = footerShippingItems[i];
641    
642    const footerShippingItemPicture = addChildren('picture', footerShippingItem);
643
644    const footerShippingItemImage = addChildren('img', footerShippingItemPicture, {
645      attributes: [
646      {
647        name: 'src',
648        value: `${chocolatehillImagesPath}common/${footerShippingItemsData[i].fileName}.png`,
649      },{
650        name: 'alt',
651        value: footerShippingItemsData[i].alt,
652      }]
653    });
654  }
655}
656
657const footerPromo = footer?.getElementsByClassName('custom-footer__poll')[0];
658
659if (footerPromo) {
660  footerPromo.classList.add('custom-footer__promo');
661  footerPromo.classList.remove('custom-footer__poll');
662  footerPromo.innerHTML = '';
663
664  const footerLogo = addChildren('a', footerPromo, {
665    attributes: {
666      name: 'href',
667      value: '/',
668    },
669    classes: 'custom-footer__logo',
670  });
671
672  const footerLogoImage = addChildren('img', footerLogo, {
673    attributes: [{
674      name: 'src',
675      value: `${chocolatehillImagesPath}common/logo-chocolatehill-on-dark.svg`,
676    },{
677      name: 'alt',
678      value: 'Chocolatehill logo',
679    }],
680  });
681
682  const footerSocialsList = addChildren('ul', footerPromo, {
683    classes: 'custom-footer__socials',
684    listItemsNumber: 3,
685  });
686
687  const footerSocialsListItems = footerSocialsList.getElementsByTagName('li');
688
689  const footerSocialsListItemsData = [
690    {
691      name: 'facebook',
692      link: 'https://www.facebook.com/ChocolateHillCZ',
693    },{
694      name: 'instagram',
695      link: 'https://www.instagram.com/chocolatehillcz'
696    },{
697      name: 'youtube',
698      link: 'https://www.youtube.com/@chocolatehill7199',
699    },
700  ];
701
702  for (let i = 0; i < footerSocialsListItems.length; i++) {
703    const footerSocialsListItem = footerSocialsListItems[i];
704    
705    const footerSocialsListItemLink = addChildren('a', footerSocialsListItem, {
706      attributes: [{
707        name: 'href',
708        value: footerSocialsListItemsData[i].link,
709      },{
710        name: 'target',
711        value: '_blank',
712      }],
713    });
714
715    const footerSocialsListItemIcon = addChildren('span', footerSocialsListItemLink, {
716      classes: `custom-footer__socials__icon--${footerSocialsListItemsData[i].name}`,
717    });
718  }
719}
720
721/**
722 * Category
723 */
724
725const sidebarLeft = document.getElementsByClassName('sidebar-left')[0];
726const boxFilters = sidebarLeft?.getElementsByClassName('box-filters')[0];
727boxFilters?.remove();
728
729const categoryTitle = document.getElementsByClassName('category-title')[0];
730categoryTitle?.classList.add('base-heading', 'base-heading--align-left');
731
732const categoryTop = document.getElementsByClassName('category-top')[0];
733const productsTopWrapper = categoryTop?.getElementsByClassName('products-top-wrapper')[0];
734productsTopWrapper?.remove();
735
736const categoryContentWrapper = document.getElementsByClassName('category-content-wrapper')[0];
737const categoryHeader = categoryContentWrapper?.getElementsByClassName('category-header')[0];
738
739if (categoryHeader) {
740  categoryHeader.innerHTML = '';
741}
742
743const subcategories = categoryTop?.getElementsByClassName('subcategories')[0];
744
745if (subcategories) {
746  const subcategoriesItems = subcategories.getElementsByTagName('li');
747
748  for (let i = 0; i < subcategoriesItems.length; i++) {
749    const subcategoriesItem = subcategoriesItems[i];
750    
751    const subcategoriesItemImage = subcategoriesItem.getElementsByClassName('image')[0];
752    subcategoriesItemImage.remove();
753  }
754}
755
756/**
757 * Product detail
758 */
759const productDetail = document.getElementsByClassName('p-detail')[0];
760
761if (productDetail) {
762  const productDetailHeading = productDetail.getElementsByClassName('p-detail-inner-header')[0];
763  const productDetailInfo = productDetail.getElementsByClassName('p-info-wrapper')[0];
764  const productDetailPrice = productDetail.getElementsByClassName('p-final-price-wrapper')[0];
765
766  productDetailHeading.classList.add('base-heading', 'base-heading--align-left');
767  productDetailHeading.remove();
768
769  productDetailPrice.parentNode.insertBefore(productDetailHeading, productDetailPrice);
770
771  // FIX #1: Krátký popis — přesunout CELÝ obsah beze změny, bez ořezu na 144 znaků a bez "Zobrazit více"
772  const productDetailShortDesc = productDetailInfo.getElementsByClassName('p-short-description')[0];
773  const productDetailShortDescMore = productDetailInfo.querySelectorAll('[data-testid=productCardDescr]')[0];
774
775  const productDetailShortDescWrapper = addChildren('div', productDetailInfo, {
776    classes: 'p-detail__short-description',
777    siblingAfter: productDetailPrice,
778  });
779
780  if (productDetailShortDesc) {
781    while (productDetailShortDesc.firstChild) {
782      productDetailShortDescWrapper.appendChild(productDetailShortDesc.firstChild);
783    }
784    productDetailShortDesc.remove();
785  }
786
787  // "Zobrazit více" link úplně vyhodit
788  productDetailShortDescMore?.remove();
789
790  // FIX #2: Mock varianty produktu odstraněny.
791  // Dříve zde JS natvrdo vytvářel 4 placeholder dlaždice s neexistujícími obrázky (product-detail-variant-01..04.png)
792  // a odkazy href="#". Až bude potřeba reálný přepínač variant, použít Shoptet nativní render variant.
793
794  const productDetailAvailability = productDetail.getElementsByClassName('availability-value')[0];
795  const productDetailAvailabilityTitle = productDetailAvailability.getElementsByTagName('span')[0];
796
797  if (productDetailAvailabilityTitle &&
798    productDetailAvailabilityTitle.innerHTML.toLowerCase().trim() == 'skladem'
799  ) {
800    productDetailAvailabilityTitle.style.color = '';
801    productDetailAvailability.classList.add('availability-value--in-stock');
802  }
803
804  const productRelatedProductsHeading = productDetail.getElementsByClassName('products-related-header')[0];
805
806  if (productRelatedProductsHeading) {
807    productRelatedProductsHeading.classList.add('base-heading');
808  }
809
810  // FIX #3: Dlouhý popis (description) — přesouvat tabs wrapper jen pokud máme oboje.
811  // Původní kód VŽDY odstranil .p-detail-tabs-wrapper, ale když produkt neměl related-products-header,
812  // tak ho už nikam nevrátil → dlouhý popis ze stránky úplně zmizel.
813  const productRelatedProducts = productDetail.getElementsByClassName('product-block products-related-product-additional')[0];
814  const productParams = productDetail.getElementsByClassName('p-detail-tabs-wrapper')[0];
815
816  if (productParams && productRelatedProductsHeading) {
817    productParams.remove();
818    productRelatedProductsHeading.parentNode.insertBefore(productParams, productRelatedProductsHeading);
819  }
820  // Pokud nadpis related produktů chybí, necháme tabs wrapper na původním místě — popis zůstane viditelný.
821
822  const productDetailDescription = productDetail.getElementsByClassName('basic-description')[0];
823
824  if (productDetailDescription) {
825    const productDetailDescriptionDefaultHeading = productDetailDescription.getElementsByTagName('h3')[0];
826
827    if (productDetailDescriptionDefaultHeading?.innerText.toLocaleLowerCase() === 'detailní popis produktu') {
828      productDetailDescriptionDefaultHeading.remove();
829    }
830  }
831}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.