1(function($){ 2 var currentListProducIDs = []; 3 var myItemsIDs = []; 4 var buyAgainIDs = []; 5 6 function getSubTotal() { 7 var subTotal = 0; 8 if(currentListProducIDs.length) { 9 var productsData = allProducts.products; 10 listProducts = productsData.filter(obj => currentListProducIDs.includes(obj.name)); 11 subTotal = listProducts.reduce((accumulator, product) => { 12 return accumulator + parseFloat(product.price); 13 }, 0); 14 } 15 return subTotal; 16 } 17 18 function getProductCount() { 19 var productCount = 0; 20 if(currentListProducIDs.length) { 21 var productsData = allProducts.products; 22 listProducts = productsData.filter(obj => currentListProducIDs.includes(obj.name)); 23 productCount = listProducts.length; 24 } 25 return productCount; 26 } 27 28 function refreshList( listID, productIDs ) { 29 let listItem = ''; 30 if(jQuery('.svt-all-orders-list-item[data-id="'+listID+'"]').length) { 31 let subTotal = getSubTotal(); 32 subTotal = subTotal.toFixed(2); 33 const listProducts = allProducts.products.filter(product => productIDs.includes(product.name)); 34 if (listProducts.length) { 35 listItem = `${renderListProducts(listProducts)}`; 36 } 37 let itemCount = listProducts.length+' Items'; 38 jQuery('.svt-all-orders-list-item[data-id="'+listID+'"] .svt-list-meta-info .list-items-count').html(itemCount); 39 jQuery('.svt-all-orders-list-item[data-id="'+listID+'"] .svt-list-meta-info .list-items-total').html('$'+subTotal); 40 if(jQuery('.svt-all-orders-list-item[data-id="'+listID+'"] .svt-order-items').length) { 41 jQuery('.svt-all-orders-list-item[data-id="'+listID+'"] .svt-order-items').html(listItem); 42 } 43 else { 44 listItem = `<div class="svt-order-items">${renderListProducts(listProducts)}</div>`; 45 jQuery('.svt-all-orders-list-item[data-id="'+listID+'"] .svt-delete-list-wrap').before(listItem); 46 } 47 } 48 } 49 50 function renderListProducts(listProducts) { 51 const maxProductCount = 7; 52 let listItem = ''; 53 54 listProducts.slice(0, maxProductCount).forEach(product => { 55 const productImg = product.mainImage 56 ? `https://s3-us-west-2.amazonaws.com/www.gethomesome.com/productimages_tn/${product.mainImage}.jpg` 57 : `https://s3-us-west-2.amazonaws.com/www.gethomesome.com/productimages_tn/${product.name}.jpg`; 58 59 listItem += `<div class="svt-order-product"><img src="${productImg}" alt=""></div>`; 60 }); 61 62 if (listProducts.length > maxProductCount) { 63 listItem += `<div class="svt-order-product more-products"><span>+${listProducts.length - maxProductCount} More</span></div>`; 64 } 65 66 return listItem; 67 } 68 69 async function refreshMyLists( lists ) { 70 $('.profile-shimmer-box').show(); 71 $('.svt-all-orders-list-item:not(.profile-shimmer-box)').remove(); 72 73 if(typeof lists == "undefined" || lists == '' || lists == null) { 74 75 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 76 77 var user = localStorage.getItem('user'); 78 user = JSON.parse(user); 79 80 email = user.email; 81 email = email.replace('^',''); 82 83 let headers = { 84 'emailid': email, 85 'authToken': user.authToken, 86 'location': getCookie('selectedLocation'), 87 'pricelist': getCookie('selectedPriceList'), 88 'Content-Type': 'application/json' 89 }; 90 91 92 api.getData('/v2/user/shoppinglists',headers).then(response => { 93 if (response.lists) { 94 sessionStorage.setItem('shoppingLists', JSON.stringify(response.lists)); 95 renderLists(response.lists); 96 fetchMyItems();
97 fetchBuyAgainItems(); 98 } else { 99 $('.svt-no-lists-wrapper').fadeIn(); 100 } 101 }) 102 .catch(error => { 103 console.error('Error posting data on clip coupon 664:', error); 104 }); 105 } 106 else { 107 renderLists(lists); 108 // fetchMyItems(); 109 // fetchBuyAgainItems(); 110 } 111 112 // try { 113 // const response = await $.ajax({ 114 // type: 'GET', 115 // url: sitedata.svt_ajax_url, 116 // data: { action: 'get_my_lists' }, 117 // dataType: 'json' 118 // }); 119 120 // $('.profile-shimmer-box').hide(); 121 122 // fetchMyItems(); 123 // fetchBuyAgainItems(); 124 125 // if (response.lists) { 126 // renderLists(response.lists); 127 // } else { 128 // $('.svt-no-lists-wrapper').fadeIn(); 129 // } 130 // } catch (error) { 131 // console.error('Error fetching my lists:', error); 132 // } 133 }; 134 135 async function fetchMyItems() { 136 if (myItemsIDs.length === 0) { 137 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 138 139 var user = localStorage.getItem('user'); 140 user = JSON.parse(user); 141 142 let headers = { 143 'apikey': hsdata.hs_api_key, 144 'location': getCookie('selectedLocation'), 145 'pricelist': getCookie('selectedPriceList') 146 }; 147 148 if(user != null) { 149 headers.emailId = user.email; 150 headers.authToken = user.authToken; 151 } 152 153 api.getData('/v2/user/shoppinglists?favorites=true',headers).then(response => { 154 if(response.contents) { 155 const contents = response.contents; 156 const productIDs = Object.keys(response.contents); 157 myItemsIDs.push(...productIDs.map(item => contents[item].name)); 158 } 159 }) 160 .catch(error => { 161 console.error('Error posting data on clip coupon 664:', error); 162 }); 163 164 // try { 165 // const response = await $.ajax({
166 // type: 'GET', 167 // url: sitedata.svt_ajax_url, 168 // data: { action: 'get_my_items' }, 169 // dataType: 'json', 170 // cache: true 171 // }); 172 173 // if (response.my_items) { 174 // myItemsIDs.push(...response.my_items.map(item => item.name)); 175 // } 176 // } catch (error) { 177 // console.error('Error fetching my items:', error); 178 // } 179 } 180 } 181 182 async function fetchBuyAgainItems() { 183 if (buyAgainIDs.length === 0) { 184 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 185 186 var user = localStorage.getItem('user'); 187 user = JSON.parse(user); 188 189 let headers = { 190 'apikey': hsdata.hs_api_key, 191 'location': getCookie('selectedLocation'), 192 'pricelist': getCookie('selectedPriceList') 193 }; 194 195 if(user != null) { 196 headers.emailId = user.email; 197 headers.authToken = user.authToken; 198 } 199 200 api.getData('/user/items',headers).then(response => { 201 if(response.orderedItems) { 202 const orderedItems = response.orderedItems; 203 buyAgainIDs.push(...orderedItems.map(item => item.name)); 204 } 205 }) 206 .catch(error => { 207 console.error('Error posting data on clip coupon 664:', error); 208 }); 209 210 // try { 211 // const response = await $.ajax({
212 // type: 'GET', 213 // url: sitedata.svt_ajax_url, 214 // data: { action: 'load_buy_again', dataOnly: 1 }, 215 // dataType: 'json', 216 // cache: true 217 // }); 218 219 // if (response.data) { 220 // buyAgainIDs.push(...response.data.map(item => item.name)); 221 // } 222 // } catch (error) { 223 // console.error('Error fetching buy again items:', error); 224 // } 225 } 226 } 227 228 function renderLists(lists) { 229 let listItem = ''; 230 231 lists.forEach(list => { 232 if (list.displayName !== 'Favorites') { 233 var productIDs = []; 234 if (Object.keys(list.contents).length > 0) { 235 Object.values(list.contents).forEach(item => { 236 productIDs.push(item.name); 237 }); 238 } 239 const listProducts = allProducts.products.filter(product => productIDs.includes(product.name)); 240 const subTotal = listProducts.reduce((acc, product) => acc + parseFloat(product.price), 0); 241 const formattedDate = formatCreationDate(list.creationDate); 242 243 listItem += `<div class="svt-all-orders-list-item" data-id="${list.name}"> 244 <div class="svt-all-orders-header"> 245 <h6> 246 <span class="my-list-name">${list.displayName.replace(/\\/g, '')}</span> 247 <div class="svt-list-meta-info"> 248 <span>${formattedDate}</span> 249 <span class="list-items-count">${listProducts.length} Items</span> 250 <span class="list-items-total">\$${subTotal.toFixed(2)}</span> 251 </div> 252 </h6> 253 <a href="#" class="svt-list-detail-action" 254 data-products='${JSON.stringify(productIDs)}' 255 data-id="${list.name}" 256 data-date="${formattedDate}" 257 data-subtotal="${subTotal}" 258 data-name="${list.displayName}" 259 data-editname="${list.canUpdateDisplayName}" 260 data-delete="${list.canDelete}">Details 261 ${getDetailsIcon()} 262 </a> 263 </div>`; 264 265 if (listProducts.length) { 266 listItem += `<div class="svt-order-items">${renderListProducts(listProducts)}</div>`; 267 } 268 269 if(list.canDelete !== false) { 270 listItem += `<div class="svt-delete-list-wrap"> 271 <a href="javascript:void(0);" class="svt-delete-list" data-id="${list.name}" aria-label="Delete List"> 272 ${getDeleteIcon()} 273 </a> 274 </div>`; 275 } 276 listItem += `</div>`; 277 } 278 }); 279 280 if (listItem) { 281 $('.svt-profile-header-actions').show(); 282 $('.svt-my-lists-wrapper').append(listItem); 283 } else { 284 $('.svt-no-lists-wrapper').fadeIn(); 285 } 286 } 287 288 function formatCreationDate(dateString) { 289 const creationDate = new Date(dateString); 290 const day = creationDate.getUTCDate();
291 const month = creationDate.toLocaleString('default', { month: 'short' }); 292 const year = creationDate.getUTCFullYear(); 293 const hours = creationDate.getUTCHours() % 12 || 12; 294 const minutes = creationDate.getUTCMinutes().toString().padStart(2, '0'); 295 const ampm = creationDate.getUTCHours() >= 12 ? 'PM' : 'AM'; 296 297 return `${day} ${month} ${year}, ${hours}:${minutes} ${ampm}`; 298 } 299 300 function getDetailsIcon() { 301 return `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> 302 <path fill-rule="evenodd" clip-rule="evenodd" 303 d="M8.46967 5.46967C8.76256 5.17678 9.23744 5.17678 9.53033 5.46967L15.5303 11.4697C15.8232 11.7626 15.8232 12.2374 15.5303 12.5303L9.53033 18.5303C9.23744 18.8232 8.76256 18.8232 8.46967 18.5303C8.17678 18.2374 8.17678 17.7626 8.46967 17.4697L13.9393 12L8.46967 6.53033C8.17678 6.23744 8.17678 5.76256 8.46967 5.46967Z" 304 fill="#CB333B" /> 305 </svg>`; 306 } 307 308 function getDeleteIcon() { 309 return `<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> 310 <path d="M10 10.25C10.4142 10.25 10.75 10.5858 10.75 11V17C10.75 17.4142 10.4142 17.75 10 17.75C9.58579 17.75 9.25 17.4142 9.25 17V11C9.25 10.5858 9.58579 10.25 10 10.25Z" fill="#767676"/> 311 <path d="M14.75 11C14.75 10.5858 14.4142 10.25 14 10.25C13.5858 10.25 13.25 10.5858 13.25 11V17C13.25 17.4142 13.5858 17.75 14 17.75C14.4142 17.75 14.75 17.4142 14.75 17V11Z" fill="#767676"/> 312 <path fill-rule="evenodd" clip-rule="evenodd" d="M7.25 5.25V4C7.25 3.27065 7.53973 2.57118 8.05546 2.05546C8.57118 1.53973 9.27065 1.25 10 1.25H14C14.7293 1.25 15.4288 1.53973 15.9445 2.05546C16.4603 2.57118 16.75 3.27065 16.75 4V5.25H21C21.4142 5.25 21.75 5.58579 21.75 6C21.75 6.41421 21.4142 6.75 21 6.75H19.75V20C19.75 20.7293 19.4603 21.4288 18.9445 21.9445C18.4288 22.4603 17.7293 22.75 17 22.75H7C6.27065 22.75 5.57118 22.4603 5.05546 21.9445C4.53973 21.4288 4.25 20.7293 4.25 20V6.75H3C2.58579 6.75 2.25 6.41421 2.25 6C2.25 5.58579 2.58579 5.25 3 5.25H7.25ZM9.11612 3.11612C9.35054 2.8817 9.66848 2.75 10 2.75H14C14.3315 2.75 14.6495 2.8817 14.8839 3.11612C15.1183 3.35054 15.25 3.66848 15.25 4V5.25H8.75V4C8.75 3.66848 8.8817 3.35054 9.11612 3.11612ZM5.75 6.75H18.25V20C18.25 20.3315 18.1183 20.6495 17.8839 20.8839C17.6495 21.1183 17.3315 21.25 17 21.25H7C6.66848 21.25 6.35054 21.1183 6.11612 20.8839C5.8817 20.6495 5.75 20.3315 5.75 20V6.75Z" fill="#767676"/> 313 </svg>`; 314 } 315 316 window.addEventListener('CACHE_DATA_READY', function(event) { 317 console.log('my list products ready'); 318 if($('.svt-my-lists-wrapper').length) { 319 refreshMyLists(); 320 } 321 }); 322 $(document).ready(function() { 323 $(document).on('click','.create-list-action',function() { 324 $('.svt-create-list-popup').fadeIn(); 325 $('.svt-create-list-popup input[name="list_name"]').val(''); 326 return false; 327 }); 328 329 $(document).on('click','.edit-list-name-action',function() { 330 const listID = $(this).attr('data-id'); 331 $('.svt-edit-list-name-popup').fadeIn(); 332 $('.svt-edit-list-name-popup').attr('data-id',listID); 333 return false; 334 }); 335 336 $(document).on('click','.cancel-list',function() { 337 $('.svt-create-list-popup').fadeOut(); 338 $('.svt-edit-list-name-popup').fadeOut(); 339 return false; 340 }); 341 342 $('#svt-create-list-form').validate({ 343 errorPlacement: function(error, element) { 344 var inputBox = $(element).parents().closest('.svt-field-box'); 345 if(inputBox.length) { 346 error.insertAfter(inputBox); 347 } 348 else { 349 error.insertAfter(element); 350 } 351 }, 352 submitHandler: function(form) { 353 $(form).addClass('loading'); 354 355 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 356 357 var user = localStorage.getItem('user'); 358 user = JSON.parse(user); 359 360 let headers = { 361 'apikey': hsdata.hs_api_key, 362 'location': getCookie('selectedLocation'), 363 'content-type': 'application/json' 364 }; 365 366 if(user != null) { 367 headers.emailId = user.email; 368 headers.authToken = user.authToken; 369 } 370 371 let body = { 372 "canDelete": true, 373 "canUpdateDisplayName": true, 374 "displayName": $(form).find('input[name="list_name"]').val() 375 } 376 377 api.postData('/v2/user/shoppinglists', body, headers).then(response => { 378 $(form).removeClass('loading'); 379 if(response.lists) { 380 sessionStorage.setItem('shoppingLists', JSON.stringify(response.lists)); 381 $('.svt-create-list-popup').fadeOut(); 382 refreshMyLists(response.lists); 383 } 384 }) 385 .catch(error => { 386 $(form).removeClass('loading'); 387 console.error('Error creating new list:', error); 388 }); 389 390 // $.ajax({
391 // type: 'POST', 392 // url: sitedata.svt_ajax_url, 393 // data: $(form).serialize(), 394 // dataType: 'json', 395 // beforeSend: function() { 396 // $(form).addClass('loading'); 397 // }, 398 // success: function( response ) { 399 // $(form).removeClass('loading'); 400 // if(response.success == 1) { 401 // $('.svt-create-list-popup').fadeOut(); 402 // refreshMyLists(); 403 // } 404 // else { 405 406 // } 407 // }, 408 // error: function() { 409 // $(form).removeClass('loading'); 410 // } 411 // }); 412 return false; 413 } 414 }); 415 416 $('#svt-edit-list-name-form').validate({ 417 errorPlacement: function(error, element) { 418 var inputBox = $(element).parents().closest('.svt-field-box'); 419 if(inputBox.length) { 420 error.insertAfter(inputBox); 421 } 422 else { 423 error.insertAfter(element); 424 } 425 }, 426 submitHandler: function(form) { 427 $(form).addClass('loading'); 428 429 const listID = $('.svt-edit-list-name-popup').attr('data-id'); 430 431 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 432 433 var user = localStorage.getItem('user'); 434 user = JSON.parse(user); 435 436 email = user.email; 437 email = email.replace('^',''); 438 439 const listName = $(form).find('input[name="list_name"]').val(); 440 441 let body = { 442 "name": listID, 443 "params": { 444 "displayName": listName 445 } 446 } 447 448 let headers = { 449 'emailid': email, 450 'authToken': user.authToken, 451 'location': getCookie('selectedLocation'), 452 'Content-Type': 'application/json' 453 }; 454 455 456 api.putData('/v2/user/shoppinglists',body,headers).then(response => { 457 $(form).removeClass('loading'); 458 if(response.lists) { 459 sessionStorage.setItem('shoppingLists', JSON.stringify(response.lists)); 460 $('.svt-edit-list-name-popup').fadeOut(); 461 $('.my-list-name').html(listName); 462 $('.svt-all-orders-list-item[data-id="'+listID+'"] .svt-all-orders-header .my-list-name').html(listName); 463 } 464 }) 465 .catch(error => { 466 console.error('Error posting data on clip coupon 664:', error); 467 }); 468 return false; 469 } 470 }); 471 472 $(document).on('click','.svt-delete-list',function() { 473 var parent = $(this).parents().closest('.svt-all-orders-list-item'); 474 var id = $(this).data('id'); 475 Swal.fire({ 476 title: "Delete List?", 477 html: "<p>Are you sure you want to delete this list? All items in this list will be permanently removed. This action cannot be undone.</p>", 478 showCancelButton: true, 479 confirmButtonColor: "#D60000", 480 cancelButtonColor: "transparent", 481 confirmButtonText: "Delete", 482 reverseButtons: true, 483 customClass: "swal-delete-account", 484 animation: false, 485 allowOutsideClick: false, 486 allowEscapeKey: false, 487 }).then((result) => { 488 if (result.isConfirmed) { 489 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 490 491 var user = localStorage.getItem('user'); 492 user = JSON.parse(user); 493 494 let headers = { 495 'apikey': hsdata.hs_api_key, 496 'location': getCookie('selectedLocation'), 497 'content-type': 'application/json' 498 }; 499 500 if(user != null) { 501 headers.emailId = user.email; 502 headers.authToken = user.authToken; 503 } 504 505 let body = { 506 "name": id 507 } 508 509 api.deleteData('/v2/user/shoppinglists', body, headers).then(response => { 510 if(response.lists) { 511 sessionStorage.setItem('shoppingLists', JSON.stringify(response.lists)); 512 parent.fadeOut(400,function() { 513 $(this).remove(); 514 }); 515 } 516 }) 517 .catch(error => { 518 $(form).removeClass('loading'); 519 console.error('Error deleting list:', error); 520 }); 521 // $.ajax({
522 // type: 'POST', 523 // url: sitedata.svt_ajax_url, 524 // data: { 525 // action: 'delete_my_list', 526 // id: id 527 // }, 528 // dataType: 'json', 529 // beforeSend: function() {}, 530 // success: function( response ) { 531 // if(response.success) { 532 // parent.fadeOut(400,function() { 533 // $(this).remove(); 534 // }); 535 // } 536 // } 537 // }); 538 } 539 }); 540 return false; 541 }); 542 543 $(document).on('click','.svt-delete-list-detail',function() { 544 var id = $(this).data('id'); 545 Swal.fire({ 546 title: "Delete List?", 547 html: "<p>Are you sure you want to delete this list? All items in this list will be permanently removed. This action cannot be undone.</p>", 548 showCancelButton: true, 549 confirmButtonColor: "#D60000", 550 cancelButtonColor: "transparent", 551 confirmButtonText: "Delete", 552 reverseButtons: true, 553 customClass: "swal-delete-account", 554 animation: false, 555 allowOutsideClick: false, 556 allowEscapeKey: false, 557 }).then((result) => { 558 if (result.isConfirmed) { 559 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 560 561 var user = localStorage.getItem('user'); 562 user = JSON.parse(user); 563 564 let headers = { 565 'apikey': hsdata.hs_api_key, 566 'location': getCookie('selectedLocation'), 567 'content-type': 'application/json' 568 }; 569 570 if(user != null) { 571 headers.emailId = user.email; 572 headers.authToken = user.authToken; 573 } 574 575 let body = { 576 "name": id 577 } 578 579 api.deleteData('/v2/user/shoppinglists', body, headers).then(response => { 580 if(response.lists) { 581 sessionStorage.setItem('shoppingLists', JSON.stringify(response.lists)); 582 $('.svt-my-list-title-back').trigger('click'); 583 $('.svt-all-orders-list-item[data-id="'+id+'"]').fadeOut(400,function() { 584 $(this).remove(); 585 }); 586 } 587 }) 588 .catch(error => { 589 console.error('Error deleting list from detail:', error); 590 }); 591 // $.ajax({ 592 // type: 'POST', 593 // url: sitedata.svt_ajax_url, 594 // data: { 595 // action: 'delete_my_list', 596 // id: id 597 // }, 598 // dataType: 'json', 599 // beforeSend: function() {}, 600 // success: function( response ) { 601 // if(response.success) { 602 // $('.svt-my-list-title-back').trigger('click'); 603 // $('.svt-all-orders-list-item[data-id="'+id+'"]').fadeOut(400,function() { 604 // $(this).remove(); 605 // }); 606 // } 607 // } 608 // }); 609 } 610 }); 611 return false; 612 }); 613 614 // var products = ''; 615 616 // var dataChecker = setInterval(async function() { 617 // try { 618 // const data = await getDataFromIndexedDB('products'); 619 // if (data) { 620 // clearInterval(dataChecker); 621 // products = data.products; 622 // if ($('.svt-my-lists-wrapper').length) { 623 // refreshMyLists();
624 // } 625 // } 626 // } catch (error) { 627 // console.error('Error fetching products from IndexedDB:', error); 628 // } 629 // }, 1000); 630 631 632 if($('.svt-my-lists-wrapper').length) { 633 var renderListProductCard = function( product ) { 634 var html = ''; 635 var productID = product.name; 636 var imgName = product.mainImage; 637 if(typeof imgName == "undefined" || imgName == null) { 638 imgName = productID; 639 } 640 var productImg = 'https://s3-us-west-2.amazonaws.com/www.gethomesome.com/productimages_tn/'+imgName+'.jpg'; 641 let escapedData = JSON.stringify(product).replace(/'/g, "'"); 642 html += `<div class="svt-product-box style-list"> 643 <div class="svt-product-img-wrap"> 644 <a href="${embeddata.product}?product=${productID}"> 645 <img src="${productImg}" onerror="this.onerror=null; this.className='placeholder-img'; this.src='${embeddata.theme_url}/images/nophoto-v2.svg'" alt="" /> 646 </a> 647 </div> 648 <div class="svt-product-info-wrap"> 649 <input type="hidden" name="productObj" value='${JSON.stringify(product)}'> 650 <h6>${product.displayName}</h6> 651 <div class="svt-product-price">\$${product.price}</div> 652 <div class="svt-product-short-desc"> 653 </div> 654 <div class="svt-product-remove-list"> 655 <a href="#" class="svt-product-remove-from-list" data-id="${productID}"> 656 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> 657 <path d="M10 10.25C10.4142 10.25 10.75 10.5858 10.75 11V17C10.75 17.4142 10.4142 17.75 10 17.75C9.58579 17.75 9.25 17.4142 9.25 17V11C9.25 10.5858 9.58579 10.25 10 10.25Z" fill="#767676"/> 658 <path d="M14.75 11C14.75 10.5858 14.4142 10.25 14 10.25C13.5858 10.25 13.25 10.5858 13.25 11V17C13.25 17.4142 13.5858 17.75 14 17.75C14.4142 17.75 14.75 17.4142 14.75 17V11Z" fill="#767676"/> 659 <path fill-rule="evenodd" clip-rule="evenodd" d="M7.25 5.25V4C7.25 3.27065 7.53973 2.57118 8.05546 2.05546C8.57118 1.53973 9.27065 1.25 10 1.25H14C14.7293 1.25 15.4288 1.53973 15.9445 2.05546C16.4603 2.57118 16.75 3.27065 16.75 4V5.25H21C21.4142 5.25 21.75 5.58579 21.75 6C21.75 6.41421 21.4142 6.75 21 6.75H19.75V20C19.75 20.7293 19.4603 21.4288 18.9445 21.9445C18.4288 22.4603 17.7293 22.75 17 22.75H7C6.27065 22.75 5.57118 22.4603 5.05546 21.9445C4.53973 21.4288 4.25 20.7293 4.25 20V6.75H3C2.58579 6.75 2.25 6.41421 2.25 6C2.25 5.58579 2.58579 5.25 3 5.25H7.25ZM9.11612 3.11612C9.35054 2.8817 9.66848 2.75 10 2.75H14C14.3315 2.75 14.6495 2.8817 14.8839 3.11612C15.1183 3.35054 15.25 3.66848 15.25 4V5.25H8.75V4C8.75 3.66848 8.8817 3.35054 9.11612 3.11612ZM5.75 6.75H18.25V20C18.25 20.3315 18.1183 20.6495 17.8839 20.8839C17.6495 21.1183 17.3315 21.25 17 21.25H7C6.66848 21.25 6.35054 21.1183 6.11612 20.8839C5.8817 20.6495 5.75 20.3315 5.75 20V6.75Z" fill="#767676"/> 660 </svg> 661 </a> 662 </div> 663 </div> 664 <div class="svt-product-bulk-action"> 665 <label class="svt-custom-checkbox"> 666 <input type="checkbox" data-price="${product.price}" value='${escapedData}' checked> 667 <span class="checkmark"></span> 668 </label> 669 </div> 670 </div>`; 671 return html; 672 } 673 674 var renderPopupProductCard = function( product, currentListProducIDs ) { 675 var html = ''; 676 var productID = product.name; 677 var imgName = product.mainImage;
678 if(typeof imgName == "undefined" || imgName == null) { 679 imgName = productID; 680 } 681 var added = ''; 682 if(currentListProducIDs.includes(productID)) { 683 added = 'added'; 684 } 685 var productImg = 'https://s3-us-west-2.amazonaws.com/www.gethomesome.com/productimages_tn/'+imgName+'.jpg'; 686 var type = sanitizeTitle(product.type); 687 html += `<div class="svt-product-box ${type}"> 688 <div class="svt-product-img-wrap"> 689 <a href="${embeddata.product}?product=${productID}"> 690 <img src="${productImg}" onerror="this.onerror=null; this.className='placeholder-img'; this.src='${embeddata.theme_url}/images/nophoto-v2.svg'" alt="" /> 691 </a> 692 </div> 693 <div class="svt-product-add-to-list ${added}"> 694 <a href="#" class="svt-add-to-list-action" data-id="${productID}">
695 <svg width="11" height="11" viewBox="0 0 11 11" fill="currentColor" xmlns="http://www.w3.org/2000/svg" class="ng-scope"><g id="Group 347"><path id="Vector" d="M5.66699 1V10.3333" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path><path id="Vector_2" d="M1 5.66699H10.3333" stroke="currentColor" stroke-width="1.3" stroke-linecap="round" stroke-linejoin="round"></path></g></svg> 696 <span>Add</span> 697 </a> 698 <a href="#" class="remove-from-list-action" data-id="${productID}"> 699 <span>Added</span> 700 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> 701 <path 702 d="M9 15L3 9M3 9L9 3M3 9H15C16.5913 9 18.1174 9.63214 19.2426 10.7574C20.3679 11.8826 21 13.4087 21 15C21 16.5913 20.3679 18.1174 19.2426 19.2426C18.1174 20.3679 16.5913 21 15 21H12" 703 stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" /> 704 </svg> 705 </a> 706 </div> 707 <div class="svt-product-info-wrap"> 708 <div class="svt-product-price">\$${product.price}</div> 709 <h6>${product.displayName}</h6> 710 </div> 711 </div>`; 712 return html; 713 } 714 715 // $(document).on('click','.svt-list-detail-action',function() { 716 // var id = $(this).data('id'); 717 // var name = $(this).data('name'); 718 // var formattedDate = $(this).data('date'); 719 // var subTotal = $(this).data('subtotal'); 720 // subTotal = subTotal.toFixed(2); 721 // var name = $(this).data('name'); 722 // name = name.replace(/\\/g, ''); 723 // var productIDs = $(this).data('products'); 724 // // productIDs = productIDs.split(','); 725 // currentListProducIDs = productIDs; 726 // var listProducts = []; 727 // if(productIDs.length) { 728 // var productsData = allProducts.products; 729 // listProducts = productsData.filter(obj => productIDs.includes(obj.name)); 730 // } 731 // // console.log(listProducts); 732 // var productCount = listProducts.length; 733 // $('.svt-delete-list-detail').attr('data-id',id); 734 735 // name += ' ('+productCount+')'; 736 // name += `<div class="svt-list-meta-info"> 737 // <span>${formattedDate}</span> 738 // <span>${productCount} Items</span> 739 // <span>\$${subTotal}</span> 740 // </div>`; 741 // $('.my-account-page-title-heading').hide(); 742 // $('.svt-my-list-heading-title').html(name); 743 // $('.svt-list-detail-title-h1').addClass('active'); 744 // $('.svt-my-lists-wrapper').hide(); 745 // $('.my-list-details-wrap').show(); 746 // $('.my-list-details-wrap').attr('data-id',id); 747 // // var subTotal = productsData.reduce((accumulator, product) => { 748 // // return accumulator + parseFloat(product.price); 749 // // }, 0); 750 // if(listProducts.length == 0) { 751 // $('.my-list-detail-products').hide(); 752 // $('.svt-no-list-product-wrapper').show(); 753 // } 754 // else { 755 // let groupedItems = listProducts.reduce((acc, item) => { 756 // let key = `No Position: ${item.type}`; 757 // if(typeof item.locationInStore != "undefined") { 758 // key = 'Aisle '+item.locationInStore.position; 759 // } 760 761 // if (!acc[key]) { 762 // acc[key] = []; 763 // } 764 765 // acc[key].push(item); 766 // return acc; 767 // }, {}); 768 769 // // Sort keys, prioritizing those with positions 770 // let sortedKeys = Object.keys(groupedItems).sort((a, b) => { 771 // // Sort items with positions first (numeric sort), then group "No Position" items at the end 772 // if (a.startsWith("No Position")) return 1; 773 // if (b.startsWith("No Position")) return -1; 774 // return a.localeCompare(b); 775 // }); 776 777 // $('.svt-no-list-product-wrapper').hide(); 778 // $('.my-list-detail-products').show(); 779 // var html = ''; 780 // $.each(sortedKeys, function(index,key) { 781 // var groupedProducts = groupedItems[key]; 782 // html += '<div class="my-list-product-groups">'; 783 // html += '<div class="my-list-product-groups-container">'; 784 // html += '<div class="my-list-product-groups-header">'; 785 // html += '<h6>'+key.replace('No Position: ',''); 786 // var itemsTxt = 'item'; 787 // if(groupedProducts.length > 1) { 788 // itemsTxt = 'items'; 789 // } 790 // html += '<span>'+groupedProducts.length+' '+itemsTxt+'</span>'; 791 // html += '</h6>'; 792 // html += '</div>'; 793 // html += '<div class="my-list-product-group-products">'; 794 // $.each(groupedProducts, function(pindex,product) { 795 // html += renderListProductCard(product); 796 // }); 797 // html += '</div>'; 798 // html += '</div>'; 799 // html += '</div>'; 800 // }); 801 // html += `<div class="list-bulk-add-cart-wrap"> 802 // <a href="#" class="list-bulk-add-cart"> 803 // <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> 804 // <path d="M12.75 5C12.75 4.58579 12.4142 4.25 12 4.25C11.5858 4.25 11.25 4.58579 11.25 5V11.25H5C4.58579 11.25 4.25 11.5858 4.25 12C4.25 12.4142 4.58579 12.75 5 12.75H11.25V19C11.25 19.4142 11.5858 19.75 12 19.75C12.4142 19.75 12.75 19.4142 12.75 19V12.75H19C19.4142 12.75 19.75 12.4142 19.75 12C19.75 11.5858 19.4142 11.25 19 11.25H12.75V5Z" fill="white"/> 805 // </svg>
806 // <span>Add <span class="product-count">${productCount}</span> to Cart <span class="subtotal">(\$${subTotal})</span></span> 807 // </a> 808 // </div>`; 809 // $('.my-list-detail-products').html(html); 810 // } 811 812 // return false; 813 // }); 814 815 function loadListDetails(element, productIDs) { 816 const id = $(element).attr('data-id'); 817 const editname = $(element).attr('data-editname'); 818 const candelete = $(element).attr('data-delete'); 819 let name = $(element).attr('data-name').replace(/\\/g, ''); 820 name = '<span class="my-list-name">'+name+'</span>'; 821 const formattedDate = $(element).attr('data-date'); 822 let subTotal = getSubTotal(); 823 if(typeof productIDs == "undefined" || productIDs.length == 0) { 824 productIDs = $(element).attr('data-products'); 825 productIDs = JSON.parse(productIDs); 826 if(productIDs.length > 0) { 827 subTotal = parseFloat($(element).attr('data-subtotal')); 828 } 829 } 830 831 subTotal = subTotal.toFixed(2); 832 833 currentListProducIDs = productIDs; 834 835 let listProducts = []; 836 if (productIDs.length) { 837 const productsData = allProducts.products; 838 listProducts = productsData.filter(obj => productIDs.includes(obj.name)); 839 } 840 841 const productCount = listProducts.length; 842 $('.svt-delete-list-detail').attr('data-id', id); 843 $('.edit-list-name-action').attr('data-id', id); 844 845 if(editname == "false") { 846 $('.edit-list-name-action').hide(); 847 } 848 else { 849 $('.edit-list-name-action').show(); 850 } 851 852 if(candelete == "false") { 853 $('.svt-delete-list-detail').hide(); 854 } 855 else { 856 $('.svt-delete-list-detail').show(); 857 } 858 859 name += ` (${productCount})<div class="svt-list-meta-info"> 860 <span>${formattedDate}</span> 861 <span>${productCount} Items</span> 862 <span>\$${subTotal}</span> 863 </div>`; 864 $('.my-account-page-title-heading').hide(); 865 $('.svt-my-list-heading-title').html(name); 866 $('.svt-list-detail-title-h1').addClass('active'); 867 $('.svt-my-lists-wrapper').hide(); 868 $('.my-list-details-wrap').show().attr('data-id', id); 869 870 if (listProducts.length === 0) { 871 $('.my-list-detail-products').hide(); 872 $('.svt-no-list-product-wrapper').show(); 873 } else { 874 let groupedItems = listProducts.reduce((acc, item) => { 875 let key = `${item.type}`; 876 if (typeof item.locationInStore !== "undefined") { 877 if(typeof item.locationInStore.position !== "undefined" && item.locationInStore.position != "") { 878 key = 'Aisle ' + item.locationInStore.position; 879 } 880 } 881 if (!acc[key]) acc[key] = []; 882 acc[key].push(item); 883 return acc; 884 }, {}); 885 886 let sortedKeys = Object.keys(groupedItems).sort((a, b) => { 887 // if (a.startsWith("No Position")) return 1; 888 // if (b.startsWith("No Position")) return -1; 889 return a.localeCompare(b); 890 }); 891 892 $('.svt-no-list-product-wrapper').hide(); 893 $('.my-list-detail-products').show(); 894 let html = ''; 895 sortedKeys.forEach(key => { 896 const groupedProducts = groupedItems[key]; 897 html += `<div class="my-list-product-groups"> 898 <div class="my-list-product-groups-container"> 899 <div class="my-list-product-groups-header"> 900 <h6>${key.replace('No Position: ', '')}
901 <span>${groupedProducts.length} ${groupedProducts.length > 1 ? 'items' : 'item'}</span> 902 </h6> 903 </div> 904 <div class="my-list-product-group-products">`; 905 groupedProducts.forEach(product => { 906 html += renderListProductCard(product); 907 }); 908 html += '</div></div></div>'; 909 }); 910 911 html += `<div class="list-bulk-add-cart-wrap"> 912 <a href="#" class="list-bulk-add-cart"> 913 <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"> 914 <path d="M12.75 5C12.75 4.58579 12.4142 4.25 12 4.25C11.5858 4.25 11.25 4.58579 11.25 5V11.25H5C4.58579 11.25 4.25 11.5858 4.25 12C4.25 12.4142 4.58579 12.75 5 12.75H11.25V19C11.25 19.4142 11.5858 19.75 12 19.75C12.4142 19.75 12.75 19.4142 12.75 19V12.75H19C19.4142 12.75 19.75 12.4142 19.75 12C19.75 11.5858 19.4142 11.25 19 11.25H12.75V5Z" fill="white"/> 915 </svg> 916 <span>Add <span class="product-count">${productCount}</span> to Cart <span class="subtotal">(\$${subTotal})</span></span> 917 </a> 918 </div>`; 919 $('.my-list-detail-products').html(html); 920 } 921 } 922 923 $(document).on('click', '.svt-list-detail-action', function() { 924 loadListDetails(this); 925 return false; 926 }); 927 928 929 $(document).on('click','.svt-my-list-title-back',function() { 930 $('.my-list-details-wrap').hide(); 931 $('.svt-my-lists-wrapper').show(); 932 $('.svt-list-detail-title-h1').removeClass('active'); 933 $('.my-account-page-title-heading').show(); 934 return false; 935 }); 936 937 $(document).on('click','.edit-list-action',function() { 938 $('.svt-edit-list-popup').fadeIn(); 939 $('body').addClass('svt-popup-active'); 940 // $('.edit-list-products-list .svt-product-box:not(.shimmer-product-boxes)').remove(); 941 // $('.edit-list-products-list .shimmer-product-boxes').show(); 942 $('.svt-profile-category-filter-carousel-el').removeClass('slick-initialized slick-slider'); 943 $('.edit-listing-details-wrapper').hide(); 944 $('.edit-listing-back-wrapper').hide(); 945 $('.edit-list-products-listing-wrapper').show(); 946 $('.edit-list-search-wrap input').val(''); 947 $('.edit-list-start-search-wrap').show(); 948 $('.edit-list-search-wrap .cancel-edit-list-search').hide(); 949 $('.edit-listing-search-detais-wrapper').hide(); 950 $('.edit-list-search-screen').removeClass('active'); 951 var productsDataFull = allProducts.products; 952 var productsData = allProducts.products; 953 productsData = productsData.slice(0,6); 954 var myItemshtml = ''; 955 var buyAgainhtml = ''; 956 var otherItemshtml = ''; 957 if(allProducts != '') { 958 if(myItemsIDs.length) { 959 $('.my-items-wrapper').show(); 960 var myItems = productsDataFull.filter(obj =>
960 myItemsIDs.includes(obj.name)); 961 myItems = myItems.slice(0,6); 962 $.each(myItems, function(index,product) { 963 myItemshtml += renderPopupProductCard(product, currentListProducIDs); 964 }); 965 if(myItemshtml != '') { 966 $('.my-items-wrapper .product-list-header').removeClass('svt-d-none'); 967 $('.list-my-items-products .shimmer-product-boxes').hide(); 968 $('.list-my-items-products').html(myItemshtml); 969 } 970 else { 971 $('.my-items-wrapper').hide(); 972 $('.list-my-items-products .shimmer-product-boxes').hide(); 973 } 974 } 975 else { 976 $('.my-items-wrapper').hide(); 977 $('.list-my-items-products .shimmer-product-boxes').hide(); 978 } 979 if(buyAgainIDs.length) { 980 $('.buy-again-items-wrapper').show(); 981 var buyAgainItems = productsDataFull.filter(obj => buyAgainIDs.includes(obj.name)); 982 buyAgainItems = buyAgainItems.slice(0,6); 983 $.each(buyAgainItems, function(index,product) { 984 buyAgainhtml += renderPopupProductCard(product, currentListProducIDs); 985 }); 986 if(buyAgainhtml != '') { 987 $('.buy-again-items-wrapper .product-list-header').removeClass('svt-d-none'); 988 $('.list-buy-again-products').html(buyAgainhtml); 989 } 990 else { 991 $('.buy-again-items-wrapper').hide(); 992 $('.list-buy-again-products .shimmer-product-boxes').hide(); 993 } 994 } 995 else { 996 $('.buy-again-items-wrapper').hide(); 997 $('.list-buy-again-products .shimmer-product-boxes').hide(); 998 } 999 $.each(productsData, function(index,product) { 1000 otherItemshtml += renderPopupProductCard(product, currentListProducIDs); 1001 }); 1002 $('.edit-list-products-list.list-other-products .shimmer-product-boxes').hide(); 1003 $('.trending-items-wrapper .product-list-header').removeClass('svt-d-none'); 1004 $('.edit-list-products-list.list-other-products').html(otherItemshtml); 1005 var subtotal = getSubTotal(); 1006 var productCount = getProductCount(); 1007 $('.edit-listing-stats .subtotal').html('$'+subtotal.toFixed(2)); 1008 $('.edit-listing-stats .items-count').html('('+productCount+' Items)'); 1009 } 1010 return false; 1011 }); 1012 1013 $(document).on('click','.product-list-view-all',function() { 1014 var type = $(this).data('type'); 1015 var productsDataFull = allProducts.products; 1016 1017 $('.edit-list-products-listing-wrapper').hide(); 1018 $('.edit-listing-details-wrapper').show(); 1019 $('.edit-listing-back-wrapper').show(); 1020 if(type == 'my-items') { 1021 var html = ''; 1022 var myItems = productsDataFull.filter(obj =>
1022 myItemsIDs.includes(obj.name)); 1023 var types = [...new Set(myItems.map(product => product.type))].sort(); 1024 var catHtml = `<div class="svt-profile-category-filter-box active swiper-slide"> 1025 <div class="svt-profile-category-filter-img"> 1026 <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"> 1027 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 12.5763C10.457 11.4048 11.4067 10.4551 12.5782 10.4551H16.8207C17.9922 10.4551 18.9419 11.4048 18.9419 12.5763V16.8187C18.9419 17.9902 17.9922 18.9399 16.8207 18.9399H12.5782C11.4067 18.9399 10.457 17.9902 10.457 16.8187V12.5763ZM12.5782 12.046H16.8207C17.1135 12.046 17.351 12.2834 17.351 12.5763V16.8187C17.351 17.1116 17.1135 17.349 16.8207 17.349H12.5782C12.2854 17.349 12.0479 17.1116 12.0479 16.8187V12.5763C12.0479 12.2834 12.2854 12.046 12.5782 12.046Z" fill="#CB333B"/> 1028 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 23.1824C10.457 22.0108 11.4067 21.0611 12.5782 21.0611H16.8207C17.9922 21.0611 18.9419 22.0108 18.9419 23.1824V27.4248C18.9419 28.5963 17.9922 29.546 16.8207 29.546H12.5782C11.4067 29.546 10.457 28.5963 10.457 27.4248V23.1824ZM12.5782 22.652H16.8207C17.1135 22.652 17.351 22.8895 17.351 23.1824V27.4248C17.351 27.7177 17.1135 27.9551 16.8207 27.9551H12.5782C12.2854 27.9551 12.0479 27.7177 12.0479 27.4248V23.1824C12.0479 22.8895 12.2854 22.652 12.5782 22.652Z" fill="#CB333B"/> 1029 <path fill-rule="evenodd" clip-rule="evenodd" d="M23.1843 10.4551C22.0128 10.4551 21.0631 11.4048 21.0631 12.5763V16.8187C21.0631 17.9902 22.0128 18.9399 23.1843 18.9399H27.4267C28.5982 18.9399 29.5479 17.9902 29.5479 16.8187V12.5763C29.5479 11.4048 28.5982 10.4551 27.4267 10.4551H23.1843ZM27.4267 12.046H23.1843C22.8914 12.046 22.654 12.2834 22.654 12.5763V16.8187C22.654 17.1116 22.8914 17.349 23.1843 17.349H27.4267C27.7196 17.349 27.957 17.1116 27.957 16.8187V12.5763C27.957 12.2834 27.7196 12.046 27.4267 12.046Z" fill="#CB333B"/> 1030 <path fill-rule="evenodd" clip-rule="evenodd" d="M21.0631 23.1824C21.0631 22.0108 22.0128 21.0611 23.1843 21.0611H27.4267C28.5982 21.0611 29.5479 22.0108 29.5479 23.1824V27.4248C29.5479 28.5963 28.5982 29.546 27.4267 29.546H23.1843C22.0128 29.546 21.0631 28.5963 21.0631 27.4248V23.1824ZM23.1843 22.652H27.4267C27.7196 22.652 27.957 22.8895 27.957 23.1824V27.4248C27.957 27.7177 27.7196 27.9551 27.4267 27.9551H23.1843C22.8914 27.9551 22.654 27.7177 22.654 27.4248V23.1824C22.654 22.8895 22.8914 22.652 23.1843 22.652Z" fill="#CB333B"/> 1031 </svg> 1032 </div> 1033 <h6>Shop All</h6> 1034 </div>`; 1035 $.each(types,function(index,cat) { 1036 $catSlug = sanitizeTitle(cat); 1037 $categoryImgs = JSON.parse(sitedata.categoryImgs); 1038 $catImg = ''; 1039 if($categoryImgs[$catSlug]) { 1040 $catImg = $categoryImgs[$catSlug]; 1041 } 1042 catHtml += `<div class="svt-profile-category-filter-box swiper-slide" data-name="${$catSlug}"> 1043 <div class="svt-profile-category-filter-img"> 1044 <img src="${$catImg}" alt=""> 1045 </div> 1046 <h6>${cat}</h6> 1047 </div>`; 1048 }); 1049 $('.svt-profile-category-filter-carousel-el').html(catHtml); 1050 if($('.svt-profile-category-filter-carousel-el').length) { 1051 var swiperEditList = new Swiper('.swiper-edit-list', { 1052 direction: 'horizontal', 1053 slidesPerView: 6, 1054 spaceBetween: 10, 1055 loop: false, 1056 navigation: { 1057 nextEl: '.swiper-button-next', 1058 prevEl: '.swiper-button-prev', 1059 }, 1060 breakpoints: { 1061 1100: { 1062 slidesPerView: 6, 1063 }, 1064 1024: { 1065 slidesPerView: 5.5, 1066 }, 1067 768: { 1068 slidesPerView: 4.5, 1069 }, 1070 640: { 1071 slidesPerView: 3.5, 1072 navigation: { 1073 enabled: false, // Disable navigation on mobile 1074 }, 1075 }, 1076 0: { 1077 slidesPerView: 3.5, 1078 navigation: { 1079 enabled: false, // Disable navigation on mobile 1080 }, 1081 }, 1082 }, 1083 });
1084 function checkArrowsVisibilityEditList() { 1085 const totalSlidesEditList = swiperEditList.slides.length; // Total number of slides 1086 const slidesToShowEditList = swiperEditList.params.slidesPerView; // Slides per view 1087 1088 // Determine if arrows should be shown 1089 const showArrowsEditList = totalSlidesEditList > slidesToShowEditList; 1090 1091 // Add or remove class on the Swiper container based on arrow visibility 1092 const swiperContainerEditList = document.querySelector('.swiper-edit-list'); 1093 if (!showArrowsEditList) { 1094 swiperContainerEditList.classList.add('no-arrows'); 1095 } else { 1096 swiperContainerEditList.classList.remove('no-arrows'); 1097 } 1098 } 1099 1100 // Call this function on initialization and on window resize 1101 checkArrowsVisibilityEditList(); 1102 window.addEventListener('resize', checkArrowsVisibilityEditList); 1103 } 1104 /*$('.svt-profile-category-filter-carousel-el').slick({ 1105 slidesToShow: 9, 1106 infinite: false, 1107 slidesToScroll: 1, 1108 arrows: true, 1109 dots: false, 1110 });*/ 1111 1112 $.each(myItems, function(index,product) { 1113 html += renderPopupProductCard(product, currentListProducIDs); 1114 }); 1115 $('.edit-listing-details-wrapper .edit-list-products-list').html(html) 1116 } 1117 if(type == 'buy-again') { 1118 var html = ''; 1119 var buyAgainItems = productsDataFull.filter(obj => buyAgainIDs.includes(obj.name)); 1120 var types = [...new Set(buyAgainItems.map(product => product.type))].sort(); 1121 var catHtml = `<div class="svt-profile-category-filter-box active swiper-slide"> 1122 <div class="svt-profile-category-filter-img"> 1123 <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"> 1124 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 12.5763C10.457 11.4048 11.4067 10.4551 12.5782 10.4551H16.8207C17.9922 10.4551 18.9419 11.4048 18.9419 12.5763V16.8187C18.9419 17.9902 17.9922 18.9399 16.8207 18.9399H12.5782C11.4067 18.9399 10.457 17.9902 10.457 16.8187V12.5763ZM12.5782 12.046H16.8207C17.1135 12.046 17.351 12.2834 17.351 12.5763V16.8187C17.351 17.1116 17.1135 17.349 16.8207 17.349H12.5782C12.2854 17.349 12.0479 17.1116 12.0479 16.8187V12.5763C12.0479 12.2834 12.2854 12.046 12.5782 12.046Z" fill="#CB333B"/> 1125 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 23.1824C10.457 22.0108 11.4067 21.0611 12.5782 21.0611H16.8207C17.9922 21.0611 18.9419 22.0108 18.9419 23.1824V27.4248C18.9419 28.5963 17.9922 29.546 16.8207 29.546H12.5782C11.4067 29.546 10.457 28.5963 10.457 27.4248V23.1824ZM12.5782 22.652H16.8207C17.1135 22.652 17.351 22.8895 17.351 23.1824V27.4248C17.351 27.7177 17.1135 27.9551 16.8207 27.9551H12.5782C12.2854 27.9551 12.0479 27.7177 12.0479 27.4248V23.1824C12.0479 22.8895 12.2854 22.652 12.5782 22.652Z" fill="#CB333B"/> 1126 <path fill-rule="evenodd" clip-rule="evenodd" d="M23.1843 10.4551C22.0128 10.4551 21.0631 11.4048 21.0631 12.5763V16.8187C21.0631 17.9902 22.0128 18.9399 23.1843 18.9399H27.4267C28.5982 18.9399 29.5479 17.9902 29.5479 16.8187V12.5763C29.5479 11.4048 28.5982 10.4551 27.4267 10.4551H23.1843ZM27.4267 12.046H23.1843C22.8914 12.046 22.654 12.2834 22.654 12.5763V16.8187C22.654 17.1116 22.8914 17.349 23.1843 17.349H27.4267C27.7196 17.349 27.957 17.1116 27.957 16.8187V12.5763C27.957 12.2834 27.7196 12.046 27.4267 12.046Z" fill="#CB333B"/> 1127 <path fill-rule="evenodd" clip-rule="evenodd" d="M21.0631 23.1824C21.0631 22.0108 22.0128 21.0611 23.1843 21.0611H27.4267C28.5982 21.0611 29.5479 22.0108 29.5479 23.1824V27.4248C29.5479 28.5963 28.5982 29.546 27.4267 29.546H23.1843C22.0128 29.546 21.0631 28.5963 21.0631 27.4248V23.1824ZM23.1843 22.652H27.4267C27.7196 22.652 27.957 22.8895 27.957 23.1824V27.4248C27.95
11277 27.7177 27.7196 27.9551 27.4267 27.9551H23.1843C22.8914 27.9551 22.654 27.7177 22.654 27.4248V23.1824C22.654 22.8895 22.8914 22.652 23.1843 22.652Z" fill="#CB333B"/> 1128 </svg> 1129 </div> 1130 <h6>Shop All</h6> 1131 </div>`; 1132 $.each(types,function(index,cat) { 1133 $catSlug = sanitizeTitle(cat); 1134 $categoryImgs = JSON.parse(sitedata.categoryImgs); 1135 $catImg = ''; 1136 if($categoryImgs[$catSlug]) { 1137 $catImg = $categoryImgs[$catSlug]; 1138 } 1139 catHtml += `<div class="svt-profile-category-filter-box swiper-slide" data-name="${$catSlug}"> 1140 <div class="svt-profile-category-filter-img"> 1141 <img src="${$catImg}" alt=""> 1142 </div> 1143 <h6>${cat}</h6> 1144 </div>`; 1145 }); 1146 $('.svt-profile-category-filter-carousel-el').html(catHtml); 1147 if($('.svt-profile-category-filter-carousel-el').length) { 1148 var swiperEditList = new Swiper('.swiper-edit-list', { 1149 direction: 'horizontal', 1150 slidesPerView: 6, 1151 spaceBetween: 10, 1152 loop: false, 1153 navigation: { 1154 nextEl: '.swiper-button-next', 1155 prevEl: '.swiper-button-prev', 1156 }, 1157 breakpoints: { 1158 1100: { 1159 slidesPerView: 6, 1160 }, 1161 1024: { 1162 slidesPerView: 5.5, 1163 }, 1164 768: { 1165 slidesPerView: 4.5, 1166 }, 1167 640: { 1168 slidesPerView: 3.5, 1169 navigation: { 1170 enabled: false, // Disable navigation on mobile 1171 }, 1172 }, 1173 0: { 1174 slidesPerView: 3.5, 1175 navigation: { 1176 enabled: false, // Disable navigation on mobile 1177 }, 1178 }, 1179 }, 1180 }); 1181 function checkArrowsVisibilityEditList() { 1182 const totalSlidesEditList = swiperEditList.slides.length; // Total number of slides 1183 const slidesToShowEditList = swiperEditList.params.slidesPerView; // Slides per view 1184 1185 // Determine if arrows should be shown 1186 const showArrowsEditList = totalSlidesEditList > slidesToShowEditList; 1187 1188 // Add or remove class on the Swiper container based on arrow visibility 1189 const swiperContainerEditList = document.querySelector('.swiper-edit-list'); 1190 if (!showArrowsEditList) { 1191 swiperContainerEditList.classList.add('no-arrows'); 1192 } else { 1193 swiperContainerEditList.classList.remove('no-arrows'); 1194 } 1195 } 1196 1197 // Call this function on initialization and on window resize 1198 checkArrowsVisibilityEditList(); 1199 window.addEventListener('resize', checkArrowsVisibilityEditList); 1200 } 1201 $.each(buyAgainItems, function(index,product) { 1202 html += renderPopupProductCard(product, currentListProducIDs); 1203 }); 1204 $('.edit-listing-details-wrapper .edit-list-products-list').html(html) 1205 } 1206 if(type == 'trending-items') { 1207 var html = ''; 1208 var productsData = productsDataFull.slice(0,102); 1209 var types = [...new Set(productsData.map(product => product.type))].sort(); 1210 var catHtml = `<div class="svt-profile-category-filter-box active swiper-slide"> 1211 <div class="svt-profile-category-filter-img"> 1212 <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"> 1213 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 12.5763C10.457 11.4048 11.4067 10.4551 12.5782 10.4551H16.8207C17.9922 10.4551 18.9419 11.4048 18.9419 12.5763V16.8187C18.9419 17.9902 17.9922 18.9399 16.8207 18.9399H12.5782C11.4067 18.9399 10.457 17.9902 10.457 16.8187V12.5763ZM12.5782 12.046H16.8207C17.1135 12.046 17.351 12.2834 17.351 12.5763V16.8187C17.351 17.1116 17.1135 17.349 16.8207 17.349H12.5782C12.2854 17.349 12.0479 17.1116 12.0479 16.8187V12.5763C12.0479 12.2834 12.2854 12.046 12.5782 12.046Z" fill="#CB333B"/> 1214 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 23.1824C10.457 22.0108 11.4067 21.0611 12.5782 21.0611H16.8207C17.9922 21.0611 18.9419 22.0108 18.9419 23.1824V27.4248C18.9419 28.5963 17.9922 29.546 16.8207 29.546H12.5782C11.4067 29.546 10.457 28.5963 10.457 27.4248V23.1824ZM12.5782 22.652H16.8207C17.1135 22.652 17.351 22.8895 17.351 23.1824V27.4248C17.351 27.7177 17.1135 27.9551 16.8207 27.9551H12.5782C12.2854 27.9551 12.0479 27.7177 12.0479 27.4248V23.1824C12.0479 22.8895 12.2854 22.652 12.5782 22.652Z" fill="#CB333B"/> 1215 <path fill-rule="evenodd" clip-rule="evenodd" d="M23.1843 10.4551C22.0128 10.4551 21.0631 11.4048 21.0631 12.5763V16.8187C21.0631 17.9902 22.0128 18.9399 23.1843 18.9399H27.4267C28.5982 18.9399 29.5479 17.9902 29.5479 16.8187V12.5763C29.5479 11.4048 28.5982 10.4551 27.4267 10.4551H23.1843ZM27.4267 12.046H23.1843C22.8914 12.046 22.654 12.2834 22.654 12.5763V16.8187C22.654 17.1116 22.8914 17.349 23.1843 17.349H27.4267C27.7196 17.349 27.957 17.1116 27.957 16.8187V12.5763C27.957 12.2834 27.7196 12.046 27.4267 12.046Z" fill="#CB333B"/> 1216 <path fill-rule="evenodd" clip-rule="evenodd" d="M21.0631 23.1824C21.0631 22.0108 22.0128 21.0611 23.1843 21.0611H27.4267C28.5982 21.0611 29.5479 22.0108 29.5479 23.1824V27.4248C29.5479 28.5963 28.5982 29.546 27.4267 29.546H23.1843C22.0128 29.546 21.0631 28.5963 21.0631 27.4248V23.1824ZM23.1843 22.652H27.4267C27.7196 22.652 27.957 22.8895 27.957 23.1824V27.4248C27.95
12167 27.7177 27.7196 27.9551 27.4267 27.9551H23.1843C22.8914 27.9551 22.654 27.7177 22.654 27.4248V23.1824C22.654 22.8895 22.8914 22.652 23.1843 22.652Z" fill="#CB333B"/> 1217 </svg> 1218 </div> 1219 <h6>Shop All</h6> 1220 </div>`; 1221 $.each(types,function(index,cat) { 1222 $catSlug = sanitizeTitle(cat); 1223 $categoryImgs = JSON.parse(sitedata.categoryImgs); 1224 $catImg = ''; 1225 if($categoryImgs[$catSlug]) { 1226 $catImg = $categoryImgs[$catSlug]; 1227 } 1228 catHtml += `<div class="svt-profile-category-filter-box swiper-slide" data-name="${$catSlug}"> 1229 <div class="svt-profile-category-filter-img"> 1230 <img src="${$catImg}" alt=""> 1231 </div> 1232 <h6>${cat}</h6> 1233 </div>`; 1234 }); 1235 $('.svt-profile-category-filter-carousel-el').html(catHtml); 1236 if($('.svt-profile-category-filter-carousel-el').length) { 1237 var swiperEditList = new Swiper('.swiper-edit-list', { 1238 direction: 'horizontal', 1239 slidesPerView: 6, 1240 spaceBetween: 10, 1241 loop: false, 1242 navigation: { 1243 nextEl: '.swiper-button-next', 1244 prevEl: '.swiper-button-prev', 1245 }, 1246 breakpoints: { 1247 1100: { 1248 slidesPerView: 6, 1249 }, 1250 1024: { 1251 slidesPerView: 5.5, 1252 }, 1253 768: { 1254 slidesPerView: 4.5, 1255 }, 1256 640: { 1257 slidesPerView: 3.5, 1258 navigation: { 1259 enabled: false, // Disable navigation on mobile 1260 }, 1261 }, 1262 0: { 1263 slidesPerView: 3.5, 1264 navigation: { 1265 enabled: false, // Disable navigation on mobile 1266 }, 1267 }, 1268 }, 1269 }); 1270 function checkArrowsVisibilityEditList() { 1271 const totalSlidesEditList = swiperEditList.slides.length; // Total number of slides 1272 const slidesToShowEditList = swiperEditList.params.slidesPerView; // Slides per view 1273 1274 // Determine if arrows should be shown 1275 const showArrowsEditList = totalSlidesEditList > slidesToShowEditList; 1276 1277 // Add or remove class on the Swiper container based on arrow visibility 1278 const swiperContainerEditList = document.querySelector('.swiper-edit-list'); 1279 if (!showArrowsEditList) { 1280 swiperContainerEditList.classList.add('no-arrows'); 1281 } else { 1282 swiperContainerEditList.classList.remove('no-arrows'); 1283 } 1284 } 1285 1286 // Call this function on initialization and on window resize 1287 checkArrowsVisibilityEditList(); 1288 window.addEventListener('resize', checkArrowsVisibilityEditList); 1289 } 1290 $.each(productsData, function(index,product) { 1291 html += renderPopupProductCard(product, currentListProducIDs); 1292 }); 1293 $('.edit-listing-details-wrapper .edit-list-products-list').html(html) 1294 } 1295 return false; 1296 }); 1297 1298 $(document).on('click','.edit-listing-back',function() { 1299 $('.svt-profile-category-filter-carousel-el').removeClass('slick-initialized slick-slider'); 1300 $('.edit-listing-details-wrapper').hide(); 1301 $('.edit-listing-back-wrapper').hide(); 1302 $('.edit-list-products-listing-wrapper').show(); 1303 return false; 1304 }); 1305 1306 $(document).on('click','.svt-add-to-list-action',function() { 1307 var parent = $(this).parents().closest('.svt-product-add-to-list'); 1308 var id = $(this).attr('data-id'); 1309 var listID = $('.my-list-details-wrap').attr('data-id'); 1310 1311 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 1312 1313 var user = localStorage.getItem('user'); 1314 user = JSON.parse(user); 1315 1316 email = user.email; 1317 email = email.replace('^',''); 1318 1319 1320 let body = { 1321 name: listID, 1322 contents: { 1323 [id]: { // Using computed property name to set the key dynamically 1324 name: id 1325 } 1326 } 1327 } 1328 1329 let headers = { 1330 'emailid': email, 1331 'authToken': user.authToken, 1332 'location': getCookie('selectedLocation'), 1333 'pricelist': getCookie('selectedPriceList'), 1334 'Content-Type': 'application/json' 1335 }; 1336 1337 1338 api.postData('/v2/user/shoppinglists/items',body,headers).then(response => { 1339 if(response.lists) { 1340 sessionStorage.setItem('shoppingLists', JSON.stringify(response.lists)); 1341 if (!currentListProducIDs.includes(id)) { 1342 currentListProducIDs.push(id); 1343 var subtotal = getSubTotal();
1344 var productCount = getProductCount(); 1345 var listElement = $('.svt-list-detail-action[data-id="'+listID+'"]').get(0); 1346 $(listElement).attr('data-products',JSON.stringify(currentListProducIDs)); 1347 $(listElement).attr('data-subtotal',subtotal); 1348 loadListDetails(listElement, currentListProducIDs); 1349 refreshList(listID, currentListProducIDs); 1350 if($('.edit-listing-stats').length) { 1351 $('.edit-listing-stats .subtotal').html('$'+subtotal.toFixed(2)); 1352 $('.edit-listing-stats .items-count').html('('+productCount+' Items)'); 1353 } 1354 } 1355 parent.addClass('added'); 1356 } 1357 }) 1358 .catch(error => { 1359 console.error('Error posting data on clip coupon 664:', error); 1360 }); 1361 // $.ajax({ 1362 // type: 'POST', 1363 // data: { 1364 // action: 'svt_add_to_list', 1365 // id: id, 1366 // listID: listID 1367 // }, 1368 // dataType: 'json', 1369 // url: sitedata.svt_ajax_url, 1370 // beforeSend: function() {}, 1371 // success: function( response ) { 1372 // if(response.success) { 1373 // if (!currentListProducIDs.includes(id)) { 1374 // currentListProducIDs.push(id); 1375 // var subtotal = getSubTotal(); 1376 // var productCount = getProductCount(); 1377 // var listElement = $('.svt-list-detail-action[data-id="'+listID+'"]').get(0); 1378 // $(listElement).attr('data-products',JSON.stringify(currentListProducIDs)); 1379 // $(listElement).attr('data-subtotal',subtotal); 1380 // loadListDetails(listElement, currentListProducIDs); 1381 // refreshList(listID, currentListProducIDs); 1382 // if($('.edit-listing-stats').length) { 1383 // $('.edit-listing-stats .subtotal').html('$'+subtotal.toFixed(2)); 1384 // $('.edit-listing-stats .items-count').html('('+productCount+' Items)'); 1385 // } 1386 // } 1387 // parent.addClass('added'); 1388 // } 1389 // } 1390 // }); 1391 return false; 1392 }); 1393 1394 $(document).on('click','.remove-from-list-action',function() { 1395 var parent = $(this).parents().closest('.svt-product-add-to-list'); 1396 var id = $(this).attr('data-id'); 1397 var listID = $('.my-list-details-wrap').attr('data-id'); 1398 1399 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 1400 1401 var user = localStorage.getItem('user'); 1402 user = JSON.parse(user); 1403 1404 email = user.email; 1405 email = email.replace('^',''); 1406 1407 1408 let body = { 1409 name: listID, 1410 contents: [ 1411 id 1412 ] 1413 } 1414 1415 let headers = { 1416 'emailid': email, 1417 'authToken': user.authToken, 1418 'location': getCookie('selectedLocation'), 1419 'pricelist': getCookie('selectedPriceList'), 1420 'Content-Type': 'application/json' 1421 }; 1422 1423 1424 api.deleteData('/v2/user/shoppinglists/items',body,headers).then(response => { 1425 if(response.lists) { 1426 sessionStorage.setItem('shoppingLists', JSON.stringify(response.lists)); 1427 currentListProducIDs = currentListProducIDs.filter(item => item !== id); 1428 var subtotal = getSubTotal();
1429 var productCount = getProductCount(); 1430 var listElement = $('.svt-list-detail-action[data-id="'+listID+'"]').get(0); 1431 $(listElement).attr('data-products',JSON.stringify(currentListProducIDs)); 1432 $(listElement).attr('data-subtotal',subtotal); 1433 loadListDetails(listElement, currentListProducIDs); 1434 refreshList(listID, currentListProducIDs); 1435 if($('.edit-listing-stats').length) { 1436 $('.edit-listing-stats .subtotal').html('$'+subtotal.toFixed(2)); 1437 $('.edit-listing-stats .items-count').html('('+productCount+' Items)'); 1438 } 1439 parent.removeClass('added'); 1440 } 1441 }) 1442 .catch(error => { 1443 console.error('Error posting data on clip coupon 664:', error); 1444 }); 1445 // $.ajax({ 1446 // type: 'POST', 1447 // data: { 1448 // action: 'svt_remove_from_list', 1449 // id: id, 1450 // listID: listID 1451 // }, 1452 // dataType: 'json', 1453 // url: sitedata.svt_ajax_url, 1454 // beforeSend: function() {}, 1455 // success: function( response ) { 1456 // if(response.success) { 1457 // currentListProducIDs = currentListProducIDs.filter(item => item !== id); 1458 // var subtotal = getSubTotal(); 1459 // var productCount = getProductCount(); 1460 // var listElement = $('.svt-list-detail-action[data-id="'+listID+'"]').get(0); 1461 // $(listElement).attr('data-products',JSON.stringify(currentListProducIDs)); 1462 // $(listElement).attr('data-subtotal',subtotal); 1463 // loadListDetails(listElement, currentListProducIDs); 1464 // refreshList(listID, currentListProducIDs); 1465 // if($('.edit-listing-stats').length) { 1466 // $('.edit-listing-stats .subtotal').html('$'+subtotal.toFixed(2)); 1467 // $('.edit-listing-stats .items-count').html('('+productCount+' Items)'); 1468 // } 1469 // parent.removeClass('added'); 1470 // } 1471 // } 1472 // }); 1473 return false; 1474 }); 1475 1476 $(document).on('click','.svt-product-remove-from-list',function() { 1477 var parent = $(this).parents().closest('.svt-product-box'); 1478 var id = $(this).attr('data-id'); 1479 var listID = $('.my-list-details-wrap').attr('data-id'); 1480 1481 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 1482 1483 var user = localStorage.getItem('user'); 1484 user = JSON.parse(user); 1485 1486 email = user.email; 1487 email = email.replace('^',''); 1488 1489 1490 let body = { 1491 name: listID, 1492 contents: [ 1493 id 1494 ] 1495 } 1496 1497 let headers = { 1498 'emailid': email, 1499 'authToken': user.authToken, 1500 'location': getCookie('selectedLocation'), 1501 'pricelist': getCookie('selectedPriceList'), 1502 'Content-Type': 'application/json' 1503 }; 1504 1505 1506 api.deleteData('/v2/user/shoppinglists/items',body,headers).then(response => { 1507 if(response.lists) { 1508 sessionStorage.setItem('shoppingLists', JSON.stringify(response.lists)); 1509 parent.fadeOut(400,function() { 1510 $(this).remove(); 1511 }); 1512 currentListProducIDs = currentListProducIDs.filter(item => item !== id); 1513 var subtotal = getSubTotal(); 1514 var listElement = $('.svt-list-detail-action[data-id="'+listID+'"]').get(0); 1515 $(listElement).attr('data-products',JSON.stringify(currentListProducIDs)); 1516 $(listElement).attr('data-subtotal',subtotal); 1517 loadListDetails(listElement, currentListProducIDs); 1518 refreshList(listID, currentListProducIDs); 1519 if($('.my-list-details-wrap .my-list-detail-products .svt-product-box').length == 0) { 1520 $('.my-list-detail-products').hide(); 1521 $('.svt-no-list-product-wrapper').show(); 1522 } 1523 } 1524 }) 1525 .catch(error => { 1526 console.error('Error posting data on clip coupon 664:', error); 1527 }); 1528 1529 // $.ajax({
1530 // type: 'POST', 1531 // data: { 1532 // action: 'svt_remove_from_list', 1533 // id: id, 1534 // listID: listID 1535 // }, 1536 // dataType: 'json', 1537 // url: sitedata.svt_ajax_url, 1538 // beforeSend: function() {}, 1539 // success: function( response ) { 1540 // if(response.success) { 1541 // parent.fadeOut(400,function() { 1542 // $(this).remove(); 1543 // }); 1544 // currentListProducIDs = currentListProducIDs.filter(item => item !== id); 1545 // var subtotal = getSubTotal(); 1546 // var listElement = $('.svt-list-detail-action[data-id="'+listID+'"]').get(0); 1547 // $(listElement).attr('data-products',JSON.stringify(currentListProducIDs)); 1548 // $(listElement).attr('data-subtotal',subtotal); 1549 // loadListDetails(listElement, currentListProducIDs); 1550 // refreshList(listID, currentListProducIDs); 1551 // if($('.my-list-details-wrap .my-list-detail-products .svt-product-box').length == 0) { 1552 // $('.my-list-detail-products').hide(); 1553 // $('.svt-no-list-product-wrapper').show(); 1554 // } 1555 // } 1556 // } 1557 // }); 1558 return false; 1559 }); 1560 } 1561 1562 $(document).on('click','.svt-dots-menu',function() { 1563 var dropdown = $(this).parents().closest('.svt-dots-menu-wrap').find('.svt-dots-menu-dropdown'); 1564 if(dropdown.is(':visible')) { 1565 dropdown.fadeOut(); 1566 } 1567 else { 1568 dropdown.fadeIn(); 1569 } 1570 return false; 1571 }); 1572 1573 $(document).mouseup(function(e) { 1574 var listDropdownMenu = $('.svt-dots-menu-dropdown'); 1575 if (!listDropdownMenu.is(e.target) && listDropdownMenu.has(e.target).length === 0) { 1576 listDropdownMenu.fadeOut(); 1577 } 1578 }); 1579 1580 $(document).on('click','.svt-select-list-all',function() { 1581 $('.svt-product-bulk-action .svt-custom-checkbox input').prop('checked',true); 1582 $('.svt-product-bulk-action .svt-custom-checkbox input').trigger('change'); 1583 return false; 1584 }); 1585 1586 $(document).on('change','.svt-product-bulk-action .svt-custom-checkbox input',function() { 1587 var productCount = $('.svt-product-bulk-action .svt-custom-checkbox input:checked').length; 1588 var subTotal = 0; 1589 $('.svt-product-bulk-action .svt-custom-checkbox input:checked').each(function() { 1590 var price = $(this).data('price'); 1591 subTotal = subTotal + price; 1592 }); 1593 subTotal = subTotal.toFixed(2); 1594 $('.list-bulk-add-cart .product-count').html(productCount); 1595 $('.list-bulk-add-cart .subtotal').html('$'+subTotal); 1596 if($('.svt-product-bulk-action .svt-custom-checkbox input:checked').length > 0) { 1597 $('.list-bulk-add-cart-wrap').addClass('active'); 1598 } 1599 else { 1600 $('.list-bulk-add-cart-wrap').removeClass('active'); 1601 } 1602 }); 1603 1604 $('.edit-list-search-wrap input').focus(function() { 1605 $('.edit-list-products-listing-wrapper').hide(); 1606 $('.edit-listing-details-wrapper').hide(); 1607 $('.edit-list-search-wrap .cancel-edit-list-search').show(); 1608 $('.edit-list-search-screen').addClass('active'); 1609 }); 1610 1611 $('.cancel-edit-list-search').click(function() { 1612 $('.edit-list-products-listing-wrapper').show(); 1613 $('.edit-list-start-search-wrap').show(); 1614 $('.edit-listing-details-wrapper').hide(); 1615 $('.edit-listing-search-detais-wrapper').hide(); 1616 $('.edit-list-search-wrap input').val(''); 1617 $('.edit-list-search-wrap .cancel-edit-list-search').hide(); 1618 $('.edit-list-search-screen').removeClass('active'); 1619 }); 1620 1621 var elSearch = ''; 1622 $('.edit-list-search-wrap input').on('input',function() { 1623 const $this = $(this); 1624 const query = $this.val().trim(); 1625 if(query != '') { 1626 if (query.length >= 3) { 1627 $('.edit-list-search-loader').show(); 1628 $('.edit-list-start-search-wrap').hide(); 1629 $('.edit-listing-search-detais-wrapper').hide(); 1630 $('.edit-list-search-data').html(''); 1631 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 1632 let headers = { 1633 'location': getCookie('selectedLocation'), 1634 'pricelist': getCookie('selectedPriceList') 1635 }; 1636 1637 api.getData('/product/searchV2?search='+query,headers).then(response => { 1638 $('.edit-list-search-loader').hide(); 1639 if(response.results) { 1640 resultData = response.results[0]; 1641 var html = ''; 1642 $.each(resultData,function(index,result) { 1643 var img = ''; 1644 img = sitedata.svt_thumb_url+result.name+'.jpg'; 1645 html += `<div class="svt-edit-search-suggestion-item" data-keyword="${result.displayName}"> 1646 <div class="sr-img-wrap"> 1647 <img src="${img}" onerror="this.onerror=null; this.className='placeholder-img'; this.src='${sitedata.search_placeholder}'" alt="" class=""> 1648 </div> 1649 ${result.displayName} 1650 </div>`; 1651 }); 1652 $('.edit-list-search-data').html(html); 1653 } 1654 }); 1655 } 1656 } 1657 // if(elSearch != '') { 1658 // elSearch.abort(); 1659 // } 1660 // elSearch = $.ajax({
1661 // type: 'GET', 1662 // url: sitedata.svt_ajax_url, 1663 // data: { 1664 // action: 'product_search_v2', 1665 // search: keyword 1666 // }, 1667 // dataType: 'json', 1668 // beforeSend: function() { 1669 // $('.edit-list-search-loader').show(); 1670 // $('.edit-list-start-search-wrap').hide(); 1671 // $('.edit-listing-search-detais-wrapper').hide(); 1672 // $('.edit-list-search-data').html(''); 1673 // }, 1674 // success: function( response ) { 1675 // $('.edit-list-search-loader').hide(); 1676 // if(response.data) { 1677 // resultData = JSON.parse(response.data); 1678 // var html = ''; 1679 // $.each(resultData,function(index,result) { 1680 // var img = ''; 1681 // img = sitedata.svt_thumb_url+result.name+'.jpg'; 1682 // html += `<div class="svt-edit-search-suggestion-item" data-keyword="${result.displayName}"> 1683 // <div class="sr-img-wrap"> 1684 // <img src="${img}" onerror="this.onerror=null; this.className='placeholder-img'; this.src='${sitedata.search_placeholder}'" alt="" class=""> 1685 // </div> 1686 // ${result.displayName} 1687 // </div>`; 1688 // }); 1689 // $('.edit-list-search-data').html(html); 1690 // } 1691 // } 1692 // }) 1693 }); 1694 1695 $(document).on('click','.svt-edit-search-suggestion-item',function() { 1696 var keyword = $(this).attr('data-keyword'); 1697 const api = new HomesomeAPI(hsdata.base_url, hsdata.hs_api_key); 1698 let headers = { 1699 'location': getCookie('selectedLocation'), 1700 'pricelist': getCookie('selectedPriceList') 1701 }; 1702 1703 api.getData('/product/searchV2?search='+keyword,headers).then(response => { 1704 if(response.results) { 1705 let searchData = response.results[0]; 1706 var productsData = allProducts.products; 1707 var searchedProducts = productsData.filter(searchItem => 1708 searchData.some(product => product.name === searchItem.name) 1709 ); 1710 // console.log(searchData); 1711 // console.log(searchedProducts); 1712 if(searchedProducts.length) { 1713 var types = [...new Set(searchedProducts.map(product => product.type))].sort(); 1714 var catHtml = `<div class="svt-profile-category-filter-box active swiper-slide"> 1715 <div class="svt-profile-category-filter-img"> 1716 <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"> 1717 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 12.5763C10.457 11.4048 11.4067 10.4551 12.5782 10.4551H16.8207C17.9922 10.4551 18.9419 11.4048 18.9419 12.5763V16.8187C18.9419 17.9902 17.9922 18.9399 16.8207 18.9399H12.5782C11.4067 18.9399 10.457 17.9902 10.457 16.8187V12.5763ZM12.5782 12.046H16.8207C17.1135 12.046 17.351 12.2834 17.351 12.5763V16.8187C17.351 17.1116 17.1135 17.349 16.8207 17.349H12.5782C12.2854 17.349 12.0479 17.1116 12.0479 16.8187V12.5763C12.0479 12.2834 12.2854 12.046 12.5782 12.046Z" fill="#CB333B"/> 1718 <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 23.1824C10.457 22.0108 11.4067 21.0611 12.5782 21.0611H16.8207C17.9922 21.0611 18.9419 22.0108 18.9419 23.1824V27.4248C18.9419 28.5963 17.9922 29.546 16.8207 29.546H12.5782C11.4067 29.546 10.457 28.5963 10.457 27.4248V23.1824ZM12.5782 22.652H16.8207C17.1135 22.652 17.351 22.8895 17.351 23.1824V27.4248C17.351 27.7177 17.1135 27.9551 16.8207 27.9551H12.5782C12.2854 27.9551 12.0479 27.7177 12.0479 27.4248V23.1824C12.0479 22.8895 12.2854 22.652 12.5782 22.652Z" fill="#CB333B"/> 1719 <path fill-rule="evenodd" clip-rule="evenodd" d="M23.1843 10.4551C22.0128 10.4551 21.0631 11.4048 21.0631 12.5763V16.8187C21.0631 17.9902 22.0128 18.9399 23.1843 18.9399H27.4267C28.5982 18.9399 29.5479 17.9902 29.5479 16.8187V12.5763C29.5479 11.4048 28.5982 10.4551 27.4267 10.4551H23.1843ZM27.4267 12.046H23.1843C22.8914 12.046 22.654 12.2834 22.654 12.5763V16.8187C22.654 17.1116 22.8914 17.349 23.1843 17.349H27.4267C27.7196 17.349 27.957 17.1116 27.957 16.8187V12.5763C27.957 12.2834 27.7196 12.046 27.4267 12.046Z" fill="#CB333B"/> 1720 <path fill-rule="evenodd" clip-rule="evenodd" d="M21.0631 23.1824C21.0631 22.0108 22.0128 21.0611 23.1843 21.0611H27.4267C28.5982 21.0611 29.5479 22.0108 29.5479 23.1824V27.4248C29.5479 28.5963 28.5982 29.546 27.4267 29.546H23.1843C22.0128 29.546 21.0631 28.5963 21.0631 27.4248V23.1824ZM23.1843 22.652H27.4267C27.7196 22.652 27.957 22.8895 27.957 23.1824V27.4248C27.95
17207 27.7177 27.7196 27.9551 27.4267 27.9551H23.1843C22.8914 27.9551 22.654 27.7177 22.654 27.4248V23.1824C22.654 22.8895 22.8914 22.652 23.1843 22.652Z" fill="#CB333B"/> 1721 </svg> 1722 </div> 1723 <h6>Shop All</h6> 1724 </div>`; 1725 $.each(types,function(index,cat) { 1726 $catSlug = sanitizeTitle(cat); 1727 $categoryImgs = JSON.parse(sitedata.categoryImgs); 1728 $catImg = ''; 1729 if($categoryImgs[$catSlug]) { 1730 $catImg = $categoryImgs[$catSlug]; 1731 } 1732 catHtml += `<div class="svt-profile-category-filter-box swiper-slide" data-name="${$catSlug}"> 1733 <div class="svt-profile-category-filter-img"> 1734 <img src="${$catImg}" alt=""> 1735 </div> 1736 <h6>${cat}</h6> 1737 </div>`; 1738 }); 1739 $('.edit-listing-search-detais-wrapper .svt-profile-category-filter-carousel-el').html(catHtml); 1740 var html = ''; 1741 $.each(searchedProducts, function(index,product) { 1742 html += renderPopupProductCard( product, currentListProducIDs ); 1743 }); 1744 $('.edit-list-search-screen').removeClass('active'); 1745 $('.edit-listing-search-detais-wrapper .edit-list-products-list').html(html); 1746 $('.edit-listing-search-detais-wrapper').show(); 1747 if($('.edit-listing-search-detais-wrapper .svt-profile-category-filter-carousel-el').length) { 1748 var listingSearchSwiper = new Swiper('.list-search-swiper', { 1749 direction: 'horizontal', 1750 slidesPerView: 7, 1751 spaceBetween: 10, 1752 loop: false, 1753 navigation: { 1754 nextEl: '.swiper-button-next', 1755 prevEl: '.swiper-button-prev', 1756 }, 1757 breakpoints: { 1758 1024: { 1759 slidesPerView: 5.5, 1760 }, 1761 768: { 1762 slidesPerView: 4.5, 1763 }, 1764 640: { 1765 slidesPerView: 3.5, 1766 navigation: { 1767 enabled: false, // Disable navigation on mobile 1768 }, 1769 }, 1770 0: { 1771 slidesPerView: 3.5, 1772 navigation: { 1773 enabled: false, // Disable navigation on mobile 1774 }, 1775 }, 1776 }, 1777 }); 1778 function checkArrowsListingSearchVisibility() { 1779 const totalSlides = listingSearchSwiper.slides.length; // Total number of slides 1780 const slidesToShow = listingSearchSwiper.params.slidesPerView; // Slides per view 1781 1782 // Determine if arrows should be shown 1783 const showArrows = totalSlides > slidesToShow; 1784 1785 // Add or remove class on the Swiper container based on arrow visibility 1786 const swiperContainer = document.querySelector('.swiper-container'); 1787 if (!showArrows) { 1788 swiperContainer.classList.add('no-arrows'); 1789 } else { 1790 swiperContainer.classList.remove('no-arrows'); 1791 } 1792 } 1793 1794 // Call this function on initialization and on window resize 1795 checkArrowsListingSearchVisibility(); 1796 window.addEventListener('resize', checkArrowsListingSearchVisibility); 1797 } 1798 $('.edit-listing-search-detais-header h6 span').html(keyword); 1799 var count = searchedProducts.length+' items found'; 1800 $('.edit-listing-search-detais-header .result-count').html(count); 1801 } 1802 } 1803 }); 1804 // $.ajax({
1805 // type: 'GET', 1806 // url: sitedata.svt_ajax_url, 1807 // data: { 1808 // action: 'product_search_v2', 1809 // search: keyword 1810 // }, 1811 // dataType: 'json', 1812 // beforeSend: function() { 1813 // $('.edit-list-search-loader').show(); 1814 // $('.edit-list-start-search-wrap').hide(); 1815 // $('.edit-list-search-data').html(''); 1816 // }, 1817 // success: function( response ) { 1818 // $('.edit-list-search-loader').hide(); 1819 // if(response.data) { 1820 // var searchData = JSON.parse(response.data); 1821 // var productsData = allProducts.products; 1822 // var searchedProducts = productsData.filter(searchItem => 1823 // searchData.some(product => product.name === searchItem.name) 1824 // ); 1825 // // console.log(searchData); 1826 // // console.log(searchedProducts); 1827 // if(searchedProducts.length) { 1828 // var types = [...new Set(searchedProducts.map(product => product.type))].sort(); 1829 // var catHtml = `<div class="svt-profile-category-filter-box active swiper-slide"> 1830 // <div class="svt-profile-category-filter-img"> 1831 // <svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40" fill="none"> 1832 // <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 12.5763C10.457 11.4048 11.4067 10.4551 12.5782 10.4551H16.8207C17.9922 10.4551 18.9419 11.4048 18.9419 12.5763V16.8187C18.9419 17.9902 17.9922 18.9399 16.8207 18.9399H12.5782C11.4067 18.9399 10.457 17.9902 10.457 16.8187V12.5763ZM12.5782 12.046H16.8207C17.1135 12.046 17.351 12.2834 17.351 12.5763V16.8187C17.351 17.1116 17.1135 17.349 16.8207 17.349H12.5782C12.2854 17.349 12.0479 17.1116 12.0479 16.8187V12.5763C12.0479 12.2834 12.2854 12.046 12.5782 12.046Z" fill="#CB333B"/> 1833 // <path fill-rule="evenodd" clip-rule="evenodd" d="M10.457 23.1824C10.457 22.0108 11.4067 21.0611 12.5782 21.0611H16.8207C17.9922 21.0611 18.9419 22.0108 18.9419 23.1824V27.4248C18.9419 28.5963 17.9922 29.546 16.8207 29.546H12.5782C11.4067 29.546 10.457 28.5963 10.457 27.4248V23.1824ZM12.5782 22.652H16.8207C17.1135 22.652 17.351 22.8895 17.351 23.1824V27.4248C17.351 27.7177 17.1135 27.9551 16.8207 27.9551H12.5782C12.2854 27.9551 12.0479 27.7177 12.0479 27.4248V23.1824C12.0479 22.8895 12.2854 22.652 12.5782 22.652Z" fill="#CB333B"/> 1834 // <path fill-rule="evenodd" clip-rule="evenodd" d="M23.1843 10.4551C22.0128 10.4551 21.0631 11.4048 21.0631 12.5763V16.8187C21.0631 17.9902 22.0128 18.9399 23.1843 18.9399H27.4267C28.5982 18.9399 29.5479 17.9902 29.5479 16.8187V12.5763C29.5479 11.4048 28.5982 10.4551 27.4267 10.4551H23.1843ZM27.4267 12.046H23.1843C22.8914 12.046 22.654 12.2834 22.654 12.5763V16.8187C22.654 17.1116 22.8914 17.349 23.1843 17.349H27.4267C27.7196 17.349 27.957 17.1116 27.957 16.8187V12.5763C27.957 12.2834 27.7196 12.046 27.4267 12.046Z" fill="#CB333B"/> 1835 // <path fill-rule="evenodd" clip-rule="evenodd" d="M21.0631 23.1824C21.0631 22.0108 22.0128 21.0611 23.1843 21.0611H27.4267C28.5982 21.0611 29.5479 22.0108 29.5479 23.1824V27.4248C29.5479 28.5963 28.5982 29.546 27.4267 29.546H23.1843C22.0128 29.546 21.0631 28.5963 21.0631 27.4248V23.1824ZM23.1843 22.652H27.4267C27.7196 22.652 27.957 22.8895 27.957 23.1824V27.4248C27.957 27.7177 27.7196 27.9551 27.4267 27.9551H23.1843C22.8914 27.9551 22.654 27.7177 22.654 27.4248V23.1824C22.654 22.8895 22.8914 22.652 23.1843 22.652Z" fill="#CB333B"/> 1836 // </svg> 1837 // </div> 1838 // <h6>Shop All</h6> 1839 // </div>`; 1840 // $.each(types,function(index,cat) { 1841 // $catSlug = sanitizeTitle(cat); 1842 // $categoryImgs = JSON.parse(sitedata.categoryImgs); 1843 // $catImg = ''; 1844 // if($categoryImgs[$catSlug]) { 1845 // $catImg = $categoryImgs[$catSlug]; 1846 // } 1847 // catHtml += `<div class="svt-profile-category-filter-box swiper-slide" data-name="${$catSlug}"> 1848 // <div class="svt-profile-category-filter-img"> 1849 // <img src="${$catImg}" alt=""> 1850 // </div> 1851 // <h6>${cat}</h6> 1852 // </div>`; 1853 // }); 1854 // $('.edit-listing-search-detais-wrapper .svt-profile-category-filter-carousel-el').html(catHtml); 1855 // /*$('.edit-listing-search-detais-wrapper .svt-profile-category-filter-carousel-el').slick({ 1856 // slidesToShow: 9, 1857 // infinite: false, 1858 // slidesToScroll: 1, 1859 // arrows: true, 1860 // dots: false, 1861 // });*/ 1862 // var html = ''; 1863 // $.each(searchedProducts, function(index,product) { 1864 // html += renderPopupProductCard( product, currentListProducIDs ); 1865 // }); 1866 // $('.edit-list-search-screen').removeClass('active'); 1867 // $('.edit-listing-search-detais-wrapper .edit-list-products-list').html(html); 1868 // $('.edit-listing-search-detais-wrapper').show(); 1869 // if($('.edit-listing-search-detais-wrapper .svt-profile-category-filter-carousel-el').length) { 1870 // var mySwiper = new Swiper('.swiper-container', { 1871 // direction: 'horizontal', 1872 // slidesPerView: 7, 1873 // spaceBetween: 10, 1874 // loop: false, 1875 // navigation: { 1876 // nextEl: '.swiper-button-next', 1877 // prevEl: '.swiper-button-prev', 1878 // }, 1879 // breakpoints: { 1880 // 1024: { 1881 // slidesPerView: 5.5, 1882 // }, 1883 // 768: { 1884 // slidesPerView: 4.5, 1885 // }, 1886 // 640: { 1887 // slidesPerView: 3.5, 1888 // navigation: { 1889 // enabled: false, // Disable navigation on mobile 1890 // }, 1891 // }, 1892 // 0: { 1893 // slidesPerView: 3.5, 1894 // navigation: { 1895 // enabled: false, // Disable navigation on mobile 1896 // }, 1897 // }, 1898 // }, 1899 // }); 1900 // function checkArrowsVisibility() { 1901 // const totalSlides = mySwiper.slides.length; // Total number of slides 1902 // const slidesToShow = mySwiper.params.slidesPerView; // Slides per view 1903 1904 // // Determine if arrows should be shown 1905 // const showArrows = totalSlides > slidesToShow; 1906 1907 // // Add or remove class on the Swiper container based on arrow visibility 1908 // const swiperContainer = document.querySelector('.swiper-container'); 1909 // if (!showArrows) { 1910 // swiperContainer.classList.add('no-arrows'); 1911 // } else { 1912 // swiperContainer.classList.remove('no-arrows'); 1913 // } 1914 // } 1915 1916 // // Call this function on initialization and on window resize 1917 // checkArrowsVisibility(); 1918 // window.addEventListener('resize', checkArrowsVisibility); 1919 // } 1920 // $('.edit-listing-search-detais-header h6 span').html(keyword); 1921 // var count = searchedProducts.length+' items found'; 1922 // $('.edit-listing-search-detais-header .result-count').html(count); 1923 // } 1924 // } 1925 // } 1926 // }); 1927 }); 1928 });
1929})(jQuery);
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.