42014202window.tcart.products.forEach(function (product) {4203if (JSON.stringify(product) !== '{}' && product.deleted !== 'yes') {4204products.push(product);4205}4206});42074208return products;4209},42104211/* Checking if the projectId is not set, will try to find it in the DOM */4212updateProjectId: function () {
var that = this; var itemsWithProjectId = [ document.getElementById('allrecords'), document.getElementById('t-header'), document.getElementById('t-footer'), ]; Array.prototype.forEach.call(itemsWithProjectId, function (el) { if (el && !parseInt(that.deliveryState.projectId, 10)) { that.deliveryState.projectId = parseInt(el.getAttribute('data-tilda-project-id'), 10); } }); var el = document.getElementById('tildacopy'); if (el && !parseInt(that.deliveryState.projectId, 10)) { that.deliveryState.projectId = parseInt((el.getAttribute('data-tilda-sign') || '').split('#')[0], 10); } }, /* Checking if the error is a timeout error, it will change the endpoint to `2.tildacdn.com` */ endpointDelivery: '.tildacdn.com', changeEndpoint: function (error, onChangeCallback, onErrorCallback) { var that = this; if ( typeof error === 'object' && (error.status >= 500 || error.status == 408 || error.status == 410 || error.status == 429 || error.isTimeout) && that.endpointDelivery === '.tildacdn.com' ) { that.endpointDelivery = '2.tildacdn.com'; if (typeof onChangeCallback === 'function') { onChangeCallback(); } } else { if (error && error.responseText) { console.error('[' + error.status + '] ' + error.responseText + '. Please, try again later.'); } else if (error && error.statusText) { console.error('Error [' + error.status + ', ' + error.statusText + ']. Please, try again later.'); } else if (error && error.status) { console.error('[' + error.status + '] Unknown error. Please, try again later.'); } else { console.error('Unknown error. Please, try again later.'); } if (typeof onErrorCallback === 'function') { onErrorCallback(); } } },};/* Show and hide error messages */window.tcart__errorHandler = { show: function (error) { var errorBoxes = document.querySelectorAll('.t706 .js-errorbox-all'); var errorBoxString = document.querySelectorAll('.t706 .t-form__errorbox-item.js-rule-error-string'); // fill new text if (error) { Array.prototype.forEach.call(errorBoxString, function (stringEl) { stringEl.innerHTML = error; }); } // show old text too Array.prototype.forEach.call(errorBoxString, function (stringEl) { if (stringEl.textContent !== '') { stringEl.style.display = 'block'; Array.prototype.forEach.call(errorBoxes, function (errorBoxEl) { if (errorBoxEl) { errorBoxEl.style.display = ''; } }); } }); }, hide: function () { var errorBoxes = document.querySelectorAll('.t706 .js-errorbox-all'); var errorBoxString = document.querySelectorAll('.t706 .t-form__errorbox-item.js-rule-error-string'); Array.prototype.forEach.call(errorBoxes, function (errorBoxEl) { if (errorBoxEl) { errorBoxEl.style.display = 'none'; } });