1// Please see documentation at https://docs.microsoft.com/aspnet/core/client-side/bundling-and-minification 2// for details on configuring this project to bundle and minify static web assets. 3 4// Write your JavaScript code. 5 6 7function Test(newCount, productIds) { 8 $.ajax({ 9 url: "/" + globalLang + "/admin/product/ChangeStorage", 10 method: 'post', 11 data: { count: newCount, productIds } 12 }).done(function (data) { 13 14 let container = document.getElementById('basket-il'); 15 container.innerHTML = ''; 16 if (data.subTotal === 0) { 17 18 let noProductP = document.createElement('p'); 19 noProductP.classList = 'woocommerce-mini-cart__empty-message'; 20 let noProductText = document.createTextNode('No products in the cart.'); 21 noProductP.appendChild(noProductText); 22 23 container.appendChild(noProductP); 24 } 25 else { 26 { 27 const cartListUl = document.createElement('ul'); 28 cartListUl.classList = 'woocommerce-mini-cart cart_list product_list_widget'; 29 30 data.objects.forEach(element => { 31 const cartItemLi = item(element); 32 cartListUl.appendChild(cartItemLi); 33 }); 34 35 container.appendChild(cartListUl); 36 } 37 { 38 39 {//Cart Total P 40 41 const cartTotalP = subTotal(data.subTotal) 42 container.appendChild(cartTotalP); 43 } 44 {//Cart Buttons P 45 46 const cartButtons = buttons(); 47 container.appendChild(cartButtons); 48 } 49 50 } 51 } 52 }) 53} 54 55function buttons() { 56 const cartButtons = document.createElement('p'); 57 cartButtons.classList = 'woocommerce-mini-cart__buttons buttons'; 58 59 { 60 const viewCartA = document.createElement('a'); 61 viewCartA.classList = 'button wc-forward'; 62 63 viewCartAText = document.createTextNode('View cart'); 64 viewCartA.appendChild(viewCartAText); 65 66 viewCartAHref = document.createAttribute('href'); 67 viewCartAHref.value = '/' + globalLang + '/product/cart'; 68 viewCartA.setAttributeNode(viewCartAHref); 69 70 cartButtons.appendChild(viewCartA); 71 } 72 73 { 74 const checkoutCartA = document.createElement('a'); 75 checkoutCartA.classList = 'button checkout wc-forward'; 76 77 checkoutCartAText = document.createTextNode('Checkout'); 78 checkoutCartA.appendChild(checkoutCartAText); 79 80 checkoutCartAHref = document.createAttribute('href'); 81 checkoutCartAHref.value = '/' + globalLang + '/product/checkout'; 82 checkoutCartA.setAttributeNode(checkoutCartAHref); 83 84 cartButtons.appendChild(checkoutCartA); 85 } 86 return cartButtons; 87} 88 89function subTotal(amount) { 90 const cartTotalP = document.createElement('p'); 91 cartTotalP.classList = 'woocommerce-mini-cart__total total'; 92 93 {//Sub Total Strong 94 const subTotalStrong = document.createElement('strong'); 95 const subTotalStrongText = document.createTextNode('Subtotal: '); 96 subTotalStrong.appendChild(subTotalStrongText); 97 98 cartTotalP.appendChild(subTotalStrong); 99 } 100 { 101 //Amount Span 102 const amountSpan = document.createElement('span'); 103 amountSpan.classList = 'woocommerce-Price-amount amount'; 104 105 {//Amount Bdi 106 const amountBdi = document.createElement('bdi'); 107 108 {//Currency Smybol Span 109 const currencySmybolSpan = document.createElement('span'); 110 currencySmybolSpan.classList = 'woocommerce-Price-currencySymbol'; 111 currencySmybolSpanText = document.createTextNode('AZN '); 112 currencySmybolSpan.appendChild(currencySmybolSpanText); 113 amountBdi.appendChild(currencySmybolSpan); 114 115 currencySmybolBdiAmount = document.createTextNode(amount); 116 amountBdi.appendChild(currencySmybolBdiAmount); 117 } 118 119 amountSpan.appendChild(amountBdi); 120 121 } 122 123 cartTotalP.appendChild(amountSpan); 124 } 125 return cartTotalP 126} 127 128function item(element) { 129 {//li 130 console.log('element ', element); 131 const cartItemLi = document.createElement('li'); 132 cartItemLi.classList = 'woocommerce-mini-cart-item mini_cart_item'; 133 134 {//a remove item 135 136 const removeItemA = document.createElement('a'); 137 //remove_from_cart_button 138 139 removeItemA.classList = 'remove'; 140 removeItemA.ariaLabel = 'Remove this item'; 141 removeItemA.dataset.product_id = element.object.id; 142 removeItemA.dataset.cart_item_key = '8'; 143 removeItemA.dataset.product_sku = '8'; 144 removeItemA.href = 'javascript:void(0);'; 145 removeItemA.addEventListener('click', (e) => { 146 e.preventDefault(); 147 148 const currentId = e.target.dataset.product_id; 149 let cart = JSON.parse(localStorage.getItem('cart')); 150 if (cart) { 151 152 var oldItem = cart.find(x => x.id == currentId); 153 var oldCount = oldItem.count; 154 var val = $(".jet-blocks-cart__count-val")[0].innerText; 155 var count = parseInt(val); 156 var newCount = count - oldCount; 157 $(".jet-blocks-cart__count-val")[0].innerText = newCount; 158 159 cart = cart.filter(x => x.id != currentId) 160 localStorage.setItem('cart', JSON.stringify(cart)); 161 162 if (newCount === 0) { 163 $(".widget_shopping_cart").remove(); 164 } 165 //else { 166 // let st = parseInt($(".woocommerce-Price-currencySymbol").val()); 167 // let oldAllAmount = oldItem.object.amount * oldCount; 168 // st -= oldAllAmount; 169 // $(".woocommerce-Price-currencySymbol").val(st); 170 //} 171 172 } 173 174 let pn = e.target.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode; 175 e.target.parentNode.remove(); 176 if (pn.classList.contains('jet-cart-open')) { 177 pn.classList.remove('jet-cart-open') 178 } 179 180 }) 181 182 removeItemAText = document.createTextNode('Ã'); 183 removeItemA.appendChild(removeItemAText); 184 185 cartItemLi.appendChild(removeItemA); 186 } 187 {//a image 188 189 const imageA = document.createElement('a'); 190 imageA.href = `/product/detail/${element.object.id}`; 191 192 {//img 193 194 const thumbnailImg = document.createElement('img'); 195 thumbnailImg.width = 300; 196 thumbnailImg.height = 300; 197 thumbnailImg.src = `/uploads/product/${element.object.photoUrl}`; 198 thumbnailImg.classList = 'attachment-woocommerce_thumbnail size-woocommerce_thumbnail'; 199 thumbnailImg.alt = 'image'; 200 thumbnailImg.loading = 'lazy'; 201 thumbnailImg.srcset = '"/uploads/product/' + element.object.photoUrl + ' 300w, /uploads/product/' + element.object.photoUrl + ' 150w, /uploads/product/' + element.object.photoUrl + ' 360w, /uploads/product/' + element.object.photoUrl + ' 85w, /uploads/product/' + element.object.photoUrl + ' 100w, /uploads/product/' + element.object.photoUrl + ' 58w';
202 thumbnailImg.sizes = '(max-width: 300px) 100vw, 300px'; 203 204 imageA.appendChild(thumbnailImg); 205 } 206 {//text 207 const imageAText = document.createTextNode(element.object.title); 208 209 imageA.appendChild(imageAText); 210 } 211 cartItemLi.appendChild(imageA); 212 } 213 {//span quantity 214 215 const quantitySpan = document.createElement('span'); 216 quantitySpan.classList = 'quantity'; 217 218 {//span text 219 220 const quantitySpanText = document.createTextNode(element.count + 'Ã '); 221 222 quantitySpan.appendChild(quantitySpanText); 223 } 224 {//span amount 225 226 const amountSpan = document.createElement('span'); 227 amountSpan.classList = 'woocommerce-Price-amount amount'; 228 229 {//Amount Bdi 230 const amountBdi = document.createElement('bdi'); 231 232 {//Currency Smybol Span 233 const currencySmybolSpan = document.createElement('span'); 234 currencySmybolSpan.classList = 'woocommerce-Price-currencySymbol'; 235 currencySmybolSpanText = document.createTextNode('AZN '); 236 currencySmybolSpan.appendChild(currencySmybolSpanText); 237 amountBdi.appendChild(currencySmybolSpan); 238 239 currencySmybolBdiAmount = document.createTextNode(element.object.amount); 240 amountBdi.appendChild(currencySmybolBdiAmount); 241 } 242 243 amountSpan.appendChild(amountBdi); 244 245 } 246 247 quantitySpan.appendChild(amountSpan); 248 } 249 250 cartItemLi.appendChild(quantitySpan); 251 } 252 253 return cartItemLi 254 255 } 256}
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.