PageSourceSearch

https://zs-mc.ru/catalog/view/theme/zs_mc/scripts/custom.js?v=1.4.0

js zs-mc.ru collected 2026-09-28 11:16:22 UTC 5,322 bytes, 144 lines download raw bytes

1document.addEventListener('DOMContentLoaded', function () {
2  const pageSaleAjax = () => {
3    if (!document.querySelector('.sale-filters__form')) return
4
5    const changeContent = (html, isChangeType = true) => {
6      const div = document.createElement('div')
7      div.innerHTML = html
8
9      const newPageCounter = div.querySelector('.page-title__counter')
10
11      const newList = div.querySelector('.sale-list')
12      const newPaginationMobile = div.querySelector('.pagination.hidden-to-md')
13      const newPaginationDesk = div.querySelector('.pagination.hidden-from-md')
14
15      pageCounter.innerHTML = newPageCounter.innerHTML
16
17      if (newList) {
18        list.style.display = 'block'
19        if (window.innerWidth > 768 || isChangeType)
20          list.innerHTML = newList.innerHTML
21        else
22          list.innerHTML += newList.innerHTML
23      } else {
24        list.style.display = 'none'
25        list.innerHTML = ''
26      }
27
28      if (newPaginationMobile) {
29        paginationMobile.style.display = 'block'
30        paginationMobile.innerHTML = newPaginationMobile.innerHTML
31      } else {
32        paginationMobile.style.display = 'none'
33        paginationMobile.innerHTML = ''
34      }
35
36      if (newPaginationDesk) {
37        paginationDesk.style.display = 'block'
38        paginationDesk.innerHTML = newPaginationDesk.innerHTML
39      } else {
40        paginationDesk.style.display = 'none'
41        paginationDesk.innerHTML = ''
42      }
43    }
44
45    const filter = async () => {
46      const type = form.querySelector('.sale-filter__input:checked').value
47
48      let url = `${location.pathname}?PageSpeed=noscript`
49      if (type) url += `&filters=${type}`
50
51      const response = await fetch(url)
52      const html = await response.text()
53
54      changeContent(html)
55    }
56
57    const filterMobile = async (e) => {
58      const type = e.target.closest('.dropdown__item').getAttribute('data-value')
59
60      let url = `${location.pathname}?PageSpeed=noscript`
61      if (type) url += `&filters=${type}`
62
63      const response = await fetch(url)
64      const html = await response.text()
65
66      changeContent(html)
67    }
68
69    const paginationClick = async e => {
70      e.preventDefault()
71
72      const target = e.target.closest('a')
73      if (!target) return
74
75      const response = await fetch(target.href + `&PageSpeed=noscript`)
76      const html = await response.text()
77
78      changeContent(html, false)
79    }
80
81    const form = document.querySelector('form.sale-filters__form')
82    const list = document.querySelector('.sale-list')
83    const pageCounter = document.querySelector('.page-title__counter')
84    const paginationMobile = document.querySelector('.pagination.hidden-to-md')
85    const paginationDesk = document.querySelector('.pagination.hidden-from-md')
86
87    if (paginationDesk) paginationDesk.addEventListener('click', paginationClick)
88    if (paginationMobile) paginationMobile.addEventListener('click', paginationClick)
89
90    if (form) form.addEventListener('change', filter)
91    document.querySelectorAll('.sale-filters__form .dropdown__item').forEach(el => el.addEventListener('click', filterMobile))
92  }
93
94  pageSaleAjax()
95
96  const podcastsSpecialist = () => {
97    const tabs = document.querySelector('.podcasts-other-tabs')
98    const pinned = document.querySelector('.podcasts-featured')
99    const podcastsList = document.querySelector('.podcasts-cards')
100    if (!tabs || !pinned || !podcastsList) return
101
102    const pinnedTypes = pinned.getAttribute('data-types').split(' ')
103
104    const switchType = e => {
105      e.preventDefault()
106
107      const target = e.target
108      const selected = podcastsList.getAttribute('data-selected')
109      const newSelected = target.getAttribute('data-type')
110
111      if (target.classList.contains('custom-btn--orange')) return
112
113      if (pinnedTypes.length > 1 && pinnedTypes.includes(newSelected)) {
114        pinned.setAttribute('data-selected', newSelected)
115        pinned.querySelector(`.podcasts-featured-actions [data-type="${newSelected}"]`)?.setAttribute('class', 'custom-btn custom-btn--orange custom-btn--color-black')
116        pinned.querySelector(`.podcasts-featured-actions [data-type="${selected}"]`)?.setAttribute('class', 'custom-btn custom-btn--outline')
117      }
118
119      console.log('a', newSelected, selected, tabs.querySelector(`[data-type="${newSelected}"]`), tabs.querySelector(`[data-type="${selected}"]`))
120      tabs.querySelector(`[data-type="${newSelected}"]`)?.setAttribute('class', 'custom-btn custom-btn--orange custom-btn--color-black')
121      tabs.querySelector(`[data-type="${selected}"]`)?.setAttribute('class', 'custom-btn custom-btn--outline')
122
123      podcastsList?.setAttribute('data-selected', newSelected)
124    }
125
126    tabs.querySelectorAll('.custom-btn').forEach(el => el.addEventListener('click', switchType))
127  }
128
129  podcastsSpecialist()
130
131  const initOpenAppointmentForm = () => {
132    if (location.pathname !== '/') return
133
134    const params = new URLSearchParams(location.search);
135    if (params.get('appoinment') !== '1') return;
136
137    const button = document.querySelector(`.header__extra button[data-modal="modal-appointment"]`)
138    if (!button) return;
139
140    button.click()
141  }
142
143  initOpenAppointmentForm()
144})

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.