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

© 2020-2026 Некодим

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

Компания

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

Полезное

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

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

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

tilda-catalog-1.2.js

Код файла
Версия от 05.12.2026, 07:01:02 МСК
Оригинал на CDNСнимок 56c3b845Полный текст
2201		var link = 'tilda.' + domainParts[domainParts.length - 1];2202		apiUrl = 'https://' + link + '/projects/store/getproductsbyuid/';2203	}2204 2205	// TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)2206	// @ts-expect-error ST-2949_52207	dataObj = JSON.stringify(dataObj);2208 2209	var xhr = new XMLHttpRequest();2210	xhr.onload = function () {2211		if (xhr.readyState === xhr.DONE && xhr.status === 200) {
История файла и сравнение версий
  • 05.12.2026, 07:01:02 · 56c3b845
2212
if (typeof xhr.responseText !== 'string' || xhr.responseText.substring(0, 1) !== '{') {
2213 console.error("Can't get products array by uid list");
2214 }
2215 if (t_catalog__handleRootzoneRedirect(xhr.responseText, apiUrl)) {
2216 t_catalog_loadProducts_byId(idArr, options, onDone, onFail);
2217 return;
2218 }
2219 onDone(JSON.parse(xhr.responseText));
2220 }
2221 };
2222
2223 // TODO ST-2949_2: implicit any on params, vars, this, and index access (TS7006, TS7005, TS7008, TS7034, TS2683, TS7053, TS7015)
2224 // @ts-expect-error ST-2949_2
2225 function onError(error) {
2226 console.error("Can't get getproductsbyuid. Requesting idArr: " + idArr);
2227
2228 if (typeof onFail === 'function') {
2229 onFail(error);
2230 }
2231 }
2232
2233 xhr.ontimeout = onError;
2234 xhr.onerror = onError;
2235
2236 xhr.open('POST', apiUrl);
2237 xhr.timeout = 20000;
2238 // TODO ST-2949_5: assignability, arguments, calls, return types (TS2345, TS2322, TS2554, TS2769, TS2740, TS2739, TS2353, TS2349, TS2355, TS2366, TS2774, TS18046)
2239 // @ts-expect-error ST-2949_5
2240 xhr.send(dataObj);
2241}
2242
2243/**
2244 * Sends a request to the server to get the filters for the store part
2245 *
2246 * @param {object} options
2247 * @param {Function} onDone - callback on success
2248 * @param {Function} onFail - callback on error
2249 **/
2250function t_catalog_loadFilters(options, onDone, onFail) {
2251 var c = Date.now();
2252 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
2253 // @ts-expect-error ST-2949_1
2254 var storepartuid = options.storepart;
2255
2256 var dataObj = {
2257 storepartuid: storepartuid,
2258 c: c,
2259 };
2260
2261 var allRecords = document.getElementById('allrecords');
2262
2263 // TODO ST-2949_1: missing properties on Window/DOM/data objects (TS2339, TS2551)
2264 // @ts-expect-error ST-2949_1
2265 if (options && options.defaultSort && options.defaultSort.in_stock) {
2266 // @ts-expect-error ST-2949_1
2267 if (!dataObj.filters) dataObj.filters = {};
2268 // @ts-expect-error ST-2949_1
2269 dataObj.filters['quantity'] = 'y';
2270 }
2271
2272 // @ts-expect-error ST-2949_1
2273 var apiUrl = 'https://' + window.t_catalog_endpoint + '/api/getfilters/';
2274
2275 // inside tilda we get data from another url
2276 // @ts-expect-error ST-2949_1
2277 if (!options.isPublishedPage) {
2278 if (allRecords) {
2279 // @ts-expect-error ST-2949_1
2280 dataObj.projectid = allRecords.getAttribute('data-tilda-project-id');
2281 }
2282 var domainParts = window.location.hostname.split('.');
2283 var link = 'tilda.' + domainParts[domainParts.length - 1];
2284 apiUrl = 'https://' + link + '/projects/store/getfilters/';
2285 }
2286
2287 /**
2288 * Обрабатывает ответ getfilters: из сети или из кэша редактора
2289 * @param {string} text - текст ответа
2290 */
2291 function handleFiltersResponse(text) {
2292 try {
2293 onDone(JSON.parse(text));
2294 } catch (error) {
2295 console.error(error);
2296 onDone();
2297 }
2298 }
2299
2300 // В редакторе повторный рендер записи берёт фильтры из кэша (микрозадачей, без сети). Ключ берём до отправки.
Предыдущие 100 строкСледующие 100 строк