<script>
document.addEventListener("DOMContentLoaded", function(){
let warrantyPopup = document.querySelector('.uc-warranty-popup');
if(warrantyPopup){
let popupC = warrantyPopup.querySelector('.t390__descr');
popupC.innerHTML = '';
let popupH = warrantyPopup.querySelector('.t-popup').getAttribute('data-tooltip-hook');
let warrantyPopupLink = document.createElement('a');
warrantyPopupLink.href = popupH; warrantyPopupLink.className = "warranty-popup";
warrantyPopup.appendChild(warrantyPopupLink);
let wBtn = document.querySelector('.warranty-btn');
let wForm = document.querySelector('.warranty-form');
function findValue(){
let code = document.querySelector('input[name="warranty"]').value;
let tableNum = document.querySelectorAll('.uc-warranty-table').length;
if(code.length && tableNum>0 ){
let tableLine = document.querySelectorAll('.uc-warranty-table .t431__tbody tr');
for (let i = 0; i < tableLine.length; i++) {
let cont = tableLine[i].querySelectorAll('td');
let trLine = cont;
cont = cont[0].innerText;
warrantyPopupLink.click();
let txtPrint = '';
if(code.toLowerCase()==cont.toLowerCase()){
txtPrint = `Код ПВЗ: ${trLine[0].innerText}<br>
Адрес: ${trLine[1].innerText}<br>
Метро: ${trLine[2].innerText}<br>
Время работы: ${trLine[3].innerText}<br>
`;
popupC.innerHTML = txtPrint;
return false;
}else{
txtPrint = `Данный код отсутствует в базе.<br>
Пожалуйста, проверьте правильность ввода и повторите попытку.
`;
popupC.innerHTML = txtPrint;
};
};
};
};
if(wBtn&&wForm) {
wBtn.addEventListener('click', function() { findValue() });
wForm.addEventListener('keydown', function(event) {
if (event.key === "Enter") {
event.preventDefault();
findValue()
};
});
};
};
});
</script>
<style>
.warranty-btn { cursor: pointer}
/*div.uc-warranty-table { display: none}*/
.uc-warranty-popup .t-popup__close {display: none}
.uc-warranty-popup .t-popup__container:after {
content: "";
background-image: url(https://static.tildacdn.com/tild6432-3463-4365-a337-363436633835/Group_9_1.svg);
background-size: contain;
background-repeat: no-repeat;
width: 25px;
height: 25px;
position: absolute;
top: -40px;
right: 0px;
z-index: 999;
pointer-events: none;
}
</style>