1var count = 0; 2 3function deleteProd(id,name,img,width,depth,height,sub) 4{ 5 if(window.location.href.indexOf("samples") > -1) 6 { 7 remove_id = localStorage.getItem('samples_id'); 8 remove_name = localStorage.getItem('samples_names'); 9 remove_img = localStorage.getItem('samples_imgs'); 10 11 remove_id = remove_id.replace(id+',',''); 12 remove_id = remove_id.replace(id,''); 13 14 remove_name = remove_name.replace(name+',',''); 15 remove_name = remove_name.replace(name,''); 16 17 remove_img = remove_img.replace(img+',',''); 18 remove_img = remove_img.replace(img,''); 19 20 localStorage.setItem('samples_id', remove_id); 21 localStorage.setItem('samples_names', remove_name); 22 localStorage.setItem('samples_imgs', remove_img); 23 24 samples_items = []; 25 samples_names = []; 26 samples_imgs = []; 27 28 samples_items.push(localStorage.getItem('samples_id')); 29 samples_names.push(localStorage.getItem('samples_names')); 30 samples_imgs.push(localStorage.getItem('samples_imgs')); 31 } 32} 33 34jQuery(document).ready(function($){ 35 samples_items = []; 36 samples_names = []; 37 samples_imgs = []; 38 items = []; 39 names = []; 40 imgs = []; 41 width = []; 42 depth = []; 43 height = []; 44 sub = []; 45 46 if(window.location.href.indexOf("samples") > -1) 47 { 48 if(localStorage.getItem('samples_id')!=null) 49 { 50 samples_items.push(localStorage.getItem('samples_id')); 51 samples_names.push(localStorage.getItem('samples_names')); 52 samples_imgs.push(localStorage.getItem('samples_imgs')); 53 } 54 55 var cartWrapper = $('.cd-cart-container-samples'); 56 //product id - you don't need a counter in your real project but you can use your real product id 57 var productId = 0; 58 59 if( cartWrapper.length > 0 ) { 60 //store jQuery objects 61 var cartBody = cartWrapper.find('.body') 62 var cartList = cartBody.find('ul').eq(0); 63 var cartTotal = cartWrapper.find('.checkout').find('span'); 64 var cartTrigger = cartWrapper.children('.cd-cart-trigger'); 65 var cartCount = cartTrigger.children('.count'); 66 var addToCartBtn = $('.cd-add-to-cart'); 67 var checkout = $('.checkout'); 68 var undo = cartWrapper.find('.undo'); 69 var undoTimeoutId; 70 71 //add product to cart 72 addToCartBtn.on('click', function(event){ 73 event.preventDefault(); 74 addToCart($(this)); 75 }); 76 77 //open/close cart 78 cartTrigger.on('click', function(event){ 79 event.preventDefault(); 80 toggleCart(); 81 }); 82 83 //close cart when clicking on the .cd-cart-container::before (bg layer) 84 cartWrapper.on('click', function(event){ 85 if( $(event.target).is($(this)) ) toggleCart(true); 86 }); 87 88 //delete an item from the cart 89 cartList.on('click', '.delete-item', function(event){ 90 event.preventDefault(); 91 removeProduct($(event.target).parents('.product')); 92 93 }); 94 95 //update item quantity 96 cartList.on('change', 'select', function(event){ 97 quickUpdateCart(); 98 }); 99 100 //reinsert item deleted from the cart 101 undo.on('click', 'a', function(event){ 102 clearInterval(undoTimeoutId); 103 event.preventDefault(); 104 cartList.find('.deleted').addClass('undo-deleted').one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(){ 105 $(this).off('webkitAnimationEnd oanimationend msAnimationEnd animationend').removeClass('deleted undo-deleted').removeAttr('style'); 106 quickUpdateCart(); 107 }); 108 undo.removeClass('visible'); 109 }); 110 } 111 function toggleCart(bool) { 112 var cartIsOpen = ( typeof bool === 'undefined' ) ? cartWrapper.hasClass('cart-open') : bool; 113 114 if( cartIsOpen ) { 115 cartWrapper.removeClass('cart-open'); 116 //reset undo 117 clearInterval(undoTimeoutId); 118 undo.removeClass('visible'); 119 cartList.find('.deleted').remove(); 120 121 setTimeout(function(){ 122 cartBody.scrollTop(0); 123 //check if cart empty to hide it 124 if( Number(cartCount.find('li').eq(0).text()) == 0) cartWrapper.addClass('empty'); 125 }, 500); 126 } else { 127 cartWrapper.addClass('cart-open'); 128 } 129 } 130 131 function addToCart(trigger) { 132 var cartIsEmpty = cartWrapper.hasClass('empty'); 133 134 $(document).ready(function () { 135 136 remove_id = localStorage.getItem('samples_id'); 137 diff = 0; 138 if(remove_id != null) 139 { 140 var parts_id; 141 parts_id=remove_id.split(","); 142 new_ids=[]; 143 144 for(i=0;i<=parts_id.length;i++) 145 { 146 if(parts_id[i] == trigger.data('id')) 147 { 148 diff = 1; 149 } 150 } 151 } 152 if(diff == 0) 153 { 154 var actual = localStorage.getItem('samples_id'); 155 156 var new_Value = trigger.data('id'); 157 var found = jQuery.inArray(new_Value, actual); 158 if (found >= 0) { 159 // Element was found, remove it. 160 filters.splice(found, 1); 161 } else { 162 // Element was not found, add it. 163 164 samples_items.push(trigger.data('id')); 165 samples_names.push(trigger.data('name').replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' ')); 166 samples_imgs.push(trigger.data('img')); 167 168 localStorage.setItem('samples_id', samples_items); 169 localStorage.setItem('samples_names', samples_names); 170 localStorage.setItem('samples_imgs', samples_imgs); 171 //update cart product list 172 173 addProduct(trigger.data('id'),trigger.data('name').replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' '),trigger.data('img')); 174 //update number of items 175 updateCartCount(cartIsEmpty); 176 //update total price 177 updateCartTotal(trigger.data('price'), true); 178 //show cart 179 cartWrapper.removeClass('empty'); 180 181 } 182 183 } 184 185 }); 186 } 187 function addProduct(id, name,img) { 188 //this is just a product placeholder 189 //you should insert an item with the selected product info 190 //replace productId, productName, price and url with your real product info 191 192 productId = id; 193 new_name = name.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' '); 194 count++; 195 var productAdded = $('<li class="product col-md-12 nospace"><div class="product-image col-md-2 nospace"><a href="#0"><img src="'+img+'" alt="placeholder" class="img-responsive"></a></div><div class="product-details col-md-10 nospace"><div class="col-md-9"><h3 class="bottomBannerBold" ><a href="#0">'+name+'</a></h3></div><div class="actions col-md-3 nospace">
195<a onclick="deleteProd('+productId+',\''+new_name+'\',\''+img+'\')" class="delete-item">Delete</a></div></li>'); 196 cartList.prepend(productAdded); 197 198 } 199 function removeProduct(product) { 200 201 clearInterval(undoTimeoutId); 202 cartList.find('.deleted').remove(); 203 var cartIsEmpty = cartWrapper.hasClass('empty'); 204 205 var topPosition = product.offset().top - cartBody.children('ul').offset().top , 206 //productQuantity = Number(product.find('.quantity').find('select').val()), 207 productTotPrice = Number(product.find('#price').text().replace('$', '')); 208 209 product.css('top', topPosition+'px').addClass('deleted'); 210 211 //update items count + total price 212 updateCartTotal(22, false); 213 updateCartCount(cartIsEmpty, -1); 214 //undo.addClass('visible'); 215 216 //wait 8sec before completely remove the item 217 undoTimeoutId = setTimeout(function(){ 218 undo.removeClass('visible'); 219 cartList.find('.deleted').remove(); 220 }, 8000); 221 } 222 223 function quickUpdateCart() { 224 var quantity = 0; 225 var price = 0; 226 227 cartList.children('li:not(.deleted)').each(function(){ 228 var singleQuantity = Number($(this).find('select').val()); 229 quantity = quantity + singleQuantity; 230 price = price + singleQuantity*Number($(this).find('.price').text().replace('$', '')); 231 }); 232 233 cartTotal.text(price.toFixed(2)); 234 cartCount.find('li').eq(0).text(quantity); 235 cartCount.find('li').eq(1).text(quantity+1); 236 } 237 238 function updateCartCount(emptyCart, quantity) { 239 if( typeof quantity === 'undefined' ) { 240 var actual = Number(cartCount.find('li').eq(0).text()) + 1; 241 var next = actual + 1; 242 243 if( emptyCart ) { 244 cartCount.find('li').eq(0).text(actual); 245 cartCount.find('li').eq(1).text(next); 246 } else { 247 cartCount.addClass('update-count'); 248 249 setTimeout(function() { 250 cartCount.find('li').eq(0).text(actual); 251 }, 150); 252 253 setTimeout(function() { 254 cartCount.removeClass('update-count'); 255 }, 200); 256 257 setTimeout(function() { 258 cartCount.find('li').eq(1).text(next); 259 }, 230); 260 } 261 } else { 262 var actual = Number(cartCount.find('li').eq(0).text()) + quantity; 263 264 var next = actual + 1; 265 266 267 cartCount.find('li').eq(0).text(actual); 268 cartCount.find('li').eq(1).text(next); 269 } 270 } 271 272 function updateCartTotal(price, bool) { 273 274 bool ? cartTotal.text( (Number(cartTotal.text()) + Number(price)).toFixed(2) ) : cartTotal.text( (Number(cartTotal.text()) - Number(price)).toFixed(2) ); 275 276 } 277 checkout.on('click', function(event){ 278 event.preventDefault(); 279 280 $('#reqSamplesModal').on('hidden.bs.modal', function () { 281 checkoutSamples(); 282 }) 283 //checkoutSamples(); 284 285 }); 286 function checkoutSamples() 287 { 288 289 var tracker=getUrl(); 290 291 var name = $('#name').val(); 292 var email = $('#email').val(); 293 var country = $('#country').val(); 294 var state = $('#state').val(); 295 var company = $('#company').val(); 296 var phone = $('#phone').val(); 297 var ocupation = $('#ocupation').val(); 298 299 $.ajax({ 300 data:{ 301 //items: items, 302 items: localStorage.getItem('samples_id'), 303 name: name, 304 email: email, 305 country: country, 306 state: state, 307 ocupation: ocupation, 308 company: company, 309 phone: phone, 310 origin: tracker.url_origin, 311 referrer: tracker.referrer, 312 lead_path: tracker.flow, 313 url:'brabbu.com/samples', 314 token_webuzz : 'g2zAsJ8NrvZHmdCuvydCWoGWNjYRsr9jYbPpDIqf', 315 }, 316 async:false, 317 type: "post", 318 url: "/include/form-response/samples-page-response.php", 319 cache: false, 320 dataType:"json", 321 322 success:function(data) 323 { 324 if(data == "OK"){ 325 console.log('ok'); 326 } 327 else 328 { 329 console.log('error'); 330 } 331 }, 332 }); 333 334 } 335
336 /////////////////////////////////////////////////// SAMPLES VARS ///////////////////////////////////////////// 337 338 var ID_samples = localStorage.getItem('samples_id'); 339 console.log(ID_samples); 340 var parts_samples; 341 parts_samples=ID_samples.split(","); 342 total_items_samples=[]; 343 teste_total = ""; 344 345 for(i=0;i<=parts_samples.length;i++) 346 { 347 if(teste_total != parts_samples[i]) 348 { 349 total_items_samples.push(parts_samples[i]); 350 351 } 352 teste_total = parts_samples[i]; 353 } 354 355 var NAME_samples = localStorage.getItem('samples_names'); 356 var name_parts_samples; 357 name_parts_samples=NAME_samples.split(','); 358 total_name_samples = []; 359 teste_total_names = ""; 360 361 for(i=0;i<=name_parts_samples.length;i++) 362 { 363 if(teste_total_names != name_parts_samples[i]) 364 { 365 total_name_samples.push(name_parts_samples[i]); 366 367 } 368 teste_total_names = name_parts_samples[i]; 369 } 370 371 var IMG_samples = localStorage.getItem('samples_imgs'); 372 var img_parts_samples; 373 img_parts_samples=IMG_samples.split(','); 374 total_img_samples = []; 375 teste_total_img = ""; 376
377 for(i=0;i<=img_parts_samples.length;i++) 378 { 379 if(teste_total_img != img_parts_samples[i]) 380 { 381 total_img_samples.push(img_parts_samples[i]); 382 383 } 384 teste_total_img = total_img_samples[i]; 385 } 386 387 if(total_items_samples.length > 0) 388 { 389 390 var cartIsEmpty = cartWrapper.hasClass('empty'); 391 var teste = ""; 392 393 for(i=0;i<=total_items_samples.length;i++) 394 { 395 if(total_items_samples[i] != "" && total_items_samples[i] != undefined) 396 { 397 if(total_items_samples[i] != teste) 398 { 399 400 var productAdded= $('<li class="product col-md-12 nospace"><div class="product-image col-md-2 nospace"><a href="#0"><img class="img-responsive" src="'+total_img_samples[i]+'" alt="placeholder"></a></div><div class="product-details col-md-10 nospace"><div class="col-md-9"><h3 class="bottomBannerBold" ><a href="#0">'+total_name_samples[i]+'</a></h3></div><div class="actions col-md-3 nospace"><a onclick="deleteProd('+ total_items_samples[i] +',\''+total_name_samples[i].replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' ')+'\',\''+total_img_samples[i]+'\')" class="delete-item">Delete</a></div></div></li>'); 401 cartList.prepend(productAdded); 402 updateCartCount(cartIsEmpty); 403 count++; 404 405 } 406 teste = total_items_samples[i]; 407 } 408 } 409 price = count * 22; 410 updateCartTotal(price, true); 411 412 //show cart 413 cartWrapper.removeClass('empty'); 414 } 415 var contentType ="application/x-www-form-urlencoded; charset=utf-8"; 416 } 417 else 418 { 419 var cartWrapper = $('.cd-cart-container-new'); 420 //product id - you don't need a counter in your real project but you can use your real product id 421 var productId = 0; 422 423 if( cartWrapper.length > 0 ) { 424 //store jQuery objects 425 var cartBody = cartWrapper.find('.body-new') 426 var cartList = cartBody.find('ul').eq(0); 427 var cartTotal = cartWrapper.find('.checkout').find('span'); 428 var cartTrigger = cartWrapper.children('.cd-cart-trigger-new'); 429 var cartCount = cartTrigger.children('.count-new') 430 var addToCartBtn = $('.cd-add-to-cart-new'); 431 var checkout = $('.checkout'); 432 var undo = cartWrapper.find('.undo'); 433 var undoTimeoutId; 434 435 //add product to cart 436 addToCartBtn.on('click', function(event){ 437 event.preventDefault(); 438 addToCart($(this)); 439 }); 440 441 //open/close cart 442 cartTrigger.on('click', function(event){ 443 event.preventDefault(); 444 toggleCart(); 445 }); 446 447 //close cart when clicking on the .cd-cart-container::before (bg layer) 448 cartWrapper.on('click', function(event){ 449 if( $(event.target).is($(this)) ) toggleCart(true); 450 }); 451 452 //delete an item from the cart 453 cartList.on('click', '.delete-item', function(event){ 454 event.preventDefault(); 455 removeProduct($(event.target).parents('.product')); 456 457 }); 458 459 //update item quantity 460 cartList.on('change', 'select', function(event){ 461 quickUpdateCart(); 462 }); 463 //reinsert item deleted from the cart 464 undo.on('click', 'a', function(event){ 465 clearInterval(undoTimeoutId); 466 event.preventDefault(); 467 cartList.find('.deleted').addClass('undo-deleted').one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(){ 468 $(this).off('webkitAnimationEnd oanimationend msAnimationEnd animationend').removeClass('deleted undo-deleted').removeAttr('style'); 469 quickUpdateCart(); 470 }); 471 undo.removeClass('visible'); 472 }); 473 } 474 function toggleCart(bool) { 475 var cartIsOpen = ( typeof bool === 'undefined' ) ? cartWrapper.hasClass('cart-open') : bool; 476 477 if( cartIsOpen ) { 478 cartWrapper.removeClass('cart-open'); 479 //reset undo 480 clearInterval(undoTimeoutId); 481 undo.removeClass('visible'); 482 cartList.find('.deleted').remove(); 483 484 setTimeout(function(){ 485 cartBody.scrollTop(0); 486 //check if cart empty to hide it 487 if( Number(cartCount.find('li').eq(0).text()) == 0) cartWrapper.addClass('empty'); 488 }, 500); 489 } else { 490 cartWrapper.addClass('cart-open'); 491 } 492 } 493 function addToCart(trigger) { 494 var total = $('#wishNotify').text(); 495 if(total == '0') 496 { 497 $('#wish').find('a').attr('data-toggle','modal'); 498 } 499 500 501 502 503 var cartIsEmpty = cartWrapper.hasClass('empty'); 504 505 $(document).ready(function () { 506 507 508 remove_id = localStorage.getItem('id'); 509 diff = 0; 510 if(remove_id != null) 511 { 512 var parts_id; 513 parts_id=remove_id.split(","); 514 new_ids=[]; 515 for(i=0;i<=parts_id.length;i++) 516 { 517 if(parts_id[i] == trigger.data('id')) 518 { 519 diff = 1; 520 } 521 } 522 } 523 524 if(diff == 0) 525 { 526 items.push(localStorage.getItem('id')); 527 names.push(localStorage.getItem('name')); 528 imgs.push(localStorage.getItem('img')); 529 width.push(localStorage.getItem('width')); 530 depth.push(localStorage.getItem('depth')); 531 height.push(localStorage.getItem('height')); 532 sub.push(localStorage.getItem('sub')); 533 var actual = items; 534 535 536 var new_Value = trigger.data('id'); 537 var found = jQuery.inArray(new_Value, actual); 538 if (found >= 0) { 539 // Element was found, remove it. 540 //filters.splice(found, 1); 541 } else { 542 // Element was not found, add it. 543 items.push(trigger.data('id')); 544 names.push(trigger.data('name').replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' ')); 545 imgs.push(trigger.data('img')); 546 width.push(trigger.data('width')); 547 depth.push(trigger.data('depth')); 548 height.push(trigger.data('height')); 549 sub.push(trigger.data('sub')); 550 551 localStorage.setItem('id', items); 552 localStorage.setItem('name', names); 553 localStorage.setItem('img', imgs); 554 localStorage.setItem('width', width); 555 localStorage.setItem('depth', depth); 556 localStorage.setItem('height', height); 557 localStorage.setItem('sub', sub); 558 addProduct(trigger.data('id'),trigger.data('name').replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, ' '),trigger.data('img'), 559 trigger.data('width'),trigger.data('depth'),trigger.data('height'),trigger.data('sub')); 560 561 //update cart product list 562 } 563 } 564 565 }); 566 567 //update number of items 568 updateCartCount(cartIsEmpty); 569 570 //show cart 571 cartWrapper.removeClass('empty'); 572 } 573 574 function addProduct(id, name,img,width,depth,height,sub) { 575 //this is just a product placeholder 576 //you should insert an item with the selected product info 577 //replace productId, productName, price and url with your real product info 578 579 productId = id; 580 var count = 0; 581 count = $('#wishNotify').text(); 582 583 count++; 584 585 $('#wishNotify').text(count); 586 587 var productAdded = $('<li class="product col-md-12 nospace marginBottom" id="'+id+'" data-name="'+name+'" data-img="'+img+'" data-width="'+width+'" data-height="'+height+'" data-depth="'+depth+'" data-sub="'+sub+'"><div class="product-image col-md-2 nospace"><a href="#0"><img class="img-responsive" src="'+img+'" alt="placeholder"></a></div><div class="product-details col-md-10 nospace"><a class="col-md-10" href="#0"><h3 class="bottomBannerBold" >'+name+' '+sub+' </h3><p>Dimensions: W:'+width+' D:'+depth+' H:'+height+'</p></a><div class="actions col-md-2"><a class="center-block delete-item">Delete</a></div></div></li>'); 588 cartList.prepend(productAdded); 589 590 swal({ 591 title: "Added to Wishlist", 592 text: "", 593 animation: false, 594 confirmButtonColor: "#000000" 595 }); 596 } 597 function removeProduct(product) { 598 clearInterval(undoTimeoutId); 599 cartList.find('.deleted').remove(); 600 601 var topPosition = product.offset().top - cartBody.children('ul').offset().top , 602 productQuantity = Number(product.find('.quantity').find('select').val()), 603 productTotPrice = Number(product.find('.price').text().replace('$', '')) * productQuantity; 604 605 product.css('top', topPosition+'px').addClass('deleted'); 606 607 remove_id = localStorage.getItem('id'); 608 remove_name = localStorage.getItem('name'); 609 remove_img = localStorage.getItem('img'); 610 remove_width = localStorage.getItem('width'); 611 remove_depth = localStorage.getItem('depth'); 612 remove_height = localStorage.getItem('height'); 613 remove_sub = localStorage.getItem('sub'); 614 615 remove_id = remove_id.replace(product.attr('id')+',',''); 616 remove_id = remove_id.replace(product.attr('id'),''); 617 618 remove_name = remove_name.replace(product.attr('data-name')+',',''); 619 remove_name = remove_name.replace(product.attr('data-name'),''); 620 621 remove_img = remove_img.replace(product.attr('data-img')+',',''); 622 remove_img = remove_img.replace(product.attr('data-img'),''); 623 624 remove_width = remove_width.replace(product.attr('data-width')+',',''); 625 remove_width = remove_width.replace(product.attr('data-width'),''); 626 627 remove_depth = remove_depth.replace(product.attr('data-depth')+',',''); 628 remove_depth = remove_depth.replace(product.attr('data-depth'),''); 629 630 remove_height = remove_height.replace(product.attr('data-height')+',',''); 631 remove_height = remove_height.replace(product.attr('data-height'),''); 632 633 remove_sub = remove_sub.replace(product.attr('data-sub')+',',''); 634 remove_sub = remove_sub.replace(product.attr('data-sub'),''); 635 636 localStorage.setItem('id', remove_id); 637 localStorage.setItem('name', remove_name); 638 localStorage.setItem('img', remove_img); 639 localStorage.setItem('width', remove_width); 640 localStorage.setItem('depth', remove_depth); 641 localStorage.setItem('height', remove_height); 642 localStorage.setItem('sub', remove_sub); 643 644 items = []; 645 names = []; 646 imgs = []; 647 width = []; 648 depth = []; 649 height = []; 650 sub = []; 651 652 items.push(localStorage.getItem('id')); 653 names.push(localStorage.getItem('name')); 654 imgs.push(localStorage.getItem('img')); 655 width.push(localStorage.getItem('width')); 656 depth.push(localStorage.getItem('depth')); 657 height.push(localStorage.getItem('height')); 658 sub.push(localStorage.getItem('sub')); 659 660 var count = $('#wishNotify').text(); 661 count--; 662 663 $('#wishNotify').text(count); 664 665 if(count == '0') 666 { 667 $('#wish').find('a').removeAttr('data-toggle'); 668 } 669 670 product.remove(); 671 672 //update items count + total price 673 //updateCartTotal(productTotPrice, false); 674 updateCartCount(true, -productQuantity); 675 undo.addClass('visible'); 676 677 //wait 8sec before completely remove the item 678 undoTimeoutId = setTimeout(function(){ 679 undo.removeClass('visible'); 680 cartList.find('.deleted').remove(); 681 }, 8000); 682 } 683 684 function quickUpdateCart() { 685 var quantity = 0; 686 var price = 0; 687 688 cartList.children('li:not(.deleted)').each(function(){ 689 var singleQuantity = Number($(this).find('select').val()); 690 quantity = quantity + singleQuantity; 691 price = price + singleQuantity*Number($(this).find('.price').text().replace('$', '')); 692 }); 693 694 cartTotal.text(price.toFixed(2)); 695 cartCount.find('li').eq(0).text(quantity); 696 cartCount.find('li').eq(1).text(quantity+1); 697 } 698 699 function updateCartCount(emptyCart, quantity) { 700 if( typeof quantity === 'undefined' ) { 701 var actual = Number(cartCount.find('li').eq(0).text()) + 1; 702 var next = actual + 1; 703 704 if( emptyCart ) { 705 cartCount.find('li').eq(0).text(actual); 706 cartCount.find('li').eq(1).text(next); 707 } else { 708 cartCount.addClass('update-count'); 709 710 setTimeout(function() { 711 cartCount.find('li').eq(0).text(actual); 712 }, 150); 713 714 setTimeout(function() { 715 cartCount.removeClass('update-count'); 716 }, 200); 717 718 setTimeout(function() { 719 cartCount.find('li').eq(1).text(next); 720 }, 230); 721 } 722 } else { 723 var actual = Number(cartCount.find('li').eq(0).text()) + quantity; 724 var next = actual + 1; 725 726 cartCount.find('li').eq(0).text(actual); 727 cartCount.find('li').eq(1).text(next); 728 } 729 } 730 731 function updateCartTotal(price, bool) { 732 733 bool ? cartTotal.text( (Number(cartTotal.text()) + Number(price)).toFixed(2) ) : cartTotal.text( (Number(cartTotal.text()) - Number(price)).toFixed(2) ); 734 } 735 checkout.on('click', function(event){ 736 event.preventDefault(); 737 738 checkoutWishlist(); 739 }); 740 741 function checkoutWishlist() 742 { 743 var form = $(document.createElement('form')); 744 $(form).attr("action", "wishlist.php"); 745 $(form).attr("method", "POST"); 746 $(form).css("display", "none"); 747 748 var ids = $("<input>") 749 .attr("type", "text") 750 .attr("name", "ids") 751 .val(localStorage.getItem('id')); 752 $(form).append($(ids)); 753 754 form.appendTo( document.body ); 755 $(form).submit(); 756 757 } 758
759 /////////////////////////////////////////////////// WEBSITE VARS ///////////////////////////////////////////// 760 761 var ID = localStorage.getItem('id'); 762 if(ID == null) 763 { 764 ID = ","; 765 } 766 var parts; 767 parts=ID.split(","); 768 total_items=[]; 769 770 for(i=0;i<=parts.length;i++) 771 { 772 total_items.push(parts[i]); 773 } 774 775 var NAME = localStorage.getItem('name'); 776 if(NAME == null) 777 { 778 NAME = ","; 779 } 780 var name_parts; 781 name_parts=NAME.split(','); 782 total_name = []; 783 784 for(i=0;i<=name_parts.length;i++) 785 { 786 total_name.push(name_parts[i]); 787 } 788 789 790 var IMG = localStorage.getItem('img'); 791 if(IMG == null) 792 { 793 IMG = ","; 794 } 795 var img_parts; 796 img_parts=IMG.split(','); 797 total_img = []; 798 799 for(i=0;i<=img_parts.length;i++) 800 { 801 total_img.push(img_parts[i]); 802 } 803 804 var WIDTH = localStorage.getItem('width'); 805 if(WIDTH == null) 806 { 807 WIDTH = ","; 808 } 809 var width_parts; 810 width_parts=WIDTH.split(','); 811 total_width = []; 812 813 for(i=0;i<=width_parts.length;i++) 814 { 815 total_width.push(width_parts[i]); 816 } 817 818 819 var DEPTH = localStorage.getItem('depth'); 820 if(DEPTH == null) 821 { 822 DEPTH = ","; 823 } 824 var depth_parts; 825 depth_parts=DEPTH.split(','); 826 total_depth = []; 827 828 for(i=0;i<=depth_parts.length;i++) 829 { 830 total_depth.push(depth_parts[i]); 831 } 832 833 834 var HEIGHT = localStorage.getItem('height'); 835 if(HEIGHT == null) 836 { 837 HEIGHT = ","; 838 } 839 var height_parts; 840 height_parts=HEIGHT.split(','); 841 total_height = []; 842 843 for(i=0;i<=height_parts.length;i++) 844 { 845 total_height.push(height_parts[i]); 846 } 847 848 849 850 var SUB = localStorage.getItem('sub'); 851 if(SUB == null) 852 { 853 SUB = ","; 854 } 855 var sub_parts; 856 sub_parts=SUB.split(','); 857 total_sub = []; 858 859 for(i=0;i<=sub_parts.length;i++) 860 { 861 total_sub.push(sub_parts[i]); 862 } 863 864 var count = 0; 865 866 if(total_items.length > 0) 867 { 868 869 870 var cartIsEmpty = cartWrapper.hasClass('empty'); 871 872 for(i=0;i<=total_items.length;i++) 873 { 874 875 876 if(total_items[i] != "" && total_items[i] != undefined) 877 { 878 879 count++; 880 var productAdded = $('<li class="product col-md-12 nospace marginBottom" id="'+ total_items[i] +'" data-name="'+total_name[i]+'" data-img="'+total_img[i]+'" data-width="'+total_width[i]+'" data-height="'+total_height[i]+'" data-depth="'+total_depth[i]+'" data-sub="'+total_sub[i]+'"><div class="product-image col-md-2 nospace"><a href="#0"><img class="img-responsive" src="'+total_img[i]+'" alt="placeholder"></a></div><div class="product-details col-md-10 nospace"><a class="col-md-10" href="#0"><h3 class="bottomBannerBold" >'+total_name[i]+' '+total_sub[i]+' </h3><p> Dimensions:: W:'+total_width[i]+' D:'+total_depth[i]+' H:'+total_height[i]+'</p></a><div class="actions col-md-2"><a class="center-block delete-item">Delete</a></div></div></li>'); 881 cartList.prepend(productAdded); 882 updateCartCount(cartIsEmpty); 883 $('#wishNotify').text(count); 884 } 885 886 } 887 888 //show cart 889 cartWrapper.removeClass('empty'); 890 } 891 var contentType ="application/x-www-form-urlencoded; charset=utf-8"; 892 } 893});
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.