1/* ========================= 2 СТÐÐ ÐÐÐÐÐÐÐ â EmpireG.RU 3 ÐодÑÐ»Ñ v4.1 Ð´Ð»Ñ DLE 19+ 4 ========================= */ 5(function(){ 6 'use strict'; 7 8 // âââ ÐолоÑование на ÑÑÑаниÑе пÑоÑмоÑÑа (Ajax) â новÑй дизайн âââ 9 document.addEventListener('click', function(e) { 10 // ÐбÑабоÑка кнопки "УбÑаÑÑ Ð³Ð¾Ð»Ð¾Ñ" 11 var removeBtn = e.target.closest('.orders-vote-remove'); 12 if (removeBtn) { 13 e.preventDefault(); 14 var wrap = removeBtn.closest('.orders-voting'); 15 if (!wrap) return; 16 var orderId = wrap.getAttribute('data-order-id'); 17 if (!orderId) return; 18 19 removeBtn.disabled = true; 20 21 var formData = new FormData(); 22 formData.append('id', orderId); 23 formData.append('vote', '0'); 24 25 fetch('/orders/vote/', { 26 method: 'POST', 27 body: formData, 28 credentials: 'same-origin' 29 }) 30 .then(function(r){ return r.json(); }) 31 .then(function(data) { 32 if (data.success) { 33 updateViewVoting(wrap, data, null); 34 // СкÑÑваем ÐºÐ½Ð¾Ð¿ÐºÑ ÑбÑаÑÑ Ð³Ð¾Ð»Ð¾Ñ 35 removeBtn.style.display = 'none'; 36 } else { 37 if (data.error) alert(data.error); 38 } 39 }) 40 .catch(function(err) { 41 console.error('Orders remove vote error:', err); 42 }) 43 .finally(function() { 44 removeBtn.disabled = false; 45 }); 46 return; 47 } 48 49 var btn = e.target.closest('.orders-vote'); 50 if (!btn || btn.disabled) return; 51 e.preventDefault(); 52 53 var wrap = btn.closest('.orders-voting'); 54 if (!wrap) return; 55 56 var orderId = wrap.getAttribute('data-order-id'); 57 var vote = btn.getAttribute('data-vote'); 58 if (!orderId || !vote) return; 59 60 var buttons = wrap.querySelectorAll('.orders-vote'); 61 buttons.forEach(function(b){ b.disabled = true; }); 62 63 var formData = new FormData(); 64 formData.append('id', orderId); 65 formData.append('vote', vote); 66 67 fetch('/orders/vote/', { 68 method: 'POST', 69 body: formData, 70 credentials: 'same-origin' 71 }) 72 .then(function(r){ return r.json(); }) 73 .then(function(data) { 74 if (data.success) { 75 var activeVote = (data.action === 'added' || data.action === 'changed') ? vote : null; 76 updateViewVoting(wrap, data, activeVote); 77 78 // ÐоказÑваем/ÑкÑÑваем ÐºÐ½Ð¾Ð¿ÐºÑ ÑбÑаÑÑ Ð³Ð¾Ð»Ð¾Ñ 79 var rmBtn = wrap.querySelector('.orders-vote-remove'); 80 if (rmBtn) { 81 rmBtn.style.display = activeVote ? '' : 'none'; 82 } else if (activeVote) { 83 // СоздаÑм ÐºÐ½Ð¾Ð¿ÐºÑ ÐµÑли ÐµÑ ÐµÑÑ Ð½ÐµÑ 84 var row = wrap.querySelector('.orders-voting__row'); 85 if (row) { 86 var newRmBtn = document.createElement('button'); 87 newRmBtn.className = 'orders-vote-remove'; 88 newRmBtn.setAttribute('data-vote', '0'); 89 newRmBtn.setAttribute('title', 'УбÑаÑÑ Ð³Ð¾Ð»Ð¾Ñ'); 90 newRmBtn.innerHTML = '<i class="fa-solid fa-xmark"></i>'; 91 row.appendChild(newRmBtn); 92 } 93 } 94 } else { 95 if (data.error) alert(data.error); 96 } 97 }) 98 .catch(function(err) { 99 console.error('Orders vote error:', err); 100 }) 101 .finally(function() { 102 buttons.forEach(function(b){ b.disabled = false; }); 103 }); 104 }); 105 106 function updateViewVoting(wrap, data, activeVote) { 107 var upBtn = wrap.querySelector('.orders-vote--up'); 108 var downBtn = wrap.querySelector('.orders-vote--down'); 109 var scoreEl = wrap.querySelector('.orders-voting__score'); 110 var scoreNum = wrap.querySelector('.orders-voting__score-num'); 111 112 if (upBtn) { 113 var upCount = upBtn.querySelector('.orders-vote__count'); 114 if (upCount) upCount.textContent = data.likes; 115 } 116 if (downBtn) { 117 var downCount = downBtn.querySelector('.orders-vote__count'); 118 if (downCount) downCount.textContent = data.dislikes; 119 } 120 if (scoreNum) scoreNum.textContent = data.rating; 121 122 if (upBtn) upBtn.classList.remove('orders-vote--active'); 123 if (downBtn) downBtn.classList.remove('orders-vote--active'); 124 125 if (activeVote === '1' && upBtn) upBtn.classList.add('orders-vote--active'); 126 if (activeVote === '-1' && downBtn) downBtn.classList.add('orders-vote--active'); 127 128 // Update score frame classes 129 if (scoreEl) { 130 scoreEl.classList.remove('orders-rating--pos', 'orders-rating--neg', 'orders-rating--zero'); 131 if (data.rating > 0) scoreEl.classList.add('orders-rating--pos'); 132 else if (data.rating < 0) scoreEl.classList.add('orders-rating--neg'); 133 else scoreEl.classList.add('orders-rating--zero'); 134 } 135 136 wrap.classList.remove('orders-rating--pos', 'orders-rating--neg', 'orders-rating--zero'); 137 if (data.rating > 0) wrap.classList.add('orders-rating--pos'); 138 else if (data.rating < 0) wrap.classList.add('orders-rating--neg'); 139 else wrap.classList.add('orders-rating--zero'); 140 } 141 142 // âââ Ðини-голоÑование в каÑÑоÑÐºÐ°Ñ ÑпиÑка (Ajax) âââ 143 document.addEventListener('click', function(e) { 144 var btn = e.target.closest('.orders-mini-vote'); 145 if (!btn || btn.disabled) return; 146 e.preventDefault(); 147 148 var wrap = btn.closest('.orders-cell-rating'); 149 if (!wrap) return; 150 151 var orderId = wrap.getAttribute('data-order-id'); 152 var vote = btn.getAttribute('data-vote'); 153 if (!orderId || !vote) return; 154 155 var buttons = wrap.querySelectorAll('.orders-mini-vote'); 156 buttons.forEach(function(b){ b.disabled = true; }); 157 158 var formData = new FormData(); 159 formData.append('id', orderId); 160 formData.append('vote', vote); 161 162 fetch('/orders/vote/', { 163 method: 'POST', 164 body: formData, 165 credentials: 'same-origin' 166 }) 167 .then(function(r){ return r.json(); }) 168 .then(function(data) { 169 if (data.success) { 170 var upBtn = wrap.querySelector('.orders-mini-vote--up'); 171 var downBtn = wrap.querySelector('.orders-mini-vote--down'); 172 var ratingEl = wrap.querySelector('.orders-cell-rating__val'); 173 174 if (upBtn) { 175 var upCount = upBtn.querySelector('.mini-vote-count'); 176 if (upCount) upCount.textContent = data.likes; 177 } 178 if (downBtn) { 179 var downCount = downBtn.querySelector('.mini-vote-count'); 180 if (downCount) downCount.textContent = data.dislikes; 181 } 182 if (ratingEl) { 183 ratingEl.textContent = (data.rating > 0 ? '+' : '') + data.rating; 184 ratingEl.className = 'orders-cell-rating__val'; 185 if (data.rating > 0) ratingEl.classList.add('orders-cell-rating__val--pos'); 186 else if (data.rating < 0) ratingEl.classList.add('orders-cell-rating__val--neg'); 187 else ratingEl.classList.add('orders-cell-rating__val--zero'); 188 } 189 190 if (upBtn) upBtn.classList.remove('active'); 191 if (downBtn) downBtn.classList.remove('active'); 192 193 if (data.action === 'added' || data.action === 'changed') { 194 if (vote === '1' && upBtn) upBtn.classList.add('active'); 195 if (vote === '-1' && downBtn) downBtn.classList.add('active'); 196 } 197 } else { 198 if (data.error) alert(data.error); 199 } 200 }) 201 .catch(function(err) { 202 console.error('Orders mini-vote error:', err); 203 }) 204 .finally(function() { 205 buttons.forEach(function(b){ b.disabled = false; }); 206 }); 207 }); 208 209 // âââ ÐеÑеклÑÑение полей ÑоÑÐ¼Ñ Ð¿Ð¾ ÑÐ¸Ð¿Ñ Ð·Ð°ÐºÐ°Ð·Ð° âââ 210 var typeSelect = document.getElementById('orders-type-select'); 211 if (typeSelect) { 212 function toggleFields() { 213 var v = typeSelect.value; 214 document.querySelectorAll('[data-types]').forEach(function(el){ 215 var types = el.getAttribute('data-types').split(','); 216 el.style.display = types.indexOf(v) !== -1 ? '' : 'none'; 217 }); 218 } 219 typeSelect.addEventListener('change', toggleFields); 220 toggleFields(); 221 } 222 223 // âââ Stagger animation for card grid âââ 224 document.querySelectorAll('.orders-row').forEach(function(row, i) { 225 row.style.animationDelay = (i * 0.06) + 's'; 226 }); 227 228})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.