promo! csp
This commit is contained in:
parent
f7e53901f9
commit
baba9b9263
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
||||
const host = 'https://hvatilo.ru';
|
||||
// const host = 'https://local.hvatilo.ru:8055';
|
||||
// const host = 'https://hvatilo.ru';
|
||||
const host = 'https://local.hvatilo.ru:8055';
|
||||
|
||||
// Returns a function, that, when invoked, will only be triggered at most once
|
||||
// during a given window of time. Normally, the throttled function will run
|
||||
@ -193,7 +193,7 @@ function renderProduct(item, index) {
|
||||
const li = document.createElement('li');
|
||||
li.className = 'cart-item';
|
||||
const amount = item.unit === 'g' ? item.n + ' г' : item.n + ' шт';
|
||||
li.innerHTML = `
|
||||
li.innerHTML = cartPolicy.createHTML(`
|
||||
<div class="item-image"><img src="${item.image}" alt=""></div>
|
||||
<div class="item-details">
|
||||
<div class="item-name">${item.name}</div>
|
||||
@ -208,7 +208,7 @@ function renderProduct(item, index) {
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
`);
|
||||
return li;
|
||||
}
|
||||
|
||||
@ -219,8 +219,12 @@ let showMoreBtn;
|
||||
let remainingSpan;
|
||||
let initialData_g;
|
||||
|
||||
const cartPolicy = trustedTypes.createPolicy('cartPolicy', {
|
||||
createHTML: (string) => string
|
||||
});
|
||||
|
||||
function renderProducts() {
|
||||
cartList.innerHTML = '';
|
||||
cartList.innerHTML = cartPolicy.createHTML('');
|
||||
visibleProducts.forEach((item, index) => {
|
||||
cartList.appendChild(renderProduct(item, index));
|
||||
});
|
||||
@ -240,10 +244,10 @@ function updateSummaryCount() {
|
||||
Math.round(allProducts.reduce((sum, item) => sum + item.total_price, 0) * 100) / 100,
|
||||
);
|
||||
const x = Math.round(initialData_g.days * initialData_g.excess + initialData_g.days);
|
||||
document.getElementById('summary-details').innerHTML = `${allProducts.length} ${declension(allProducts.length, ['товар', 'товара', 'товаров'])} • ${totalPrice} ~ с запасами на ${x} ${declension(x, ['день', 'дня', 'дней'])}, точность ${Math.round(initialData_g.precision * 100)/100}%`;
|
||||
document.getElementById('total-price').innerHTML = `${totalPrice}`;
|
||||
document.getElementById('summary-details').innerHTML = cartPolicy.createHTML(`${allProducts.length} ${declension(allProducts.length, ['товар', 'товара', 'товаров'])} • ${totalPrice} ~ с запасами на ${x} ${declension(x, ['день', 'дня', 'дней'])}, точность ${Math.round(initialData_g.precision * 100)/100}%`);
|
||||
document.getElementById('total-price').innerHTML = cartPolicy.createHTML(`${totalPrice}`);
|
||||
if(allProducts.length === 0) {
|
||||
document.getElementById('summary-details').innerHTML = `0 товаров • ${totalPrice} ₽`;
|
||||
document.getElementById('summary-details').innerHTML = cartPolicy.createHTML(`0 товаров • ${totalPrice} ₽`);
|
||||
}
|
||||
}
|
||||
function calculateListHeight() {
|
||||
@ -412,20 +416,20 @@ function wholeRender(initialData) {
|
||||
let editingIndex = null;
|
||||
|
||||
function renderPeople() {
|
||||
familyList.innerHTML = '';
|
||||
familyList.innerHTML = cartPolicy.createHTML('');
|
||||
people.forEach((person, index) => {
|
||||
const avatar = '🥦';
|
||||
const div = document.createElement('div');
|
||||
div.className = 'family-member';
|
||||
div.dataset.index = index;
|
||||
div.innerHTML = `
|
||||
div.innerHTML = cartPolicy.createHTML(`
|
||||
<div class="avatar">${avatar}</div>
|
||||
<div class="info">
|
||||
<div class="name">${person.name}</div>
|
||||
<div class="age">${person.age} лет</div>
|
||||
</div>
|
||||
<div class="delete-member" data-index="${index}">×</div>
|
||||
`;
|
||||
`);
|
||||
familyList.appendChild(div);
|
||||
});
|
||||
|
||||
@ -467,7 +471,7 @@ function wholeRender(initialData) {
|
||||
editingIndex = index;
|
||||
|
||||
// Очистка тегов внутри попапа
|
||||
document.querySelectorAll('#personModal .tags-wrap').forEach(el => el.innerHTML = '');
|
||||
document.querySelectorAll('#personModal .tags-wrap').forEach(el => el.innerHTML = cartPolicy.createHTML(''));
|
||||
|
||||
if (editingIndex !== null) {
|
||||
modalTitle.textContent = 'Редактировать человека';
|
||||
@ -534,7 +538,7 @@ function wholeRender(initialData) {
|
||||
|
||||
const tag = document.createElement('div');
|
||||
tag.className = `tag ${type === 'avoid' ? 'tag-red' : 'tag-green'}`;
|
||||
tag.innerHTML = `${text} <span class="tag-close">×</span>`;
|
||||
tag.innerHTML = cartPolicy.createHTML(`${text} <span class="tag-close">×</span>`);
|
||||
tag.querySelector('.tag-close').addEventListener('click', function() {
|
||||
tag.remove();
|
||||
});
|
||||
@ -549,7 +553,7 @@ function wholeRender(initialData) {
|
||||
|
||||
input.addEventListener('input', function() {
|
||||
const val = this.value.toLowerCase();
|
||||
listEl.innerHTML = '';
|
||||
listEl.innerHTML = cartPolicy.createHTML('');
|
||||
|
||||
// Ищем все уже выбранные теги в обеих группах внутри попапа
|
||||
const allSelectedTags = new Set();
|
||||
@ -637,7 +641,7 @@ function wholeRender(initialData) {
|
||||
const toggleBtn = document.getElementById('expand-categories');
|
||||
|
||||
function renderCategories() {
|
||||
categoriesGrid.innerHTML = '';
|
||||
categoriesGrid.innerHTML = cartPolicy.createHTML('');
|
||||
const dataToShow = isCategoriesExpanded ? categories : categories.slice(0, maxVisibleCategories);
|
||||
|
||||
dataToShow.forEach(cat => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user