Некодим логотипНекодим
МодификацииПубликацииНекодИИмЦены
Некодим логотипНекодим

© 2020-2026 Некодим

Готовые модификации для вашего сайта. Улучшайте функциональность и дизайн без программирования.

Компания

  • Контакты
  • Публичная оферта
  • Политика конфиденциальности
  • Согласие на обработку данных
  • Лицензионное соглашение
  • Реферальная программа

Полезное

  • Модификации
  • Публикации
  • Каталог блоков Tilda
  • MCP для агентов
  • Журнал изменений
  • Доска почёта

Личный кабинет

  • Вход
  • Регистрация
  • Цены
Журнал измененийИстория GitФайлыTilda MCP
Каталог файлов

tilda-catalog-1.2.js

Код файла
Версия от 05.12.2026, 07:01:02 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
9801			// @ts-expect-error ST-2949_19802			text = '[' + error.status + '] ' + error.responseText;9803			// @ts-expect-error ST-2949_19804		} else if (error && error.statusText) {9805			// @ts-expect-error ST-2949_19806			text = 'Error [' + error.status + ', ' + error.statusText + ']';9807		} else {9808			// @ts-expect-error ST-2949_19809			text = 'Error type [' + error.type + ']';9810		}9811 9812
История файла и сравнение версий
  • 05.12.2026, 07:01:02 · 56c3b845
console.error(text + '. Please, try again later.');
9813 }
9814}
9815
9816/**
9817 * Обрабатывает ответ запроса и если в нем есть редирект на другую зону, обновляет конечную точку API
9818 * @param {string | object} responseData
9819 * @param {string} previousEndpoint - конечная точка API, которая была до выполнения запроса. Из нее извлекается рутзона
9820 * @returns {boolean} была ли изменена рутзона
9821 */
9822function t_catalog__handleRootzoneRedirect(responseData, previousEndpoint) {
9823 let json = responseData;
9824 if (typeof responseData === 'string') {
9825 try {
9826 json = JSON.parse(responseData);
9827 } catch (error) {
9828 return false;
9829 }
9830 }
9831 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
9832 // @ts-expect-error ST-2949_1
9833 const newRootZone = json?.redirectto;
9834 if (!newRootZone) {
9835 return false;
9836 }
9837
9838 const previousRootZone = t_catalog__getRootZoneFromEndpoint(previousEndpoint);
9839 const isRootzoneChanged = previousRootZone !== newRootZone;
9840 if (isRootzoneChanged) {
9841 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
9842 // @ts-expect-error ST-2949_1
9843 window.t_catalog_endpoint = window.t_catalog_endpoint.split('.').slice(0, -1).join('.') + '.' + newRootZone;
9844 }
9845 t_catalog__setRootZone(newRootZone);
9846 return isRootzoneChanged;
9847}
9848
9849// TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)
9850// @ts-expect-error ST-2949_2
9851function t_catalog__getRootZoneFromEndpoint(endpoint) {
9852 const match = endpoint.match(/\.([a-z]{2,})(?:[\/:]|$)/i);
9853 return match ? match[1] : '';
9854}
9855
9856// TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)
9857// @ts-expect-error ST-2949_2
9858function t_catalog_snippet_chooseEditionFromUrl(recid, product, el_product, options) {
9859 try {
9860 var urlParams = t_catalog_snippet_getJsonFromUrl();
9861 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
9862 // @ts-expect-error ST-2949_1
9863 var uid = urlParams.editionuid;
9864 if (uid && el_product.getAttribute('data-product-uid') !== uid) {
9865 console.info('show product by uid from url = ' + uid);
9866 /* find data for edition */
9867 var edObj = '';
9868 // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)
9869 // @ts-expect-error ST-2949_2
9870 product.editions.forEach(function (edtn) {
9871 if (edtn.uid === parseInt(uid, 10)) {
9872 edObj = edtn;
9873 }
9874 });
9875 if (!edObj) {
9876 return;
9877 }
9878
9879 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
9880 // @ts-expect-error ST-2949_5
9881 t_catalog_product_updateEdition(recid, el_product, edObj, product, options);
9882 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
9883 // @ts-expect-error ST-2949_1
9884 var isSoldOut = parseInt(edObj.quantity) === 0;
9885 t_catalog_product_triggerSoldOutMsg(recid, el_product, isSoldOut, options);
9886 }
9887 } catch (error) {
9888 console.error('Error decode url:' + error);
9889 }
9890}
9891
9892// TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)
9893// @ts-expect-error ST-2949_2
9894function t_catalog_moveSearhSort(recid, opts) {
9895 // sidebar может быть пустым, его функция должна находиться всегда в каталоге
9896 var rec = document.getElementById('rec' + recid);
9897 if (!rec) return;
9898 var searchSort = rec.querySelector('.t-catalog__filter__search-and-sort');
9899
9900 // If search was hidden on mobile, show it again on window resize
Предыдущие 100 строкСледующие 100 строк