;try {
// =========================================================
// FULL WIDGET FILE (JS)
// =========================================================
// - Tabs behavior (original, unchanged)
// - Reviews masonry (original, unchanged)
// - ✅ Structured description: распределение по разделам
// * Артикул / Упаковка
// * Применимость / Автомобиль
// * Характеристики
// * Utility numbers
// * OE numbers
// * EAN
// * Аналоги / Кроссы (ТОЛЬКО коды, без "слов")
// * Замены / Replacement numbers
// * Место установки
// * Размеры / Технические данные
// - ✅ Убираем нижний дубль "сырого текста" (скрываем всё кроме SEO-блока)
// =========================================================
let widget = '.widget-type_widget_v4_product_info_2_5f6f3f54bc3450ac4a98b2a8fb5a2a3b';
let $widget = $(widget);
// ---------------------------------------------------------
// Helpers
// ---------------------------------------------------------
function norm(s) {
return String(s || "").replace(/\u00A0/g, " ").replace(/\s+/g, " ").trim();
}
function lower(s) {
return norm(s).toLowerCase();
}
function uniq(arr) {
return Array.from(new Set((arr || []).map(norm).filter(Boolean)));
}
function esc(s) {
return String(s || "")
.replace(/&/g, "&")
.replace(//g, ">");
}
function listBlock(arr) {
const a = (arr || []).map(norm).filter(Boolean);
if (!a.length) return "";
return "
`;
html += `
Структурированное описание
`;
// Артикул / Упаковка
const packRows = [];
if (dealerPartNumber) packRows.push("Dealer part number: " + dealerPartNumber);
if (partNumber) packRows.push("Part Number: " + partNumber);
if (partsDesc) packRows.push("Parts Description: " + partsDesc);
if (packingUnit) packRows.push("Packing unit: " + packingUnit);
if (qtyPerPU) packRows.push("Quantity per PU: " + qtyPerPU);
if (partsState) packRows.push("Parts state: " + partsState);
if (packRows.length) {
html += `
Артикул / Упаковка
`;
html += "
" + packRows.map(esc).join("
") + "
";
}
// Применимость / Автомобиль
const vehRows = [];
if (vehicle) vehRows.push("Vehicle: " + vehicle);
if (constrYear) vehRows.push("Constr.year: " + constrYear);
if (power) vehRows.push("Power: " + power);
if (capacity) vehRows.push("Capacity: " + capacity);
if (engineCode) vehRows.push("Engine Code: " + engineCode);
if (kba) vehRows.push("KBA Keynumber: " + kba);
if (vehRows.length) {
html += `
Применимость / Автомобиль
`;
html += "
" + vehRows.map(esc).join("
") + "
";
}
// Характеристики
if (charsClean.length) {
html += `
Характеристики
`;
html += "
" + charsClean.map(esc).join("
") + "
";
}
// Utility numbers
if (utilityNumbers.length) {
html += `
Utility numbers
`;
html += listBlock(utilityNumbers);
}
// OE numbers
if (oeNumbers.length) {
html += `
OE numbers
`;
html += listBlock(oeNumbers);
}
// EAN
if (ean) {
html += `
EAN
`;
html += listBlock([ean]);
}
// Аналоги / Кроссы (только коды)
if (analogs.length) {
html += `
Аналоги / Кроссы
`;
html += listBlock(analogs);
}
// Replacement numbers
if (replacementOut.length) {
html += `
Замены / Replacement numbers
`;
html += listBlock(replacementOut);
}
// Место установки
if (placeTokens.length) {
html += `
Место установки
`;
html += listBlock(placeTokens);
}
// Размеры / Технические данные
if (tech.length) {
html += `
Размеры / Технические данные
`;
html += listBlock(tech);
}
// Доп. информация
if (infoLines.length) {
html += `
Дополнительная информация
`;
html += "
" + infoLines.map(esc).join("
") + "
";
}
html += `
`;
// вставляем блок наверх
desc.insertAdjacentHTML("afterbegin", html);
// ✅ скрываем "сырой" дубль (всё кроме seo-structured-desc)
Array.from(desc.childNodes).forEach(node => {
if (node.nodeType === Node.ELEMENT_NODE && node.classList && node.classList.contains("seo-structured-desc")) return;
if (node.nodeType === Node.ELEMENT_NODE) node.style.display = "none";
if (node.nodeType === Node.TEXT_NODE) node.textContent = "";
});
})();
// -------------------------------------------------------
// More items (original)
// -------------------------------------------------------
$widget.find('.js-more-items').on("click", function() {
const block_with_more_items = $(this).parents(".block-with-more-items:first");
block_with_more_items.find('.hidden-item').removeClass('hidden-item');
$(this).hide().parents(".more-items").hide();
if (block_with_more_items.find(".masonry-reviews-list").length) {
resizeAllMassonryGridItems();
}
});
// -------------------------------------------------------
// Reviews masonry (original)
// -------------------------------------------------------
function resizeMassonryGridItem(item) {
let grid = document.getElementsByClassName("masonry-reviews-list")[0];
if (!grid) return;
let rowHeight = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-auto-rows'));
let rowGap = parseInt(window.getComputedStyle(grid).getPropertyValue('grid-row-gap'));
if (rowGap == 0) rowGap = 1;
let rowSpan = Math.ceil((item.querySelector('.masonry-reviews-item__content').getBoundingClientRect().height + rowGap) / (rowHeight + rowGap));
item.style.gridRowEnd = "span " + rowSpan;
}
function resizeAllMassonryGridItems() {
const allItems = document.getElementsByClassName("masonry-reviews-item");
for (let x = 0; x < allItems.length; x++) {
resizeMassonryGridItem(allItems[x]);
}
}
window.onload = function() {
resizeAllMassonryGridItems();
}
window.addEventListener("resize", resizeAllMassonryGridItems);
$(function() {
if (window.EventBus && EventBus.subscribe) {
EventBus.subscribe(['widget:input-setting:insales:system:editor', 'widget:change-setting:insales:system:editor'], (data) => {
const masonryReviewsList = document.querySelector('[data-widget-id="' + data.widget_id + '"] .masonry-reviews-list');
if (masonryReviewsList) {
resizeAllMassonryGridItems();
}
});
}
});
// -------------------------------------------------------
// Events (original)
// -------------------------------------------------------
if (window.EventBus && EventBus.subscribe) {
EventBus.subscribe('reviews-open:insales:site', function() {
let reviews_block = $widget.find("#tab-reviews");
if (reviews_block.length) {
$widget.find('[data-tabs-item="tab-reviews"]:first').click();
$('html, body').animate({ scrollTop: reviews_block.offset().top - 64 }, 500);
}
});
EventBus.subscribe('properties-open:insales:site', function() {
let properties_block = $widget.find("#tab-characteristics");
if (properties_block.length) {
$widget.find('[data-tabs-item="tab-characteristics"]:first').click();
$('html, body').animate({ scrollTop: properties_block.offset().top - 64 }, 500);
}
});
$widget.find('.js-show-manager').on("click", function() {
$(this).parents('.masonry-reviews-item__content').find('.comments-item').toggleClass('hidden');
resizeAllMassonryGridItems();
$(this).toggleClass('hidden');
$(this).parents('.masonry-reviews-item__content').find('.js-hide-manager').toggleClass('hidden');
});
$widget.find('.js-hide-manager').on("click", function() {
$(this).parents('.masonry-reviews-item__content').find('.comments-item').toggleClass('hidden');
resizeAllMassonryGridItems();
$(this).toggleClass('hidden');
$(this).parents('.masonry-reviews-item__content').find('.js-show-manager').toggleClass('hidden');
});
$widget.find('.js-show-form').on("click", function() {
$widget.find('.reviews-wrapper').toggleClass('hidden');
$(this).hide();
});
$widget.find('.js-hide-form').on("click", function() {
$widget.find('.reviews-wrapper').toggleClass('hidden');
$widget.find('.js-show-form').show();
});
$widget.find('.js-load-review-image').on("change", function() {
let str = $(this).val();
let i = str.lastIndexOf('/') + 1;
if (str.lastIndexOf('\\')) i = str.lastIndexOf('\\') + 1;
let filename = str.slice(i);
$widget.find('.load-review-image-name').html(filename);
});
EventBus.subscribe('send-review:insales:ui_reviews', (data) => {
const $thisWidget = $(data.form[0].closest('.layout'));
if ($thisWidget.attr('class') !== $widget.attr('class')) { return; }
const review_notice_success = $thisWidget.find("[data-reviews-form-success]");
const file_input = $thisWidget.find("[data-reviews-file-input-name]");
if (file_input.length) {
file_input.text(file_input.data('reviews-file-input-name'));
}
if (review_notice_success.length) {
$('html,body').animate({ scrollTop: review_notice_success.offset().top }, 500);
}
});
}
});
} catch (error) {
console.error('Widget "widget-type_widget_v4_product_info_2_5f6f3f54bc3450ac4a98b2a8fb5a2a3b"', error);
}