1'use strict'; 2// console.log('Script.js Loaded!'); 3var IS_SHOP = location.href === (location.origin + '/shop/'); 4var elHeader = document.querySelector('header.main-header'); 5var elHeaderMenu = document.querySelector('header.main-header .header-categories-block'); 6var elHeaderLinksBlock = document.querySelector('header.main-header .header-links-block'); 7var elVariableOutOfStock = document.querySelectorAll('p.stock.out-of-stock.variable-out-of-stock'); 8var elCopyBillingDataBtns = document.querySelectorAll('td.copy-data button.copy-user-billing-data'); 9var elTransalteBtns = document.querySelectorAll('header .switcher .option a.nturl'); 10var elNotesPopup = document.querySelector('#popup-notes-for-customers'); 11var elChooseCompany = document.querySelector('form.checkout .choose-company'); 12var elVariationsForms = document.querySelectorAll('.product form.variations_form.cart'); 13var LAST_SCROLL_Y = 0; 14var elNewCustomSearchForms = document.querySelectorAll('.new-custom-search-form'); 15var ADMIN_AJAX_URL = location.origin + '/wp-admin/admin-ajax.php'; 16var MAX_MOBILE_SIZE = 1180; 17var IS_MOBILE = (window.innerWidth > MAX_MOBILE_SIZE)? false: true; 18var search_timeout; 19 20(function() { 21 22 document.addEventListener("DOMContentLoaded", function () { 23 updateCountdown(); 24 }); 25 26 jQuery('form.woocommerce-checkout').on( 'change', 'input#add_gift_box', function() { 27 jQuery('body').trigger('update_checkout'); 28 }); 29 30 /* ש×× ×.פ - ספר×ת ××××, ×¢× 9. 31 ××××× ×-input (××× ×-keypress) ××× ×תפ×ס ×× ××××§× ×××××× ×××××××, 32 ×××××צ×× ×-document ×× ×ש×× ×ר×× ×ר ×××ש ×¢"× ×××§××רס. 33 ×× ××× ×ª UI ×××× - ×××××¤× ××× ××××××צ×× ××¦× ×שרת. */ 34 jQuery(document).on('input', '#billing_company_id', function() { 35 var digits = this.value.replace(/\D/g, '').slice(0, 9); 36 if (this.value !== digits) this.value = digits; 37 }); 38 39 Init(); 40 if(!IS_SHOP) { 41 var LoadMoreProductsAssets = document.querySelectorAll('link[href*="load-more-products-for-woocommerce"], script[src*="load-more-products-for-woocommerce"]'); 42 if(LoadMoreProductsAssets) { 43 LoadMoreProductsAssets.forEach(function(asset) { 44 asset.parentElement.removeChild(asset); 45 }) 46 } 47 } 48 49 if(elHeader) { 50 var headerHeight = elHeader.offsetHeight; 51 window.addEventListener('scroll', function() { 52 if(window.scrollY >= headerHeight) { 53 document.body.style.marginTop = headerHeight + 'px'; 54 elHeader.classList.add('sticky-header'); 55 if(LAST_SCROLL_Y > window.scrollY) elHeader.classList.add('header-show'); 56 else elHeader.classList.remove('header-show'); 57 } else { 58 document.body.style.marginTop = '0px'; 59 elHeader.classList.remove('header-show'); 60 elHeader.classList.remove('sticky-header'); 61 } 62 LAST_SCROLL_Y = window.scrollY; 63 }); 64 65 var elPrimaryMain = document.querySelector('main#primary'); 66 if(elPrimaryMain) { 67 var windowHeight = window.innerHeight; 68 var elFooter = document.querySelector('footer'); 69 if(elFooter) elPrimaryMain.style.minHeight = (windowHeight - elFooter.offsetHeight - elHeader.offsetHeight) + 'px'; 70 else elPrimaryMain.style.minHeight = (windowHeight - elHeader.offsetHeight) + 'px'; 71 } 72 if(elHeaderLinksBlock) { 73 var elHeaderLinksBlockItems = elHeaderLinksBlock.querySelectorAll('ul#menu-sub-header-menu > li'); 74 if(elHeaderLinksBlockItems) { 75 var previousTop = 0; 76 elHeaderLinksBlockItems.forEach(function(child, index) { 77 var childTop = child.getBoundingClientRect().top; 78 if (index === 0 || childTop !== previousTop) { 79 child.classList.add('first-in-row'); 80 previousTop = childTop; 81 } 82 }); 83 } 84 } 85 } 86 87 if(elNewCustomSearchForms) {
88 elNewCustomSearchForms.forEach(function(elNewCustomSearchForm) { 89 var elSearchFeild = elNewCustomSearchForm.querySelector('form input#global-search'); 90 var elAutoComplateSearchProducts = elNewCustomSearchForm.querySelector('form .autocomplete-products'); 91 if(elSearchFeild && elAutoComplateSearchProducts) { 92 elSearchFeild.addEventListener('input', function(e) { 93 if (search_timeout != undefined) clearTimeout(search_timeout); 94 e.preventDefault(false); 95 var search_value = elSearchFeild.value; 96 if(search_value.length > 2) { 97 search_timeout = setTimeout(function() { 98 fetch('/wp-json/orema10/v1/search-products/get-products/', { 99 method: 'POST', 100 headers: {'Content-Type': 'application/json'}, 101 body: JSON.stringify({s: search_value, get_tags: true, get_cats: true, get_brands: true}), 102 }) 103 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 104 .then(data => { 105 var TextHTML = "<ul>"; 106 var productsCount = 0; 107 108 if(data.tags.length) {
109 data.tags.forEach(function(tag) { 110 if(tag.products_count > 0) { 111 TextHTML += '<li class="tag" data-term-id="' + tag.term_id + '">'; 112 TextHTML += '<a class="tag-link-container" href="' + tag.term_link + '">'; 113 TextHTML += '<p class="tag-title">ת××ת: ' + tag.term_name + '</p>'; 114 TextHTML += '</a>'; 115 TextHTML += '</li>'; 116 } 117 }); 118 119 productsCount++; 120 } 121 122 if(data.cats.length) { 123 data.cats.forEach(function(cat) { 124 if(cat.products_count > 0) { 125 TextHTML += '<li class="tag category" data-term-id="' + cat.term_id + '">'; 126 TextHTML += '<a class="tag-link-container" href="' + cat.term_link + '">'; 127 // TextHTML +='<div class="product-img"><img src="' + cat.term_image + '" /></div>'; 128 TextHTML += '<p class="tag-title">×§×××ר××: ' + cat.term_name + '</p>'; 129 TextHTML += '</a>'; 130 TextHTML += '</li>'; 131 } 132 }); 133 134 productsCount++; 135 } 136 137 if(data.brands.length) { 138 data.brands.forEach(function(brand) { 139 if(brand.products_count > 0) { 140 TextHTML += '<li class="tag brand" data-term-id="' + brand.term_id + '">'; 141 TextHTML += '<a class="tag-link-container" href="' + brand.term_link + '">'; 142 // TextHTML +='<div class="product-img"><img src="' + cat.term_image + '" /></div>'; 143 TextHTML += '<p class="tag-title">××ת×: ' + brand.term_name + '</p>'; 144 TextHTML += '</a>'; 145 TextHTML += '</li>'; 146 } 147 }); 148 149 productsCount++; 150 } 151 152 if(data.products.length) { 153 data.products.forEach(function(product) { 154 if(productsCount >= 8) return; 155 if(product.product_visible === 'visible' || WP_User_Role === 'admin') { 156 TextHTML += '<li class="product" data-product-id="' + product.product_id + '">'; 157 TextHTML += '<a class="product-link-container" href="' + product.link + '">'; 158 TextHTML +='<div class="product-img">' + product.product_image + '</div>'; 159 TextHTML += '<p class="product-title">' + product.product_title + ((product.product_subtitle)? ' - ' + product.product_subtitle: '') + '</p>'; 160 TextHTML += '</a>'; 161 TextHTML += '</li>'; 162 productsCount++; 163 } 164 }); 165 } 166 167 if(!productsCount) { 168 TextHTML += '<li><p class="not-results">×× × ×צ×× ×ª×צ××ת</p></li>'; 169 } else if (data.products.length > 8) { 170 TextHTML += '<li><button>××× ×××צר×× .... (' + data.products.length + ')</button></li>'; 171 } 172 TextHTML += "</ul>"; 173 elAutoComplateSearchProducts.innerHTML = TextHTML; 174 }) 175 .catch(error => { 176 console.error('Error:', error); 177 // alert(error); 178 }); 179 }, 500); 180 } else { 181 elAutoComplateSearchProducts.innerHTML = ""; 182 } 183 }) 184 } 185 }) 186 } 187 188 if(elVariableOutOfStock) { 189 elVariableOutOfStock.forEach(function(item) { 190 var id = item.getAttribute('data-product-id'); 191 var elCurrentAboveElement = document.querySelector('li.product.type-product.post-' + id); 192 var elProductPage = document.querySelector('.single-product div.product#product-' + id); 193 if (elCurrentAboveElement) { 194 var elMoreOptionBtn = elCurrentAboveElement.querySelector('.button'); 195 if (elMoreOptionBtn) { 196 elMoreOptionBtn.style.display = 'none'; 197 } 198 } else if (elProductPage) { 199 var elSingleVariationWrap = elProductPage.querySelector('.woocommerce-variation-add-to-cart'); 200 if (elSingleVariationWrap) { 201 elSingleVariationWrap.style.display = 'none'; 202 } 203 } 204 }) 205 } 206 207 if(elCopyBillingDataBtns) {
208 elCopyBillingDataBtns.forEach(function(btn) { 209 btn.addEventListener('click', function(e) { 210 e.preventDefault(false); 211 SetBillingData(btn); 212 }) 213 }) 214 } 215 216 if(elTransalteBtns) { 217 elTransalteBtns.forEach(function(btn) { 218 btn.addEventListener('click', function(e) { 219 e.preventDefault(false); 220 var lang = 'iw|' + btn.querySelector('img').alt; 221 doGTranslate(lang); 222 }) 223 }) 224 } 225 226 if(elNotesPopup) { 227 elNotesPopup.querySelector('.close-notes-popup').addEventListener('click', function(e) { 228 e.preventDefault(false); 229 elNotesPopup.classList.remove('open'); 230 }); 231 } 232 233 if(elChooseCompany) { 234 var elCompaniesSelect = elChooseCompany.querySelector('select'); 235 if(elCompaniesSelect) { 236 var elSearchCompany = elChooseCompany.querySelector('input[name=company]'); 237 if(elSearchCompany) { 238 var elCopamyAutoComplete = elChooseCompany.querySelector('.company-autocomplete'); 239 elSearchCompany.addEventListener('input', function(e) { 240 elCopamyAutoComplete.innerHTML = ""; 241 elCopamyAutoComplete.style.visibility = 'hidden'; 242 var value = elSearchCompany.value; 243 if(value) { 244 elCompaniesSelect.querySelectorAll('option').forEach(function(option) { 245 if(option.innerText.includes(value)) { 246 if(WP_User_Role === 'agent' || WP_User_Role === 'shop_agent' || WP_User_Role === 'web_agent') { 247 var CUSTNAME = option.value; 248 if(CUSTNAME) { 249 elCopamyAutoComplete.innerHTML += '<div class="option" onclick="placeCostomerForOrder(this, ' + CUSTNAME + ')">' + option.innerText + '</div>'; 250 } 251 } /*else { 252 elCopamyAutoComplete.innerHTML += '<div class="option" onclick="placeCompany(this)">' + option.innerText + '</div>'; 253 }*/ 254 elCopamyAutoComplete.style.visibility = 'visible'; 255 } 256 }) 257 } 258 259 }); 260 } 261 } 262 } 263 264 if (document.body.classList.contains('single-product')) { 265 var product_id = document.body.className.match(/postid-(\d+)/)[1]; 266 if(product_id) { 267 fetch('/wp-json/orema10/v1/product-views/update-views-count/', { 268 method: 'POST', 269 headers: {'Content-Type': 'application/json'}, 270 body: JSON.stringify({product_id}), 271 }) 272 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 273 .then(data => { 274 // console.log(data); 275 }) 276 .catch(error => { 277 // console.error('Error:', error); 278 }); 279 } 280 } 281 282 /* Claude Save Old Version */ 283 // var max = jQuery('form.checkout #check-calendar').attr('max'); 284 // if(max) { 285 // var checkout_form = jQuery('form.checkout'); 286 // checkout_form.on('checkout_place_order', function () { 287 // var checkDate = jQuery('form.checkout #check-calendar').val(); 288 // if(checkDate) { 289 // if(checkDate > max) { 290 // var maxDateDisplay = max.split('-').reverse().join('/'); 291 // alert('××קס×××× ×ת×ר×× ×©××§ ××× ×ת×ר××: ' + maxDateDisplay); 292 // return false; 293 // } 294 // } 295 // 296 // return true; 297 // }); 298 // } 299 300 /* 301 * ××¨×¡× ×××©× - ×©× × ×ª××§×× ××: 302 * 303 * 1) ×-max × ×§×¨× ×¤×¢× ××ת ×××¢×× ×ª ××¢×××. ×××ר ×תש××× ×ר×× ×ר ×××ש ××× 304 * update_order_review (AJAX), ×××× ×× ×©××ת ×תש××× "ש××§" ×× ××××ª× × ××רת 305 * ×××¢×× × ×ר×ש×× × - ×-handler ×××× ×× × ×¨×©× ××× ××××ª× ×©×× ×××קת ת×ר××. 306 * ×¢×ש×× ×-handler × ×¨×©× ×ª×××, ××§××¨× ×ת ×-max ×ר××¢ ×ש××××. 307 * 308 * 2) ש×××ש ×-stopImmediatePropagation ××× ××××× ×©×ש×ש×××× ×××××ת, 309 * handlers ××ר×× ×¢× ×××ª× ××ר××¢ ×× ××ש××× ×ר××¥ (××¢×קר ×× ×©×ש××ת ×ת 310 * ×פת×ר "ש×××ת ×××× ×" ××ש××ר ×××ª× ×ª×§××¢ ×¢× "ש××× ×××× ×..."). 311 */ 312 jQuery('form.checkout').on('checkout_place_order', function (e) { 313 var elCalendar = jQuery('form.checkout #check-calendar'); 314 if(!elCalendar.length) return true; 315 316 var max = elCalendar.attr('max');
317 var checkDate = elCalendar.val(); 318 319 if(max && checkDate && checkDate > max) { 320 var maxDateDisplay = max.split('-').reverse().join('/'); 321 alert('××קס×××× ×ת×ר×× ×©××§ ××× ×ת×ר××: ' + maxDateDisplay); 322 e.stopImmediatePropagation(); 323 return false; 324 } 325 326 return true; 327 }); 328})(); 329 330function Init() { 331 InitLoopProductGallery(); 332 var products = document.querySelectorAll('.product'); 333 if (products) { 334 products.forEach(function(product) { 335 var post_id = GetProductIDByClassList(product); 336 var elVariationForm = product.querySelector(".variations_form"); 337 if (elVariationForm) { 338 var elProductImage = product.querySelector('a img') ? product.querySelector('a img'): product.querySelector('td.product-img img'); 339 var variations = JSON.parse(elVariationForm.getAttribute("data-product_variations")); 340 if (variations) { 341 var elVariationsSelect = elVariationForm.querySelector('select.woo-variation-raw-select'); 342 if(elVariationsSelect) { 343 var currentSelectAttribute = 'attribute_' + elVariationsSelect.id; 344 elVariationsSelect.addEventListener('change', function(e) { 345 var value = elVariationsSelect.value; 346 var currentVariation = variations.find(function (variation) { return variation.attributes[currentSelectAttribute] === value }); 347 if(currentVariation) { 348 var elProductPrice = product.querySelector('span.price'); 349 if(elProductPrice) elProductPrice.innerHTML = currentVariation.price_html; 350 } 351 }); 352 } 353 } 354 355 var elResetVariations = product.querySelector('a.reset_variations'); 356 if (elResetVariations) { 357 elResetVariations.addEventListener('click', function() { 358 var dataOldSRC = product.getAttribute('data-old-src'); 359 if (dataOldSRC) { 360 elProductImage.src = dataOldSRC; 361 } 362 363 elVariationForm.querySelector('.quantity').classList.remove('selected'); 364 }) 365 } 366 } 367 368 if(post_id) { 369 var elNewPriceField = product.querySelector('input[name="new_price"][id="new_price_' + post_id + '"]'); 370 if(elNewPriceField) { 371 ChangePriceByNewPrice(product, elNewPriceField); 372 elNewPriceField.addEventListener('change', function() { 373 ChangePriceByNewPrice(product, elNewPriceField); 374 }) 375 } 376 } 377 }); 378 } 379} 380 381function openStockBtns(btn) { 382 var elDisplayStockBtns = btn.parentElement; 383 var elTheStockBtns = elDisplayStockBtns.querySelector('.the-stock-btns'); 384 if(elTheStockBtns) { 385 if(elDisplayStockBtns.classList.contains('open')) { 386 elTheStockBtns.style.height = '0px'; 387 elDisplayStockBtns.classList.remove('open') 388 } else { 389 var elStockBtnsContainer = elTheStockBtns.querySelector('.the-stock-btns-container'); 390 if(elStockBtnsContainer) { 391 elTheStockBtns.style.height = elStockBtnsContainer.offsetHeight + 'px'; 392 elDisplayStockBtns.classList.add('open') 393 } 394 } 395 } 396} 397 398function placeCompany(option) { 399 if(confirm('××× ×××§×× ×©××רת ×××: ' + option.innerText)) { 400 var elSearchCompany = elChooseCompany.querySelector('input[name=company]'); 401 var elCopamyAutoComplete = elChooseCompany.querySelector('.company-autocomplete'); 402 elSearchCompany.value = option.innerText; 403 elCopamyAutoComplete.innerHTML = ""; 404 setTimeout(function() { 405 var elCompaniesSelect = elChooseCompany.querySelector('select'); 406 var currentCompamy = elSearchCompany.value; 407 var orderID = Array.from(elCompaniesSelect.querySelectorAll('option')).filter(function(option) { return option.innerText === currentCompamy })[0].value; 408 if(orderID) setOrderDetails(orderID, true); 409 410 }, 500); 411 } 412} 413 414function placeCostomerForOrder(option, customer) { 415 if(customer) { 416 if(confirm('××× ×××§×× ×©××רת ×××: ' + option.innerText)) { 417 setCustomerToAgentOrder(customer); 418 } 419 } 420} 421
422function GetProductIDByClassList(product) { 423 var post_id = null; 424 product.classList.forEach(function(c) { 425 if(c.includes('post-')) { 426 post_id = c.replace('post-', ''); 427 } 428 }); 429 430 return post_id; 431} 432 433function ChangePriceByNewPrice(elProduct, elNewPriceField) { 434 var newPrice = +elNewPriceField.value; 435 if(newPrice) elNewPriceField.setAttribute('data-new-price', newPrice); 436 var elPrice = elProduct.querySelector('span.price'); 437 var currentPrice = (newPrice)? (newPrice).toLocaleString('he-IL', {style: 'currency', currency: 'ILS'}): null; 438 var dataOriginalPrice = (+elNewPriceField.getAttribute('data-regular-price')).toLocaleString('he-IL', {style: 'currency', currency: 'ILS'}); 439 if(currentPrice) SetNewPriceToProduct('change-price', elPrice, currentPrice, dataOriginalPrice); 440 else SetNewPriceToProduct('change-price', elPrice, dataOriginalPrice); 441} 442 443function CheckIfNewPriceIsGood(data) { 444 var isGoodPrice = true; 445 if(data.new_price) { 446 var elPrice = document.querySelector('.product.post-' + data.product_id + ' span.price'); 447 var isSalePrice = elPrice.querySelector('ins'); 448 var price = isSalePrice? Number(isSalePrice.innerText.replace('âª', '')): Number(elPrice.innerText.replace('âª', '')); 449 var MinimumPrice = Math.round(price * 0.85); 450 if(+data.new_price < MinimumPrice) isGoodPrice = false; 451 } 452 453 return isGoodPrice; 454} 455 456function GetQtyGlobalParent(item) { 457 var elItem = item; 458 while(!elItem.classList.toString().includes('product type-product')) { 459 elItem = elItem.parentNode; 460 } 461 462 return elItem; 463} 464 465function GetGlobalParentByTag(item, tag) { 466 tag = tag.toUpperCase(); 467 var elItem = item; 468 while(elItem.tagName !== tag) { 469 elItem = elItem.parentNode; 470 } 471 472 return elItem; 473} 474 475// function GetGlobalParentByTagAndClass(item, tag, class_name) { 476// tag = tag.toUpperCase(); 477// var elItem = item; 478// while(elItem.tagName !== tag || !elItem.classList.contains(class_name)) { 479// elItem = elItem.parentNode; 480// } 481 482// return elItem; 483// } 484 485function GetGlobalParentByTagAndClass(item, tag, class_name) { 486 tag = tag.toUpperCase(); 487 var elItem = item; 488 489 while (elItem !== null && elItem.tagName !== tag || elItem !== null && !elItem.classList.contains(class_name)) { 490 elItem = elItem.parentNode; 491 if (elItem === null) return null; 492 493 } 494 495 return elItem; 496} 497 498function GetGlobalParentByTagAndID(item, tag, id) { 499 tag = tag.toUpperCase(); 500 var elItem = item; 501 while(elItem.tagName !== tag || !elItem.id.includes(id)) { 502 elItem = elItem.parentNode; 503 } 504 505 return elItem; 506} 507 508function InitLoopProductGallery() { 509 var elProductsGalley = document.querySelectorAll('.custom-product-gallery.in-loop'); 510 if(elProductsGalley) { 511 elProductsGalley.forEach(function(gallery) { 512 var elMainProductImg = gallery.closest('.single-product-container')?.querySelector('img.wp-post-image'); 513 if(!elMainProductImg) elMainProductImg = gallery.parentNode.querySelector('img.attachment-woocommerce_thumbnail'); 514 if(elMainProductImg) { 515 var elGalleryItems = gallery.querySelectorAll('li'); 516 if(elGalleryItems) { 517 elGalleryItems.forEach(function(galleryItem) { 518 galleryItem.addEventListener('click', function(e) { 519 e.preventDefault(false); 520 var currentImg = galleryItem.querySelector('img'); 521 if(currentImg) { 522 var currentImgSRC = currentImg.src; 523 if(currentImgSRC) { 524 var elGalleryActiveItem = gallery.querySelector('li.active'); 525 if(elGalleryActiveItem) elGalleryActiveItem.classList.remove('active'); 526 galleryItem.classList.add('active'); 527 elMainProductImg.src = currentImgSRC; 528 } 529 } 530 }) 531 }) 532 } 533 } 534 }) 535 } 536} 537 538function GetAttributeColorName(color) { 539 switch(color) { 540 case 'pack-4': return '×××¨× ×©× 4 ×××××ת'; 541 case 'pack-5': return '×××¨× ×©× 5 ×××××ת'; 542 case 'pack-6': return '×××¨× ×©× 6 ×××××ת'; 543 default: return decodeURI(color); 544 } 545} 546 547function addMsgToMsgList(msg, bg = null, color = null) { 548 var elWoocommerceCartMessageList = document.querySelector('ul.woocommerce-cart-message-list'); 549 if (elWoocommerceCartMessageList) { 550 var elLiUpdate = document.createElement('li'); 551 elLiUpdate.innerHTML = msg; 552 if(bg) elLiUpdate.style.backgroundColor = bg; 553 if(color) elLiUpdate.style.color = color; 554 555 elWoocommerceCartMessageList.appendChild(elLiUpdate); 556 } 557 558 setTimeout(function() { 559 elLiUpdate.classList.add('hide'); 560 }, 2500); 561 562 setTimeout(function() { 563 elWoocommerceCartMessageList.removeChild(elLiUpdate); 564 }, 2500); 565} 566 567function clearPhoneNumber(phoneNumber) { 568 return phoneNumber.toString().replace(/[- )(]/g, ""); 569} 570 571function isValidIsraeliID(id) { 572 id = String(id).trim(); 573 if (id.length < 5 || id.length > 9 || isNaN(id)) return false;
574 575 id = id.padStart(9, '0'); 576 577 return Array.from(id, Number).reduce(function (counter, digit, i) { 578 var step = digit * ((i % 2) + 1); 579 return counter + (step > 9 ? step - 9 : step); 580 }, 0) % 10 === 0; 581} 582 583function openBarcode(elOpenBarcodeLink) { 584 var isOpen = elOpenBarcodeLink.classList.contains('open'); 585 var elBarcodeConatiner = elOpenBarcodeLink.parentElement.querySelector('.barcode-container'); 586 if(elBarcodeConatiner) { 587 if(isOpen) { 588 elBarcodeConatiner.style.height = '0px'; 589 } else { 590 var elBarcodeImageConatiner = elBarcodeConatiner.querySelector('.barcode-img-container'); 591 if(elBarcodeImageConatiner) { 592 elBarcodeConatiner.style.height = elBarcodeImageConatiner.offsetHeight + 'px'; 593 } 594 } 595 elOpenBarcodeLink.classList.toggle('open'); 596 } 597} 598 599 600function checkIfIsObject(item) { 601 return (typeof item == 'object' && !Array.isArray(item)); 602} 603 604function checkIfIsArray(item) { 605 return (typeof item == 'object' && Array.isArray(item)); 606} 607 608function changeBarcode(barcodeDetails) { 609 var elProductMeta = document.querySelector('.product_meta'); 610 if(elProductMeta) { 611 var isBarcodeWrapper = elProductMeta.querySelector('.barcode_wrapper'); 612 if(isBarcodeWrapper) { 613 var barcode_text = isBarcodeWrapper.querySelector('span.the_barcode'); 614 barcode_text.innerHTML = `${barcodeDetails.barcode} <b>(${barcodeDetails.format})</b>`; 615 var barcode_img = isBarcodeWrapper.querySelector('img'); 616 barcode_img.src = `${location.origin}/wp-content/themes/allphone/systems/Barcode/Image/barcode.php?format=${barcodeDetails.format}&barcode=${barcodeDetails.barcode}`; 617 } else { 618 elProductMeta.innerHTML += 619 `<div class="barcode_wrapper">×רק××: <span class="barcode"><span class="the_barcode">${barcodeDetails.barcode} <b>(${barcodeDetails.format})</b></span></span> 620 <a class="barcode-link" onclick="openBarcode(this)">××¦× ×ª××× ×ª ×רק×× <i></i></a> 621 <div class="barcode-container"> 622 <div class="barcode-img-container"> 623 <img src="${location.origin}/wp-content/themes/allphone/systems/Barcode/Image/barcode.php?format=${barcodeDetails.format}&barcode=${barcodeDetails.barcode}"> 624 </div> 625 </div> 626 </div>`; 627 } 628 } 629} 630 631function BackToStockAlert(btn) { 632 var product_id = btn.getAttribute('data-product-id'); 633 console.log(product_id) 634 if(product_id) { 635 if(!btn.classList.contains('alerted')) { 636 fetch('/wp-json/orema10/v1/whatsapp/back-alert/', { 637 method: 'POST', 638 headers: {'Content-Type': 'application/json'}, 639 body: JSON.stringify({product_id}), 640 }) 641 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 642 .then(data => { 643 // console.log(data); 644 btn.classList.add('alerted'); 645 var elText = btn.querySelector('span'); 646 elText.innerHTML = elText.getAttribute('data-alerted-desc'); 647 // btn.parentElement.setAttribute('data-desc', btn.parentElement.getAttribute('data-alerted-desc')); 648 }) 649 .catch(error => { 650 console.error('Error:', error); 651 // alert(error); 652 }); 653 } 654 } 655} 656 657function Load3DModels(model) { 658 var scene = new THREE.Scene(); 659 scene.background = new THREE.Color(0xdddddd); 660 var camera = new THREE.PerspectiveCamera(40, window.innerWidth/window.innerHeight, 1, 5000); 661 camera.rotation.y = 45 / 180 * Math.PI; 662 camera.position.x = 800; 663 camera.position.y = 100; 664 camera.position.z = 1000; 665 666 var renderer = new THREE.WebGLRenderer({antialias:true}); 667 renderer.setSize(window.innerWidth,window.innerHeight); 668 document.body.appendChild(renderer.domElement); 669 670 var hlight = new THREE.AmbientLight (0x404040, 100); 671 scene.add(hlight); 672 673 var directionalLight = new THREE.DirectionalLight(0xffffff, 100); 674 directionalLight.position.set(0, 1, 0); 675 directionalLight.castShadow = true; 676 scene.add(directionalLight); 677 678 var light = new THREE.PointLight(0xc4c4c4, 10); 679 light.position.set(0, 300, 500); 680 scene.add(light); 681 682 var light2 = new THREE.PointLight(0xc4c4c4, 10); 683 light2.position.set(500, 100, 0); 684 scene.add(light2); 685 686 var light3 = new THREE.PointLight(0xc4c4c4, 10); 687 light3.position.set(0, 100, -500); 688 scene.add(light3); 689 690 var light4 = new THREE.PointLight(0xc4c4c4, 10); 691 light4.position.set(-500, 300, 500); 692 scene.add(light4); 693 694 var loader = new THREE.GLTFLoader(); 695 loader.load(model, function(gltf) { 696 var car = gltf.scene.children[0]; 697 car.scale.set(0.5,0.5,0.5); 698 scene.add(gltf.scene); 699 animate(renderer, scene, camera); 700 }); 701 702 var controls = new THREE.OrbitControls(camera); 703 controls.addEventListener('change', renderer); 704} 705 706function animate(renderer, scene, camera) { 707 renderer.render(scene,camera); 708 requestAnimationFrame(animate); 709} 710 711function GetSelectedOption(select) { 712 return Array.from(select.querySelectorAll('option')).find(opt => opt.value === select.value); 713} 714 715function SetNewPriceToProduct(action, elPrice, newPrice, oldPrice) { 716 if(elPrice) { 717 if(newPrice && oldPrice) { 718 var textHTML = ''; 719 if(action === 'change-price') textHTML += `<i class="change-price-alert">ש×× ×× ×××ר</i>`; 720 textHTML += `<del aria-hidden="true">
721 <span class="woocommerce-Price-amount amount"> 722 <bdi>${oldPrice}</bdi> 723 </span> 724 </del> 725 <ins> 726 <span class="woocommerce-Price-amount amount"> 727 <bdi>${newPrice}</bdi> 728 </span> 729 </ins>`; 730 elPrice.innerHTML = textHTML; 731 } else if(newPrice) { 732 elPrice.innerHTML = `<span class="price"><span class="woocommerce-Price-amount amount"><bdi>${newPrice}</bdi></span></span>`; 733 } 734 } 735} 736 737function AddToCartAnimation(product_id) { 738 var elCart = document.querySelector('header .new-cart .cart img'); 739 if(elCart) { 740 var Rect = elCart.getBoundingClientRect(); 741 var elProduct = document.querySelector('.product.post-' + product_id); 742 if(elProduct) { 743 var elProductImg = elProduct.querySelector('img.attachment-woocommerce_thumbnail'); 744 if(elProductImg) { 745 var elProductImgSRC = elProductImg.src; 746 if(elProductImgSRC) { 747 var ProductImgRect = elProductImg.getBoundingClientRect(); 748 var newAnimationImg = document.createElement('img'); 749 newAnimationImg.src = elProductImgSRC; 750 newAnimationImg.setAttribute('class', elProductImg.getAttribute('class')); 751 newAnimationImg.classList.add('add-to-cart-animation-img'); 752 newAnimationImg.style.width = elProductImg.clientWidth; 753 newAnimationImg.style.position = 'fixed'; 754 newAnimationImg.style.top = ProductImgRect.top; 755 newAnimationImg.style.left = ProductImgRect.left; 756 elProductImg.parentNode.appendChild(newAnimationImg); 757 setTimeout(function() { 758 newAnimationImg.classList.add('to-cart'); 759 newAnimationImg.style.top = Rect.top; 760 newAnimationImg.style.left = Rect.left; 761 newAnimationImg.style.height = '40px'; 762 }, 100); 763 setTimeout(function() { 764 elProductImg.parentNode.removeChild(newAnimationImg); 765 }, 780); 766 } 767 } 768 } 769 } 770} 771 772function openYouTubePopUp(el) { 773 var videoID = el.getAttribute('data-video-id'); 774 var elYouTubePopup = document.querySelector('.youtube-popup'); 775 if(elYouTubePopup) { 776 var elYouTubePopupContainer = elYouTubePopup.querySelector('.youtube-video-container'); 777 if(elYouTubePopupContainer) { 778 elYouTubePopupContainer.innerHTML = '<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/' + videoID + '" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>'; 779 elYouTubePopup.classList.add('show'); 780 } 781 } 782} 783 784function openImagePopup(btn, e) { 785 e.preventDefault(false); 786 var elZoomImagePopup = document.querySelector('.zoomimage-popup'); 787 if(elZoomImagePopup) { 788 var elZoomImagePopupContainer = elZoomImagePopup.querySelector('.zoomimage-container'); 789 if(elZoomImagePopupContainer) { 790 var elImage = btn.parentNode.querySelector('img'); 791 if(elImage) { 792 var src = elImage.src; 793 if(src) { 794 elZoomImagePopupContainer.innerHTML = `<img class="zoomimage-current-img" src="${src}" />`; 795 elZoomImagePopup.classList.add('show'); 796 } 797 } 798 } 799 } 800} 801 802function openVideoPopUp(el) { 803 var videoLink = el.getAttribute('data-video-link'); 804 var elVideoPopup = document.querySelector('.video-popup'); 805 if(elVideoPopup) { 806 var elVideoPopupContainer = elVideoPopup.querySelector('.video-container'); 807 if(elVideoPopupContainer) { 808 elVideoPopupContainer.innerHTML = `<video width="560" height="315" controls autoplay playsinline> 809 <source src="${videoLink}
809" type="video/mp4"> 810 Your browser does not support the video tag. 811 </video>`; 812 elVideoPopup.classList.add('show'); 813 } 814 } 815} 816 817function closeYouTubePopUp() { 818 var elYouTubePopup = document.querySelector('.youtube-popup'); 819 if(elYouTubePopup) { 820 elYouTubePopup.classList.remove('show'); 821 var elYouTubePopupContainer = elYouTubePopup.querySelector('.youtube-video-container'); 822 if(elYouTubePopupContainer) { 823 setTimeout(function() { 824 elYouTubePopupContainer.innerHTML = ''; 825 }, 600); 826 } 827 } 828} 829 830function closeVideoPopUp() { 831 var elVideoPopup = document.querySelector('.video-popup'); 832 if(elVideoPopup) { 833 elVideoPopup.classList.remove('show'); 834 var elVideoPopupContainer = elVideoPopup.querySelector('.video-container'); 835 if(elVideoPopupContainer) { 836 setTimeout(function() { 837 elVideoPopupContainer.innerHTML = ''; 838 }, 600); 839 } 840 } 841} 842 843function closeImagePopUp() { 844 var elZoomImagePopup = document.querySelector('.zoomimage-popup'); 845 if(elZoomImagePopup) { 846 elZoomImagePopup.classList.remove('show'); 847 var elZoomImagePopupContainer = elZoomImagePopup.querySelector('.zoomimage-container'); 848 if(elZoomImagePopupContainer) { 849 setTimeout(function() { 850 elZoomImagePopupContainer.innerHTML = ''; 851 }, 600); 852 } 853 } 854} 855 856function AddPopUpNoteForCustomer(msg) { 857 elNotesPopup.querySelector('p.customer-note').innerHTML = msg; 858 elNotesPopup.classList.add('open'); 859} 860 861function closeReplacementPopUp() { 862 var elReplacementProductsPopUp = document.querySelector('.replacement-products-popup'); 863 if(elReplacementProductsPopUp) { 864 changeQtysBtnsEvents(); 865 elReplacementProductsPopUp.classList.remove('open'); 866 setTimeout(function() { 867 elReplacementProductsPopUp.innerHTML = `<div class="loader"> 868 <div class="lds-spinner"> 869 <div style="--r: 0deg; --d: -1.1s;"></div> 870 <div style="--r: 30deg; --d: -1s;"></div> 871 <div style="--r: 60deg; --d: -0.9s;"></div> 872 <div style="--r: 90deg; --d: -0.8s;"></div> 873 <div style="--r: 120deg; --d: -0.7s;"></div> 874 <div style="--r: 150deg; --d: -0.6s;"></div> 875 <div style="--r: 180deg; --d: -0.5s;"></div> 876 <div style="--r: 210deg; --d: -0.4s;"></div> 877 <div style="--r: 240deg; --d: -0.3s;"></div> 878 <div style="--r: 270deg; --d: -0.2s;"></div> 879 <div style="--r: 300deg; --d: -1s;"></div> 880 <div style="--r: 330deg; --d: 0s;"></div> 881 </div> 882 <div style="font-weight: bold; margin-top: 10px;">××פש ××צר××, ×× × ×××ª× ...</div></div>`; 883 }, 750); 884 } 885} 886 887function GetOutAnimation() { 888 var outAnimation = ['backOutDown', 'backOutLeft', 'backOutRight', 'backOutUp', 889 'bounceOut', 'bounceOutDown', 'bounceOutLeft', 'bounceOutRight', 'bounceOutUp', 890 'fadeOut', 'fadeOutDown', 'fadeOutDownBig', 'fadeOutLeft', 'fadeOutLeftBig', 'fadeOutRight', 'fadeOutRightBig', 'fadeOutUp', 'fadeOutUpBig', 'fadeOutTopLeft', 'fadeOutTopRight', 'fadeOutBottomRight', 'fadeOutBottomLeft', 891 'flipOutX', 'flipOutY', 892 'lightSpeedOutRight', 'lightSpeedOutLeft', 893 'rotateOut', 'rotateOutDownLeft', 'rotateOutDownRight', 'rotateOutUpLeft', 'rotateOutUpRight', 894 'rollOut', 895 'zoomOut', 'zoomOutDown', 'zoomOutLeft', 'zoomOutRight', 'zoomOutUp', 896 'slideOutDown', 'slideOutLeft', 'slideOutRight', 'slideOutUp' 897 ]; 898 return "animate__" + outAnimation[getRandomInt(0, outAnimation.length)]; 899} 900 901function GetInAnimation() { 902 var inAnimation = ['backInDown', 'backInLeft', 'backInRight', 'backInUp', 903 'bounceIn', 'bounceInDown', 'bounceInLeft', 'bounceInRight', 'bounceInUp', 904 'fadeIn', 'fadeInDown', 'fadeInDownBig', 'fadeInLeft', 'fadeInLeftBig', 'fadeInRight', 'fadeInRightBig', 'fadeInUp', 'fadeInUpBig', 'fadeInTopLeft', 'fadeInTopRight', 'fadeInBottomLeft', 'fadeInBottomRight',
905 'flipInX', 'flipInY', 906 'lightSpeedInRight', 'lightSpeedInLeft', 907 'rotateIn', 'rotateInDownLeft', 'rotateInDownRight', 'rotateInUpLeft', 'rotateInUpRight', 908 'jackInTheBox', 909 'rollIn', 910 'zoomIn', 'zoomInDown', 'zoomInLeft', 'zoomInRight', 'zoomInUp', 911 'slideInDown', 'slideInLeft', 'slideInRight', 'slideInUp' 912 ]; 913 return "animate__" + inAnimation[getRandomInt(0, inAnimation.length)]; 914} 915 916function getRandomInt(min, max) { 917 min = Math.ceil(min); 918 max = Math.floor(max); 919 return Math.floor(Math.random() * (max - min + 1)) + min; 920} 921 922function toggleWhatsappPopup() { 923 var elWhatsappLinksPopup = document.querySelector('.whatsapp_links_popup'); 924 if(elWhatsappLinksPopup) elWhatsappLinksPopup.classList.toggle('open'); 925} 926 927function toggleMenu() { 928 elHeader.classList.toggle('hard-sticky-header'); 929 SetMenuFitToScreen(elHeaderMenu, elHeader); 930 elHeaderMenu.classList.toggle('open'); 931 var elMenuItems = document.querySelectorAll('header ul.menu > li.menu-item'); 932 if(elMenuItems) { 933 elMenuItems.forEach(function(item) { item.classList.remove('open'); }); 934 } 935 // document.querySelector('body').classList.toggle('lock'); 936} 937 938function SetMenuFitToScreen(elHeaderMenu, elHeader) { 939 var headerHeight = elHeader.offsetHeight + 'px'; 940 elHeaderMenu.style.top = headerHeight; 941 elHeaderMenu.style.height = 'calc(100vh - ' + headerHeight + ')'; 942 var elSubMenus = elHeaderMenu.querySelectorAll('ul.menu ul.sub-menu'); 943 if(elSubMenus) { 944 elSubMenus.forEach(function(subMenu) { 945 subMenu.style.top = headerHeight; 946 subMenu.style.height = 'calc(100vh - ' + headerHeight + ')'; 947 }) 948 } 949} 950 951function toggleSearch() { 952 var elSearchForm = document.querySelector('header.main-header .header-bottom-block .search_form'); 953 if(elSearchForm) { 954 elHeader.classList.toggle('hard-sticky-header'); 955 elSearchForm.classList.toggle('open'); 956 setBlackScreenFitToScreen(elSearchForm); 957 if(elSearchForm.classList.contains('open')) { 958 var elSearchField = elSearchForm.querySelector('input[type="search"]'); 959 if(elSearchField) { 960 elSearchField.focus(); 961 } 962 } 963 } 964} 965 966function setBlackScreenFitToScreen(elSearchForm) { 967 var elBlackScreen = elSearchForm.parentElement.querySelector('.search_black_screen'); 968 if(elBlackScreen) { 969 var headerHeight = elHeader.offsetHeight + 'px'; 970 elBlackScreen.style.top = headerHeight; 971 } 972} 973 974 975function CopyTableToExcell(table) { 976 var body = document.body, range, sel; 977 if (document.createRange && window.getSelection) { 978 range = document.createRange(); 979 sel = window.getSelection(); 980 sel.removeAllRanges(); 981 try { 982 range.selectNodeContents(table); 983 sel.addRange(range); 984 } catch (e) { 985 range.selectNode(table); 986 sel.addRange(range); 987 } 988 } else if (body.createTextRange) { 989 range = body.createTextRange(); 990 range.moveToElementText(table); 991 range.select(); 992 } 993 document.execCommand("Copy"); 994} 995 996function GetCustomSearchProducts(s, elAutoComplateProducts, elAddToOrderProductFields, actionButton, block_outofstock_products = true, block_bundle_products = false) { 997 elAutoComplateProducts.innerHTML = ""; 998 elAddToOrderProductFields.innerHTML = ""; 999 fetch('/wp-json/orema10/v1/search-products/get-products/', { 1000 method: 'POST', 1001 headers: {'Content-Type': 'application/json'}, 1002 body: JSON.stringify({s}), 1003 }) 1004 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1005 .then(data => { 1006 console.log(data); 1007 var TextHTML = "<ul>"; 1008 var productsCount = 0; 1009 if(data.products.length) { 1010 data.products.forEach(function(product) { 1011 if(block_bundle_products && product.product_type === 'bundle') return; 1012 productsCount++ 1013 var stock_color = ((block_outofstock_products)? ((product.product_stock_status === 'instock')? 'style="color: green; font-weight: bold;"': 'style="color: red;"'): ''); 1014 TextHTML += '<li class="product" data-product-id="' + product.product_id + '" onclick="' + actionButton + '(this)">'; 1015 TextHTML +='<div class="product-img">' + product.product_image + '</div>'; 1016 TextHTML += '<p ' + stock_color + ' class="product-title">' + product.product_title + ((product.product_subtitle)? ' - ' + product.product_subtitle: '') + '</p>'; 1017 TextHTML += '</li>'; 1018 }); 1019 } 1020 1021 if(!productsCount) { 1022 TextHTML += '<li>×× × ×צ×× ×ª×צ××ת</li>'; 1023 } 1024 TextHTML += "</ul>"; 1025 elAutoComplateProducts.innerHTML = TextHTML; 1026 }) 1027 .catch(error => { 1028 console.error('Error:', error); 1029 // alert(error); 1030 }); 1031} 1032 1033function GetCustomSearchCustomers(s, elAutoCompleteSearchCustomer, actionButton) { 1034 elAutoCompleteSearchCustomer.innerHTML = "";
1035 fetch('/wp-json/orema10/v1/search-customers/get-customers/', { 1036 method: 'POST', 1037 headers: {'Content-Type': 'application/json'}, 1038 body: JSON.stringify({s}), 1039 }) 1040 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1041 .then(data => { 1042 console.log(data); 1043 var TextHTML = "<ul>"; 1044 var customersCount = 0; 1045 if(data.customers.length) { 1046 data.customers.forEach(function(customer) { 1047 customersCount++; 1048 TextHTML += '<li class="customer" data-customer="' + encodeURIComponent(JSON.stringify(customer)) + '" onclick="' + actionButton + '(this)">'; 1049 TextHTML += '<p class="customer-details">[' + customer.CUSTNAME + '] ' + customer.CUSTDES + ' ' + (customer.ECUSTDES ? '(' + customer.ECUSTDES + ') - ': '- ') + customer.WTAXNUM + '</p>'; 1050 TextHTML += '</li>'; 1051 }); 1052 } 1053 1054 if(!customersCount) { 1055 TextHTML += '<li>×× × ×צ×× ×ª×צ××ת</li>'; 1056 } 1057 TextHTML += "</ul>"; 1058 elAutoCompleteSearchCustomer.innerHTML = TextHTML; 1059 }) 1060 .catch(error => { 1061 console.error('Error:', error); 1062 }); 1063} 1064 1065function GetCustomSearchBarcodeProducts(barcode, elAutoComplateProducts, elAddToOrderProductFields, actionButton, block_outofstock_products = true, block_bundle_products = false) { 1066 elAutoComplateProducts.innerHTML = ""; 1067 elAddToOrderProductFields.innerHTML = ""; 1068 fetch('/wp-json/orema10/v1/search-products/get-products-by-bar
1068code/', { 1069 method: 'POST', 1070 headers: {'Content-Type': 'application/json'}, 1071 body: JSON.stringify({barcode}), 1072 }) 1073 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1074 .then(data => { 1075 console.log(data); 1076 var TextHTML = "<ul>"; 1077 var productsCount = 0; 1078 if(data.products.length) { 1079 data.products.forEach(function(item) { 1080 var product = item.details; 1081 if(block_bundle_products && product.type === 'bundle') return; 1082 productsCount++ 1083 var stock_color = ((block_outofstock_products)? ((product.product_stock_status === 'instock')? 'style="color: green; font-weight: bold;"': 'style="color: red;"'): ''); 1084 TextHTML += '<li class="product" data-product-id="' + product.product_id + '" onclick="' + actionButton + '(this)">'; 1085 TextHTML +='<div class="product-img">' + product.img + '</div>'; 1086 TextHTML += '<p ' + stock_color + ' class="product-title">' + product.name + '</p>'; 1087 TextHTML += '</li>'; 1088 }); 1089 } 1090 1091 if(!productsCount) { 1092 TextHTML += '<li>×× × ×צ×× ×ª×צ××ת</li>'; 1093 } 1094 TextHTML += "</ul>"; 1095 elAutoComplateProducts.innerHTML = TextHTML; 1096 }) 1097 .catch(error => { 1098 console.error('Error:', error); 1099 // alert(error); 1100 }); 1101} 1102 1103function GetCustomProductFields(product_id, elAddToOrderProductFields, actionButton, block_outofstock_products = true, block_bundle_products = true, enabled_qty_field = true) { 1104 elAddToOrderProductFields.innerHTML = ""; 1105 fetch('/wp-json/orema10/v1/search-products/get-selected-product-fields/', { 1106 method: 'POST', 1107 headers: {'Content-Type': 'application/json'}, 1108 body: JSON.stringify({product_id, block_outofstock_products}), 1109 }) 1110 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1111 .then(data => { 1112 console.log(data); 1113 var TextHTML = ''; 1114 var product_fields = data.fields; 1115 if(block_outofstock_products && product_fields.product_stock_status === 'outofstock') { 1116 alert('×××צר ××× ×××××× ×××× × ×××× ×ר××ש×'); 1117 } else { 1118 if(product_fields.product_type === 'variable' || product_fields.product_type === 'simple' || product_fields.product_type === 'variation' || (!block_bundle_products && product_fields.product_type === 'bundle')) { 1119 if(product_fields.product_type === 'variable') { 1120 TextHTML += '<select name="variations" class="product-variations">'; 1121 TextHTML += '<option disabled selected value="">××ר ×ר××צ××</option>'; 1122 product_fields.product_available_variations.forEach(function(variation) { 1123 if(block_outofstock_products && !variation.is_in_stock) return false; 1124 var variation_name = GetAttributeColorName(Object.values(variation.attributes)[0]); 1125 TextHTML += '<option value="' + variation.variation_id + '">' + variation_name + '</option>'; 1126 }); 1127 TextHTML += '</select>'; 1128 } 1129 1130 if(enabled_qty_field) TextHTML += '<input type="text" data-product-id="' + product_fields.product_id + '" name="qty" placeholder="××× ×××ת" class="product-qty" />'; 1131 TextHTML += '<button class="add-product-action" data-product-id="' + product_fields.product_id + '" onclick="' + actionButton + '()">××סף</button>'; 1132 elAddToOrderProductFields.innerHTML = TextHTML; 1133 } else if(product_fields.product_type === 'bundle') { 1134 alert('××צר ×ס×× "××× ××" ×× × ××ª× ×××ס××£ ×ש×× ×× ×©× ××××× ×'); 1135 } else { 1136 alert('×× × ××ª× ×××ס××£ ××צר ×× ××××× ×'); 1137 } 1138 } 1139 }) 1140 .catch(error => { 1141 console.error('Error:', error); 1142 // alert(error); 1143 }); 1144} 1145 1146function AddNewBranch(elAddBranchBtns, e) { 1147 e.preventDefault(false); 1148 var elBranchBillingFields = elAddBranchBtns.parentNode.querySelectorAll('input.billing'); 1149 if(elBranchBillingFields) { 1150 var isAllBranchFieldDone = true; 1151 elBranchBillingFields.forEach(function(field) { if(!field.value) isAllBranchFieldDone = false; }); 1152 if(isAllBranchFieldDone) { 1153 var first_name = elAddBranchBtns.parentNode.querySelector('input.billing-first-name').value; 1154 var last_name = elAddBranchBtns.parentNode.querySelector('input.billing-last-name').value; 1155 var company = elAddBranchBtns.parentNode.querySelector('input.billing-company').value; 1156 var address = elAddBranchBtns.parentNode.querySelector('input.billing-address-1').value; 1157 var city = elAddBranchBtns.parentNode.querySelector('input.billing-city').value; 1158 var phone = elAddBranchBtns.parentNode.querySelector('input.billing-phone').value; 1159 var company_id = elAddBranchBtns.parentNode.querySelector('input.billing-comapny-id').value; 1160 fetch('/wp-json/orema10/v1/my-account/add-new-branch/', { 1161 method: 'POST', 1162 headers: {'Content-Type': 'application/json'}, 1163 body: JSON.stringify({first_name, last_name, company, address, city, phone,
1163company_id}), 1164 }) 1165 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1166 .then(data => { 1167 console.log(data); 1168 alert('××¡× ××£ × ×צר ××צ×××'); 1169 setTimeout(function() { 1170 location.reload() 1171 }, 500); 1172 }) 1173 .catch(error => { 1174 console.error('Error:', error); 1175 // alert(error); 1176 }); 1177 } else { 1178 alert("×× × ××× ×ת ×× ×פר××× ×××פס"); 1179 } 1180 } 1181} 1182 1183function RemoveBranch(btn, e) { 1184 e.preventDefault(false); 1185 if(confirm('××× ×××××§ ×ת ××¡× ××£ ש×××רת')) { 1186 var idx = btn.getAttribute('data-index'); 1187 fetch('/wp-json/orema10/v1/my-account/remove-branch/', { 1188 method: 'POST', 1189 headers: {'Content-Type': 'application/json'}, 1190 body: JSON.stringify({idx}), 1191 }) 1192 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1193 .then(data => { 1194 console.log(data); 1195 alert('××¡× ××£ × ×××§ ××צ×××'); 1196 setTimeout(function() { 1197 location.reload() 1198 }, 500); 1199 }) 1200 .catch(error => { 1201 console.error('Error:', error); 1202 // alert(error); 1203 }); 1204 } 1205} 1206 1207function SelectBranch(elSelectChangeBranch) { 1208 var idx = elSelectChangeBranch.value; 1209 if(idx) { 1210 fetch('/wp-json/orema10/v1/billing/select-branch/', { 1211 method: 'POST', 1212 headers: {'Content-Type': 'application/json'}, 1213 body: JSON.stringify({idx}), 1214 }) 1215 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1216 .then(data => { 1217 alert('××¡× ××£ × ××ר ××צ×××'); 1218 setTimeout(function() { 1219 location.reload() 1220 }, 500); 1221 }) 1222 .catch(error => { 1223 console.error('Error:', error); 1224 // alert(error); 1225 }); 1226 } 1227} 1228 1229function acceptOrderAfterEdit(btn, page) { 1230 var order_id = btn.getAttribute('data-order-id'); 1231 if (order_id) { 1232 fetch('/wp-json/orema10/v1/orders/accept-order/', { 1233 method: 'POST', 1234 headers: {'Content-Type': 'application/json'}, 1235 body: JSON.stringify({order_id}), 1236 }) 1237 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1238 .then(data => { 1239 console.log(data); 1240 if(page === 'area') { 1241 var elTableTR = document.querySelector('table.accept-orders-table tr.order-' + order_id); 1242 if (elTableTR) { 1243 elTableTR.classList.add('deleted'); 1244 setTimeout(function() { 1245 elTableTR.parentNode.removeChild(elTableTR); 1246 }, 1500); 1247 } 1248 } else { 1249 alert('××××× × × ×©××× ××צ×××'); 1250 location = location.origin + '/my-account'; 1251 } 1252 }) 1253 .catch(error => { 1254 console.error('Error:', error); 1255 // alert(error); 1256 }); 1257 } 1258} 1259 1260function checkWarrantyBySerial(serial) { 1261 if(serial) { 1262 fetch('/wp-json/orema10/v1/product/check-warranty/', { 1263 method: 'POST', 1264 headers: {'Content-Type': 'application/json'}, 1265 body: JSON.stringify({serial}), 1266 }) 1267 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1268 .then(data => { 1269 document.querySelector('.res-container').innerHTML = (data.warranty)? '<span class="warranty">××צר × ×¨×ש ××××פ××</span>': '<span class="not-warranty">××צר ××× × × ×¨×ש ××××פ××, ×¤× × ××× ×ת ×××ר×ר × ×סף</sp
1269an>'; 1270 }) 1271 .catch(error => { 1272 console.error('Error:', error); 1273 // alert(error); 1274 }); 1275 } 1276} 1277 1278function PrintGenerateBarcodes(elResultsList, first_barcode, barcodes_quantity) { 1279 fetch('/wp-json/orema10/v1/generate-barcodes/generate/', { 1280 method: 'POST', 1281 headers: {'Content-Type': 'application/json'}, 1282 body: JSON.stringify({first_barcode, barcodes_quantity}), 1283 }) 1284 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1285 .then(data => { 1286 console.log(data) 1287 var TextHTML = '<table><tbody>'; 1288 data.barcodes.forEach(function(barcode) { 1289 TextHTML += '<tr><td class="barcode" data-label="×רק××">' + barcode + '</td></tr>'; 1290 }); 1291 TextHTML += '</tbody></table>'; 1292 elResultsList.innerHTML = TextHTML; 1293 }) 1294 .catch(error => { 1295 console.error('Error:', error); 1296 // alert(error); 1297 }); 1298} 1299 1300function SinglePageVariationChange(event, variation) { 1301 var variation_id = variation.variation_id; 1302 if(variation_id) { 1303 fetch('/wp-json/orema10/v1/product/variation/get-barcode-details/', { 1304 method: 'POST', 1305 headers: {'Content-Type': 'application/json'}, 1306 body: JSON.stringify({variation_id}), 1307 }) 1308 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1309 .then(data => { 1310 console.log(data) 1311 var barcodeDetails = data.barcode_details; 1312 if(barcodeDetails && (barcodeDetails.format && barcodeDetails.barcode)) changeBarcode(barcodeDetails); 1313 }) 1314 .catch(error => { 1315 console.error('Error:', error); 1316 // alert(error); 1317 }); 1318 } 1319} 1320 1321function SetBillingData(btn) { 1322 var agent_customer_id = btn.getAttribute('data-agent-user-id'); 1323 if(agent_customer_id) { 1324 fetch('/wp-json/orema10/v1/agents/set-billing-by-agent-customer/', { 1325 method: 'POST', 1326 headers: {'Content-Type': 'application/json'}, 1327 body: JSON.stringify({agent_customer_id}), 1328 }) 1329 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1330 .then(data => { 1331 console.log(data); 1332 addMsgToMsgList('×פר××× ×¢×××× × ××צ×××'); 1333 }) 1334 .catch(error => { 1335 console.error('Error:', error); 1336 // alert(error); 1337 }); 1338 } 1339} 1340 1341function setOrderDetails(order_id, isRefreshPage = false) { 1342 if(order_id) { 1343 fetch('/wp-json/orema10/v1/agents/set-billing-by-agent-order/', { 1344 method: 'POST', 1345 headers: {'Content-Type': 'application/json'}, 1346 body: JSON.stringify({order_id}), 1347 }) 1348 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1349 .then(data => { 1350 console.log(data); 1351 if(isRefreshPage) { 1352 alert("×פר××× ×¢×××× × ××צ×××"); 1353 location.reload(); 1354 } else { 1355 addMsgToMsgList('×פר××× ×¢×××× × ××צ×××'); 1356 } 1357 }) 1358 .catch(error => { 1359 console.error('Error:', error); 1360 // alert(error); 1361 }); 1362 } 1363} 1364 1365 1366function setCustomerToAgentOrder(customer_id) { 1367 if(customer_id) { 1368 fetch('/wp-json/orema10/v1/agents/set-billing-by-agent-priority-customer/', { 1369 method: 'POST', 1370 headers: {'Content-Type': 'application/json'}, 1371 body: JSON.stringify({customer_id}), 1372 }) 1373 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1374 .then(data => { 1375 console.log(data) 1376 alert("×פר××× ×¢×××× × ××צ×××"); 1377 jQuery('body').trigger('update_checkout'); 1378 setTimeout(() => { 1379 location.reload(); 1380 }); 1381 // location.reload(); 1382 }) 1383 .catch(error => { 1384 console.error('Error:', error); 1385 // alert(error); 1386 }); 1387 } 1388} 1389 1390function ClearCustomerToAgentOrder() { 1391 event.preventDefault(false); 1392 if(!confirm('××× ×× ×§×ת ×ת ×××§×× ×××××× × ×××ת ?')) return; 1393 1394 fetch('/wp-json/orema10/v1/agents/clear-billing-agent-priority-customer/', { 1395 method: 'POST', 1396 headers: {'Content-Type': 'application/json'}, 1397 }) 1398 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1399 .then(data => { 1400 console.log(data) 1401 alert("×פר×× ××§×× × ×××§× ××צ×××"); 1402 jQuery('#billing_first_name, #billing_last_name, #billing_company, #billing_address_1, #billing_city, #billing_phone, #billing_company_id, #billing_priority_custname').val(''); 1403 jQuery('body').trigger('update_checkout'); 1404 setTimeout(() => { 1405 location.reload(); 1406 }); 1407 }) 1408 .catch(error => { 1409 console.error('Error:', error); 1410 }); 1411} 1412 1413function RequestToUpdateStockStatus(btn, status) { 1414 var elInputVariationID = btn.closest('li.product')?.querySelector('input[name="variation_id"]'); 1415 var dataProductID = btn.getAttribute('data-product-id'); 1416 var product_id = (elInputVariationID)? +elInputVariationID.value: dataProductID; 1417 if(product_id) { 1418 UpdateStockStatus(product_id, status); 1419 } else if(dataProductID && confirm("××× ××צע ×ת ×פע××× ×¢× ×× ×צ××¢×× ×©× ×××צר ?")) { 1420 UpdateStockStatus(dataProductID, status); 1421 } 1422} 1423 1424function UpdateStockStatus(product_id, status, missingPage = false) { 1425 fetch('/wp-json/orema10/v1/product/update-stock-status/', { 1426 method: 'POST', 1427 headers: {'Content-Type': 'application/json'}, 1428 body: JSON.stringify({product_id, status}), 1429 }) 1430 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1431 .then(data => { 1432 console.log(data) 1433 if(missingPage) document.querySelector('li.product.post-' + product_id)?.remove(); 1434 addMsgToMsgList('ס×××ס ××××× ×תע××× ××צ×××'); 1435 }) 1436 .catch(error => { 1437 console.error('Error:', error); 1438 // alert(error); 1439 }); 1440} 1441 1442function openOrdersList(elOpenOrdersLink) { 1443 var isOpen = elOpenOrdersLink.classList.contains('open'); 1444 var elOrdersConatiner = elOpenOrdersLink.parentElement.querySelector('.orders-container'); 1445 if(elOrdersConatiner) { 1446 if(isOpen) { 1447 elOrdersConatiner.style.height = '0px'; 1448 } else { 1449 var elOrdersListConatiner = elOrdersConatiner.querySelector('.orders-list-container'); 1450 if(elOrdersListConatiner) { 1451 if(elOrdersListConatiner.innerHTML) { 1452 elOrdersConatiner.style.height = elOrdersListConatiner.offsetHeight + 'px'; 1453 } else { 1454 var variation = document.querySelector('input[name="variation_id"]');
1455 var product_id = (variation && +variation.value)? variation.value: document.querySelector('div.single-product').id.replace('product-',''); 1456 if(+product_id) { 1457 fetch('/wp-json/orema10/v1/product/get-orders-by-product/', { 1458 method: 'POST', 1459 headers: {'Content-Type': 'application/json'}, 1460 body: JSON.stringify({product_id}), 1461 }) 1462 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1463 .then(data => { 1464 console.log(data) 1465 var TextHTML = '<ul class="orders-list">'; 1466 data.orders.forEach(function(order_data) { 1467 TextHTML += '<li><a class="single-order-check" target="_blank" href="' + location.origin + '/check-order/?order_id=' + order_data.order_id +'">' + order_data.billing_company + ' (' + order_data.product_qty + ' ×××××ת)</a></li>'; 1468 }); 1469 TextHTML += '</ul>'; 1470 elOrdersListConatiner.innerHTML = TextHTML; 1471 elOrdersConatiner.style.height = (elOrdersListConatiner.offsetHeight + 10) + 'px'; 1472 }) 1473 .catch(error => { 1474 console.error('Error:', error); 1475 // alert(error); 1476 }); 1477 } else { 1478 alert('×× × ××¦× ×××× ×××××× ×××××§×'); 1479 return; 1480 } 1481 } 1482 } 1483 } 1484 elOpenOrdersLink.classList.toggle('open'); 1485 } 1486} 1487 1488function GetManualOrderItem(product, qty = 1) { 1489 var variation_id = product.details.variation_id || ''; 1490 var barcode = product.details.barcode || ''; 1491 var textHTML = ''; 1492 textHTML += '<div class="single-order-item manual-item" data-barcode="' + barcode + '" data-item-id="' + Date.now() + '" data-product-id="' + product.details.product_id + '" data-variation-id="' + variation_id + '">'; 1493 textHTML += product.details.img; 1494 textHTML += '<div class="product-title">'; 1495 textHTML += '<p class="product-name">' + product.details.name + '</p>'; 1496 textHTML += '</div>'; 1497 textHTML += '<span contenteditable="true" class="price main-price">' + product.details.price_html + '</span>'; 1498 textHTML += '<div class="total-scanned"><span class="scanned">' + qty + '</span></div>'; 1499 textHTML += '<div class="wrongs"><button class="delete single-btn" onclick="DeleteThisCheckProduct(this)">X</button></div>'; 1500 textHTML += '</div>'; 1501 return textHTML; 1502} 1503 1504function InitManualOrderItemPriceChanged() { 1505 var elContentEditableItems = document.querySelectorAll('.order-items [contenteditable]'); 1506 if(elContentEditableItems) { 1507 elContentEditableItems.forEach(function(item) { 1508 item.addEventListener('input', function() { 1509 SumManualOrderItems(); 1510 }) 1511 }); 1512 } 1513} 1514 1515function SumManualOrderItems() { 1516 console.log('Start Sum Manual Order'); 1517 var elOrderTotal = document.querySelector('.total_price'); 1518 if(elOrderTotal) { 1519 var manualOrderTotalPrice = 0; 1520 var elTabsContainer = document.querySelector('.tab-container'); 1521 var items = elTabsContainer.querySelectorAll('.single-order-item, .addon-order-item'); 1522 if(items) { 1523 items.forEach(function(item) { 1524 var itemPrice = GetPriceByItem(item); 1525 var quantity = +item.querySelector('.total-scanned .scanned').innerText; 1526 manualOrderTotalPrice += itemPrice * quantity; 1527 }); 1528 } 1529 1530 elOrderTotal.innerHTML = (manualOrderTotalPrice).toLocaleString('he-IL', {style: 'currency', currency: 'ILS'}); 1531 } 1532} 1533 1534function GetPriceByItem(item) { 1535 var elPrice = item.querySelector('.price'); 1536 var isSaleItem = elPrice.querySelector('del'); 1537 return (isSaleItem)? +elPrice.querySelector('b').innerText.replace(' âª', '').replace(',', ''): +elPrice.innerText.replace(' âª', '').replace(',', ''); 1538} 1539 1540function CleanBarcodeBeforeAction(barcode) { 1541 return barcode.replace('CapsLock', '').replace('undefined', ''); 1542} 1543 1544function changeProductPrintingType(elSelect) { 1545 var selectedOption = elSelect.options[elSelect.selectedIndex]; 1546 if(selectedOption) { 1547 var printingImageSrc = selectedOption.getAttribute('data-image-url'); 1548 if(printingImageSrc) { 1549 var elMainProductImg = elSelect.closest('.product').querySelector('img.attachment-woocommerce_thumbnail') || elSelect.closest('.product').querySelector('img.wp-post-image'); 1550 if(elMainProductImg) elMainProductImg.src = printingImageSrc; 1551 } 1552 } 1553} 1554 1555function updateCountdown() { 1556 document.querySelectorAll('.onsale-countdown-badge').forEach(function (container) { 1557 var endTime = parseInt(container.getAttribute("data-end-time")); 1558 if (!endTime) return; 1559 1560 var daysEl = container.querySelector("#days span"); 1561 var hoursEl = container.querySelector("#hours span"); 1562 var minutesEl = container.querySelector("#minutes span"); 1563 var secondsEl = container.querySelector("#seconds span"); 1564 1565 function renderCountdown() { 1566 var now = new Date().getTime(); 1567 var distance = endTime - now; 1568 1569 if (distance < 0) { 1570 container.innerHTML = "<strong>×××צע ×סת×××!</strong>"; 1571 return; 1572 } 1573 1574 var days = Math.floor(distance / (1000 * 60 * 60 * 24)); 1575 var hours = String(Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60))).padStart(2, '0'); 1576 var minutes = String(Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60))).padStart(2, '0'); 1577 var seconds = String(Math.floor((distance % (1000 * 60)) / 1000)).padStart(2, '0'); 1578 1579 daysEl.textContent = days; 1580 hoursEl.textContent = hours; 1581 minutesEl.textContent = minutes; 1582 secondsEl.textContent = seconds; 1583 } 1584 1585 renderCountdown(); 1586 setInterval(renderCountdown, 1000); 1587 }); 1588} 1589 1590function UpdateUsePriceDisplay(input) { 1591 var user_id = input.parentElement.getAttribute('data-user-id'); 1592 var displayType = input.checked ? 2: 0; 1593 fetch('/wp-json/orema10/v1/my-account/update-user-price-display/', { 1594 method: 'POST', 1595 headers: {'Content-Type': 'application/json'}, 1596 body: JSON.stringify({user_id, displayType}), 1597 }) 1598 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1599 .then(data => { 1600 addMsgToMsgList('פע××× ×××¦×¢× ××צ×××'); 1601 }) 1602 .catch(error => { 1603 console.error('Error:', error); 1604 alert(error); 1605 }); 1606} 1607 1608function UpdateUserDisplayMode(input) { 1609 var user_id = input.parentElement.getAttribute('data-user-id'); 1610 var displayMode = input.checked; 1611 fetch('/wp-json/orema10/v1/my-account/update-user-display-mode/', { 1612 method: 'POST', 1613 headers: {'Content-Type': 'application/json'}, 1614 body: JSON.stringify({user_id, displayMode}), 1615 }) 1616 .then(response => (response.ok)? response.json(): response.json().then(err => { throw new Error(err.message || 'Unknown error'); })) 1617 .then(data => { 1618 addMsgToMsgList('פע××× ×××¦×¢× ××צ×××'); 1619 if(displayMode) { 1620 document.body.classList.add('dark-mode'); 1621 } else { 1622 document.body.classList.remove('dark-mode'); 1623 } 1624 }) 1625 .catch(error => { 1626 console.error('Error:', error); 1627 alert(error); 1628 }); 1629} 1630
1631function openShortDescription(btn) { 1632 var elShortDescTab = btn.parentNode; 1633 if(elShortDescTab) { 1634 var elTheShortDesc = elShortDescTab.querySelector('.the-short-description'); 1635 if(elTheShortDesc) { 1636 var elShortDescContainer = elTheShortDesc.querySelector('.short-description-container'); 1637 if(elShortDescContainer) { 1638 var descHeight = elShortDescContainer.offsetHeight + 30; 1639 elTheShortDesc.style.height = (elTheShortDesc.classList.contains('open'))? '0px': descHeight + 'px'; 1640 btn.querySelector('i').style.transform = (elTheShortDesc.classList.contains('open'))? 'rotate(90deg)': 'rotate(0deg)'; 1641 elTheShortDesc.classList.toggle('open'); 1642 } 1643 } 1644 } 1645} 1646 1647function DeleteThisAccount(btn, e) { 1648 e.preventDefault(false); 1649 var user_id = btn.getAttribute('data-user-id'); 1650 if(user_id) { 1651 var isDeleteMyAccount = confirm('××× ××ª× ×××× ×©××ª× ×¨××¦× ×××××§ ×ת ××ש××× ?'); 1652 if(isDeleteMyAccount) { 1653 var isSecondDeleteAccountMsg = confirm('ש×× ××, ×× ××ª× ××××× ×ס××× ××××קת ××ש××× ××× ××¨× ××ר×'); 1654 if(isSecondDeleteAccountMsg) { 1655 jQuery.ajax({ 1656 type: 'POST', 1657 dataType: 'json', 1658 url: ADMIN_AJAX_URL, 1659 data: { 1660 'action': 'remove_account', 1661 'user_id': user_id 1662 }, 1663 success: function() { 1664 alert('××ש××× × ×××§ ××צ×××!'); 1665 if(location.pathname.includes('my-account')) { 1666 location.href = location.origin; 1667 } 1668 }, error: function(err) { 1669 alert('ש×××× ×××××§×'); 1670 console.error(err); 1671 } 1672 }); 1673 } 1674 } 1675 } 1676} 1677 1678function ChangePassword(btn, e) { 1679 e.preventDefault(false); 1680 var user_id = btn.getAttribute('data-user-id'); 1681 if(user_id) { 1682 var newPassword = ''; 1683 1684 var isHavePassword = confirm('××× ×ש ×× ×ת ×ס×ס×× ××××©× ?'); 1685 if(isHavePassword) { 1686 newPassword = prompt('××× ×¡ ×ת ×ס×ס×× ×××ש×'); 1687 if(newPassword && !confirm('××× ××ª× ×××× ×©×ס×ס×× ××××©× ××× ' + newPassword + ' ?')) { 1688 return; 1689 } 1690 } else { 1691 newPassword = AllPhoneGeneratePassword(); 1692 } 1693 1694 if(newPassword) { 1695 if(!confirm('××× ××ª× ×××× ×©××ª× ×¨××¦× ××©× ×ת ×ת ×ס×ס×× ?')) return; 1696 jQuery.ajax({ 1697 type: 'POST', 1698 dataType: 'json', 1699 url: ADMIN_AJAX_URL, 1700 data: { 1701 'action': 'change_password', 1702 'user_id': user_id, 1703 'new_password': newPassword 1704 }, 1705 success: function() { 1706 alert('×ס×ס×× ×©×× ×ª× ××צ×××!'); 1707 }, error: function(err) { 1708 alert('ש××××'); 1709 console.error(err); 1710 } 1711 }); 1712 } 1713 } 1714} 1715 1716function AllPhoneGeneratePassword() { 1717 const passwordLength = 6; 1718 const letters = [ 1719 'abcdefghjkmnopqrstuvwxyz', 1720 '0123456789' 1721 ]; 1722 1723 let pass = ''; 1724 1725 for (let i = 0; i < passwordLength; i++) { 1726 const r = Math.floor(Math.random() * 2); // 0 ×× 1 1727 const chars = letters[r]; 1728 const currentLetter = chars[Math.floor(Math.random() * chars.length)]; 1729 pass += currentLetter; 1730 } 1731 1732 return pass; 1733} 1734 1735function toggleLoginPopup() { 1736 var elCustomLoginPopup = document.querySelector('.login-popup'); 1737 if(elCustomLoginPopup) { 1738 elCustomLoginPopup.classList.toggle('open'); 1739 toggleWebsiteScrolling(); 1740 } 1741} 1742 1743/* Woocommerce Checkout JS events */ 1744// jQuery( document.body ).trigger( 'init_checkout' ); 1745// jQuery( document.body ).trigger( 'payment_method_selected' ); 1746// jQuery( document.body ).trigger( 'update_checkout' ); 1747// jQuery( document.body ).trigger( 'updated_checkout' ); 1748// jQuery( document.body ).trigger( 'checkout_error' ); 1749// jQuery( document.body ).trigger( 'applied_coupon_in_checkout' ); 1750// jQuery( document.body ).trigger( 'removed_coupon_in_checkout' ); 1751 1752/* Woocommerce cart page JS events */ 1753// jQuery( document.body ).trigger( 'wc_cart_emptied' ); 1754// jQuery( document.body ).trigger( 'update_checkout' ); 1755// jQuery( document.body ).trigger( 'updated_wc_div' ); 1756// jQuery( document.body ).trigger( 'updated_cart_totals' ); 1757// jQuery( document.body ).trigger( 'country_to_state_changed' ); 1758// jQuery( document.body ).trigger( 'updated_shipping_method' ); 1759// jQuery( document.body ).trigger( 'applied_coupon', [ coupon_code ] ); 1760// jQuery( document.body ).trigger( 'removed_coupon', [ coupon ] ); 1761 1762/* Woocommerce Single product page JS events */ 1763// jQuery( '.wc-tabs-wrapper, .woocommerce-tabs, #rating' ).trigger( 'init' ); 1764 1765/* Woocommerce Variable product page JS events */
1766// jQuery( document.body ).trigger( 'found_variation', [variation] ); 1767 1768/* Woocommerce Add to cart JS events */ 1769// jQuery( document.body ).trigger( 'adding_to_cart', [ $thisbutton, data ] ); 1770// jQuery( document.body ).trigger( 'added_to_cart', [ response.fragments, response.cart_hash, $thisbutton ] ); 1771// jQuery( document.body ).trigger( 'removed_from_cart', [ response.fragments, response.cart_hash, $thisbutton ] ); 1772// jQuery( document.body ).trigger( 'wc_cart_button_updated', [ $button ] ); 1773// jQuery( document.body ).trigger( 'cart_page_refreshed' ); 1774// jQuery( document.body ).trigger( 'cart_totals_refreshed' ); 1775// jQuery( document.body ).trigger( 'wc_fragments_loaded' ); 1776 1777/* Woocommerce Add payment method JS events */ 1778// jQuery( document.body ).trigger( 'init_add_payment_method' ); 1779 1780/* To bind listener to these events, use: */ 1781/*jQuery('<event_target>').on('<event_name>', function(){ 1782 console.log('<event_name> triggered'); 1783}); 1784 1785For example: 1786 1787jQuery('body').on('init_checkout', function(){ 1788 console.log('init_checkout triggered'); 1789 // now.do.whatever(); 1790});*/
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.