1let favorite = localStorage.getItem('primusFavorite'); 2 3function renderFavoriteCount() { 4 5 globalCount = 0; 6 if (favorite !== null) { 7 tmp = JSON.parse(favorite); 8 for (let id in tmp) { 9 $('#'+tmp[id]).find('.add-favorite').addClass('is-active'); 10 $('#'+tmp[id]).find('.add-favorite').addClass('remove-favorite'); 11 $('#'+tmp[id]).find('.add-favorite').removeClass('add-favorite'); 12 $('#'+tmp[id]).find('#span-favorite').html('УдалиÑÑ<br> из избÑанного') 13 globalCount++; 14 } 15 $('.globalCount-Favorite').text(globalCount); 16 $('.globalCount-Favorite').show(); 17 } 18 if (globalCount == 0) { 19 $('.globalCount-Favorite').hide(); 20 } 21} 22 23function removeFavorite(id, product_title) { 24 25 if (favorite !== null) { 26 favorite = JSON.parse(favorite); 27 if (favorite.indexOf(id) > -1) { 28 favorite.splice(favorite.indexOf(id),1); 29 } 30 } else { 31 favorite = []; 32 33 } 34 tmp = JSON.stringify(favorite); 35 localStorage.setItem('primusFavorite', tmp); 36 favorite = localStorage.getItem('primusFavorite'); 37 $('#'+id).find('.add-favorite').addClass('is-active'); 38 $('#product-favorite').find('.modal-form__title').text('Ð¢Ð¾Ð²Ð°Ñ Ñдален из избÑанного'); 39 $('#product-favorite').find('.modal-form__subtitle').html('Ð¢Ð¾Ð²Ð°Ñ <span class="product_title">'+ product_title +'</span> ÑÑпеÑно Ñдален из избÑанного'); 40 $.magnificPopup.open({ 41 items: { 42 src: '#product-favorite', 43 }, 44 type: 'inline' 45 }); 46} 47 48function addFavorite(id, product_title) { 49 50 if (favorite !== null) { 51 favorite = JSON.parse(favorite); 52 if (favorite.indexOf(id) == -1) { 53 favorite.push(id); 54 } 55 } else { 56 favorite = []; 57 favorite.push(id); 58 } 59 tmp = JSON.stringify(favorite); 60 localStorage.setItem('primusFavorite', tmp); 61 favorite = localStorage.getItem('primusFavorite'); 62 $('#'+id).find('.add-favorite').addClass('is-active'); 63 $('#product-favorite').find('.modal-form__title').text('Ð¢Ð¾Ð²Ð°Ñ Ð´Ð¾Ð±Ð°Ð²Ð»ÐµÐ½ в избÑанное'); 64 $('#product-favorite').find('.modal-form__subtitle').html('Ð¢Ð¾Ð²Ð°Ñ <span class="product_title">'+ product_title +'</span> ÑÑпеÑно добавлен в избÑанное'); 65 $.magnificPopup.open({ 66 items: { 67 src: '#product-favorite', 68 }, 69 type: 'inline' 70 }); 71} 72 73$().ready(function () { 74 75 76 renderFavoriteCount(); 77 78 $(document).on('click','.add-favorite',function (){ 79 80 let product = $(this).parent().parent().parent().parent(); 81 82 console.log(product) 83 let productId = Number(product.attr('id')); 84 addFavorite(productId, product.data('title')); 85 renderFavoriteCount(); 86 87 $('#' + productId).find('.add-favorite').addClass('is-active'); 88 $('#' + productId).find('#span-favorite').html('УдалиÑÑ<br> из избÑанного') 89 $('#' + productId).find('.add-favorite').addClass('remove-favorite'); 90 $('#' + productId).find('.add-favorite').removeClass('add-compare'); 91 92 }); 93 $(document).on('click','.remove-favorite',function (){ 94 95 let product = $(this).parent().parent().parent().parent(); 96 let productId = Number(product.attr('id')); 97 removeFavorite(productId, product.data('title')); 98 renderFavoriteCount(); 99 100 $('#' + productId).find('.remove-favorite').removeClass('is-active'); 101 $('#' + productId).find('.remove-favorite').addClass('add-favorite'); 102 $('#' + productId).find('#span-favorite').html('ÐобавиÑÑ<br> в избÑанное') 103 $('#' + productId).find('.remove-favorite').removeClass('remove-favorite'); 104 }); 105 106});
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.