1var current_url = document.URL.split("/"); 2var current_url = current_url[current_url.length - 1]; 3//* Change background color and text color for selected category button 4var cat_page = document.querySelector("body#category"); 5if (cat_page) { 6 var cat_list_wrap = cat_page.querySelector("#left-column"); 7 var cat_list_wrap = cat_list_wrap.querySelector("ul"); 8 var cat_list_wrap = cat_list_wrap.querySelector("ul"); 9 var cat_list = cat_list_wrap.querySelectorAll("li"); 10 11 for (let x = 0; x < cat_list.length; x++) { 12 var cat_btn = cat_list[x].querySelector("a"); 13 var cat_btn_link = cat_btn.href.split("/"); 14 var cat_btn_link = cat_btn_link[cat_btn_link.length - 1]; 15 16 if (cat_btn_link == current_url) { 17 cat_btn.classList.add("active"); 18 } 19 } 20} 21//* Make current menu item bold 22var header_wrap = document.querySelector("#header_menu_wrapper"); 23if (header_wrap) { 24 var header = header_wrap.querySelector("#top-menu"); 25 var nav_items = header.querySelectorAll("li"); 26 27 for (let n = 0; n < nav_items.length; n++) { 28 var nav_link = nav_items[n].querySelector("a"); 29 var link = nav_link.href.split("/"); 30 var link = link[link.length - 1]; 31 32 if (link == current_url) { 33 nav_link.classList.add("active"); 34 } else if (cat_page) { 35 nav_items[1].querySelector("a").classList.add("active"); 36 } 37 } 38} 39 40//* Load correct google map for selected location 41var store_locations_page = document.querySelector("body#stores"); 42if (store_locations_page) { 43 const county_list_wrap = document.querySelector("#county_list_wrap"); 44 const county_list = county_list_wrap.querySelector(".county_wrapper"); 45 const county_btns_wrap = county_list.querySelectorAll(".button_wrap"); 46 47 const county_locations_list_wrap = document.querySelector( 48 "#current_county_locations_wrap" 49 ); 50 const county_locations_list = 51 county_locations_list_wrap.querySelectorAll(".location_wrap"); 52 53 for (var c = 0; c < county_btns_wrap.length; c++) { 54 const county_btn = county_btns_wrap[c].querySelector(".county_btn"); 55 56 county_btn.addEventListener("click", function (event) { 57 for (var cx = 0; cx < county_btns_wrap.length; cx++) { 58 if (county_btns_wrap[cx] === event.target.parentElement) { 59 county_btns_wrap[cx].classList.add("active"); 60 for (let l = 0; l < county_locations_list.length; l++) { 61 const location_name = county_locations_list[l].querySelector("h2"); 62 if (county_btn.innerHTML == location_name.innerHTML) { 63 county_locations_list[l].classList.remove("d-none"); 64 } else { 65 county_locations_list[l].classList.add("d-none"); 66 } 67 } 68 } else { 69 county_btns_wrap[cx].classList.remove("active"); 70 } 71 } 72 }); 73 } 74} 75 76//** Burger navigation */ 77 78var burger_nav_wrap = document.querySelector("#burger_nav_wrap"); 79if (burger_nav_wrap) { 80 var burger_nav_btn = burger_nav_wrap.querySelector("#burger_nav_btn"); 81 82 burger_nav_btn.addEventListener("click", function () { 83 if (burger_nav_wrap.classList.contains("active")) { 84 burger_nav_wrap.classList.remove("active"); 85 } else { 86 burger_nav_wrap.classList.add("active"); 87 } 88 }); 89 // console.log(burger_nav_btn); 90} 91 92var cart__overview = document.querySelector('div.cart-overview'); 93if (cart__overview) { 94 const cart__items = cart__overview.querySelector('ul.cart-items'); 95 if (cart__items) { 96 const cart__item = cart__items.querySelectorAll('li.cart-item'); 97 for (let i = 0; i < cart__item.length; i++) { 98 const product__actions = cart__item[i].querySelector('.product-line-actions'); 99 const product__actions__delete = product__actions.querySelector('.remove-from-cart'); 100 101 product__actions__delete.addEventListener('click', function() { 102 const product__count = parseInt(product__actions.querySelector('input.js-cart-line-product-quantity').value); 103 const products__counter = document.querySelectorAll('#products__count'); 104 if (products__counter) { 105 for (let i = 0; i < products__counter.length; i++) { 106 let count = parseInt(products__counter[i].innerHTML); 107 products__counter[i].innerHTML = parseInt(count - product__count); 108 } 109 } 110 }); 111 } 112 } 113} 114 115//** Cart button in navigation bar */ 116document.addEventListener('click', function(event) { 117 var product_page_check = document.querySelector("#js-product-list"); 118 var single_product_page_check = document.querySelector('body#product'); 119 var cart_btn_in_header = document.querySelector("#header_cart_icon"); 120 if (product_page_check) { 121 const single_product = product_page_check.querySelectorAll(".product"); 122 for (let x = 0; x < single_product.length; x++) { 123 const product_flags = single_product[x].querySelector("ul.product-flags"); 124 const out_of_stock = product_flags.querySelector("li.out_of_stock"); 125 126 if (!out_of_stock) { 127 const add_to_cart_btn_wrap = single_product[x].querySelector("form#add-to-cart-or-refresh"); 128 const add_to_cart_btn = add_to_cart_btn_wrap.querySelector("button.add-to-cart"); 129 130 if (add_to_cart_btn.contains(event.target)) { 131 if (!cart_btn_in_header.classList.contains("d-block")) { 132 cart_btn_in_header.classList.remove("d-none"); 133 cart_btn_in_header.classList.add("d-block"); 134 } 135 136 const products__counter = document.querySelectorAll('#products__count'); 137 if (products__counter) { 138 for (let i = 0; i < products__counter.length; i++) { 139 let count = parseInt(products__counter[i].innerHTML); 140 products__counter[i].innerHTML = ++count; 141 } 142 } 143 144 const added_to_cart__notice = document.querySelector('#added_to_cart__notice'); 145 if (added_to_cart__notice) { 146 const product__title = single_product[x].querySelector('.product-title').querySelector('a').innerHTML; 147 const single__notice = document.createElement('div'); 148 single__notice.classList.add('notice'); 149 const single__notice__title = document.createElement('div'); 150 single__notice__title.classList.add('notice__title'); 151 single__notice__title.innerHTML = product__title; 152 single__notice.appendChild(single__notice__title); 153 const single__notice__icon = document.createElement('div'); 154 single__notice__icon.classList.add('notice__icon_wrap'); 155 single__notice__icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m340.652-49.717-77.674-131.348-147.826-32.717L129.63-365.37 29.478-480 129.63-594.63l-14.478-151.588 147.826-32.717 77.674-131.348L480-850.848l139.348-59.435 77.674 131.348 147.826 32.717L830.37-594.63 930.522-480 830.37-365.37l14.478 151.588-147.826 32.717-77.674 131.348L480-109.152 340.652-49.717Zm38.544-115.87L480-209.348l102.804 43.761 55.283-95.043 108.565-25.522-9.522
155-111.044L809.935-480l-72.805-84.804 9.522-111.044-108.565-23.522-57.283-95.043L480-750.652l-102.804-43.761-55.283 95.043-108.565 23.522 9.522 111.044L150.065-480l72.805 82.804-9.522 113.044 108.565 23.522 57.283 95.043ZM480-480Zm-42 144.63L666.63-564l-58.869-60.391L438-454.63l-85.761-84.24L293.37-480 438-335.37Z"/></svg>'; 156 single__notice.appendChild(single__notice__icon); 157 added_to_cart__notice.appendChild(single__notice); 158 setTimeout(() => { 159 single__notice.classList.add('active'); 160 setTimeout(() => { 161 single__notice.classList.remove('active'); 162 setTimeout(() => { 163 single__notice.remove(); 164 }, 100); 165 }, 1000); 166 }, 100); 167 } 168 }; 169 } 170 } 171 } else if (single_product_page_check) { 172 var add_to_cart_btn = single_product_page_check.querySelector('button.add-to-cart'); 173 var product_qty = single_product_page_check.querySelector('input#quantity_wanted'); 174 175 176 177 178 if (add_to_cart_btn.contains(event.target)) { 179 if (!cart_btn_in_header.classList.contains("d-block")) { 180 cart_btn_in_header.classList.remove("d-none"); 181 cart_btn_in_header.classList.add("d-block"); 182 } 183 184 const products__counter = document.querySelectorAll('#products__count'); 185 if (products__counter) { 186 for (let i = 0; i < products__counter.length; i++) { 187 let count = parseInt(products__counter[i].innerHTML); 188 products__counter[i].innerHTML = count + parseInt(product_qty.value); 189 } 190 } 191 192 const added_to_cart__notice = document.querySelector('#added_to_cart__notice'); 193 if (added_to_cart__notice) { 194 const product__title = single_product_page_check.querySelector('.product-container').querySelector('h1.h1').innerHTML; 195 const single__notice = document.createElement('div'); 196 single__notice.classList.add('notice'); 197 const single__notice__title = document.createElement('div'); 198 single__notice__title.classList.add('notice__title'); 199 single__notice__title.innerHTML = product__title; 200 single__notice.appendChild(single__notice__title); 201 const single__notice__icon = document.createElement('div'); 202 single__notice__icon.classList.add('notice__icon_wrap'); 203 single__notice__icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m340.652-49.717-77.674-131.348-147.826-32.717L129.63-365.37 29.478-480 129.63-594.63l-14.478-151.588 147.826-32.717 77.674-131.348L480-850.848l139.348-59.435 77.674 131.348 147.826 32.717L830.37-594.63 930.522-480 830.37-365.37l14.478 151.588-147.826 32.717-77.674 131.348L480-109.152 340.652-49.717Zm38.544-115.87L480-209.348l102.804 43.761 55.283-95.043 108.565-25.522-9.522-111.044L809.935-480l-72.805-84.804 9.522-111.044-108.565-23.522-57.283-95.043L480-750.652l-102.804-43.761-55.283 95.043-108.565 23.522 9.522 111.044L150.065-480l72.805 82.804-9.522 113.044 108.565 23.522 57.283 95.043ZM480-480Zm-42 144.63L666.63-564l-58.869-60.391L438-454.63l-85.761-84.24L293.37-480 438-335.37Z"/></svg>'; 204 single__notice.appendChild(single__notice__icon); 205 added_to_cart__notice.appendChild(single__notice); 206 setTimeout(() => { 207 single__notice.classList.add('active'); 208 setTimeout(() => { 209 single__notice.classList.remove('active'); 210 setTimeout(() => { 211 single__notice.remove(); 212 }, 100); 213 }, 1000); 214 }, 100); 215 } 216 }; 217 218 219 } 220}); 221 222var product_page = document.querySelector("body#product"); 223if (product_page) { 224 var header = document.querySelector("#header"); 225 const product_cover = product_page.querySelector(".product-cover"); 226 const product_img = product_cover.querySelector(".layer"); 227 const product_modal = document.querySelector("#product-modal"); 228 229 document.addEventListener("click", function () { 230 product_img.addEventListener("click", function () { 231 header.classList.add("lower"); 232 }); 233 setTimeout(() => { 234 if ( 235 !product_modal.classList.contains("in") && 236 !header.classList.contains("lower") 237 ) { 238 console.log("modal kinni ja header pole klassi"); 239 } else if ( 240 !product_modal.classList.contains("in") && 241 header.classList.contains("lower") 242 ) { 243 console.log("modal kinni ja headeril on klass"); 244 header.classList.remove("lower"); 245 } else if ( 246 product_modal.classList.contains("in") && 247 header.classList.contains("lower") 248 ) { 249 console.log("modal lahti ja headeril on klass"); 250 } 251 }, 150); 252 }); 253 console.log(header); 254 console.log(product_img); 255 console.log(product_modal); 256}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.