1if (ProductNumber !== '') { 2 createCookie('productview','true') 3} 4else if (!$('.webshop-productlist').length) { 5 createCookie('productview',''); 6} 7 8//$(document).ready(function() { 9 10 var searchForm = $('#Search_Form'); 11 var basket = $('.basket'); 12 var currency = $.trim(basket.find('.currency').text()); 13 var productsCount = basket.data('count'); 14 15 var checkFavoriteUrl = '/images/skins/Bewise/images/icon-favorites-solid.svg'; 16 17 18 19 20 $('.usp').slick({ 21 infinite: true, 22 slidesToShow: 4, 23 slidesToScroll: 1, 24 autoplay: false, 25 arrows: false, 26 autoplaySpeed: 4000, 27 responsive: [{ 28 breakpoint: 1230, 29 settings: { 30 slidesToShow: 3 31 } 32 }, { 33 breakpoint: 800, 34 settings: { 35 slidesToShow: 1 36 } 37 }] 38 }); 39 40 41 42 43 44 45 var footerInview = new Waypoint.Inview({ 46 element: $('footer')[0], 47 enter: function() { 48 this.destroy(); 49 $('footer .menu').append($('.TopMenu_MenuItems').clone().removeAttr('class').addClass('footerMenu')); 50 51 let footerbackground = $.trim($('footer[data-src]').data('src')); 52 console.log(footerbackground); 53 if (footerbackground !== '') { 54 $('footer').css('background-image', 'url(' + footerbackground + ')'); 55 } 56 57 } 58 }); 59 60 basket.on('click',function() { 61 window.location.href = ShowBasketUrl; 62 }); 63 64 65 if (pageUrl.indexOf('checkout.html') < 0) { // hvis ikke checkout 66 67 68 69 var brandsInviewLoaded = false; 70 var brandsInview = new Waypoint.Inview({ 71 element: $('section.brands')[0], 72 enter: function() { 73 if (!brandsInviewLoaded) { 74 brandsInviewLoaded = true; 75 $('section.brands > div').slick({ 76 infinite: true, 77 slidesToShow: 7, 78 slidesToScroll: 1, 79 autoplay: true, 80 arrows: false, 81 autoplaySpeed: 4000, 82 lazyLoad: 'ondemand', 83 responsive: [{ 84 breakpoint: 1000, 85 settings: { 86 slidesToShow: 3 87 } 88 }, { 89 breakpoint: 800, 90 settings: { 91 slidesToShow: 2 92 } 93 }] 94 }); 95 } 96 } 97 }); 98 99 100 UpdateFavoritesCount(); 101 } 102 103 104 if (pageUrl.indexOf('frontpage.html') !== -1) { // frontpage 105 106 if (getCookie('DDCookiePolicyDialog') == 'hide') { 107 $('.slideshow').slick({ 108 infinite: true, 109 slidesToShow: 1, 110 slidesToScroll: 1, 111 autoplay: true, 112 autoplaySpeed: 5000, 113 arrows:true, 114 prevArrow: '<i class="fa fa-chevron-left slick-prev"></i>', 115 nextArrow: '<i class="fa fa-chevron-right slick-next"></i>' 116 }); 117 118 119 $('article').after('<section class="blogSection"><div><span>Blog</span><div class="blogFrontpage ProductList_Custom_DIV"></div></div></section>',$('.fpFooterText')); 120 $('.blogFrontpage').append($('.Frontpage_Custom_DIV').addClass('ProductList_Custom_DIV').removeClass('Frontpage_Custom_DIV')); 121 transformArticles(); 122 } 123 124 125 } 126 else if (document.querySelector('body').classList.contains('webshop-productlist')) { // productlist 127 128 129 130 131 132 } 133 else if (ProductNumber !== '') { // productcard 134 135 136 137 138 } 139 else if (pageUrl.indexOf('showbasket.html') !== -1) { // showbasket 140 141 $('.giftWrap td').each(function(i) { 142 var id = 'gw' + i; 143 var td = $(this); 144 var label = '<label for="' + id + '"><span class="input"></span>' + $.trim(td.text()) + '</label>'; 145 var input = td.find('input').prop('id',id); 146 td.closest('div').empty().append(input,label); 147 }); 148 149 $.get('/shop/-10054p.html',function(cardhtml) { 150 let usp = $(cardhtml).find('.productcardUsp'); 151 if (usp.length) { 152 $('.ShowBasket_Custom_DIV').after(usp); 153 } 154 }); 155 156 } 157 else if (pageUrl.indexOf('customer.html') !== -1) { // customer 158 $('.Login_Customer > tbody > tr, .ForgotPassword_Customer > tbody > tr').each(function() { 159 var tr = $(this); 160 var firstTd = tr.children('td').eq(0); 161 var title = firstTd.text(); 162 tr.find('.TextInputField_Customer').attr('placeholder',title); 163 firstTd.remove(); 164 }); 165 166 $('.change-password-wrapper input[type="password"]').each(function() { 167 var input = $(this); 168 var titleContainer = input.parent().prev(); 169 var title = titleContainer.text(); 170 input.attr('placeholder',title); 171 titleContainer.remove(); 172 }); 173 174 var errorContainer = $('.ErrorText_customerlogin'); 175 if (errorContainer.length) { 176 $('.webshop-customercenter input[type="text"]#xprofileid.TextInputField_Customer').before(errorContainer); 177 } 178 179 var loginButton = $('.Login_Customer #xprofileid1'); 180 if (loginButton.length) { 181 loginButton.closest('form').parent().addClass('showFlex').prepend($('.customerInfo')); 182 } 183 184 if (pageUrl.indexOf('?showForgotPswForm=1') !== -1) { 185 $('form[action="/shop/customer.html"]:not([name="CustomerCenterForm"])').replaceWith($('form[action="/shop/customer.html"][name="forgotpsw"]')); 186 } 187 188 189 } 190 else if (pageUrl.indexOf('favorites.html') !== -1) { // favorites 191 $('.FormTB_EmailLabelTD,.FormTB_SubjectLabelTD').each(function() { 192 var td = $(this); 193 var placeholder = td.text(); 194 td.next().find('input').prop('placeholder',placeholder); 195 td.remove(); 196 }); 197 } 198 199 200 if (ismobile) { // mobile 201 202 $('.btnMenu').on('click', function() { 203 if (!$('.mobileMenu').length) { 204 var mobileMainMenu = $('.TopMenu_MenuItems').clone().removeClass('TopMenu_MenuItems').addClass('mobileMainMenuUl');
205 var mobileMenuHeader = $('<div class="mobileMenuHeader">' + $('#ProductmenuContainer_DIV .Heading_ProductMenu').text() + '</div>'); 206 var mobileMainMenuHeader = $('<div class="mobileMainMenuHeader">Menu</div>'); 207 var mobileMenuUl = $('#ProductMenu_List').clone().removeAttr('id').addClass('mobileMenuUl'); 208 var mobileMenuInner = $('<div class="mobileMenuInner"></div>').append(mobileMenuHeader)/*.append(mobileMenuSearch)*/.append(mobileMenuUl).append(mobileMainMenuHeader).append(mobileMainMenu); 209 var mobileMenuContainer = $('<div class="mobileMenuContainer"></div>').append(mobileMenuInner); 210 var mobileMenu = $('<div class="mobileMenu"></div>').append(mobileMenuContainer); 211 212 $('body').prepend(mobileMenu); 213 214 var mobileMenuActiveGroup = mobileMenuUl.find('a.Activ_ProductMenu'); 215 mobileMenuActiveGroup.parentsUntil('.mobileMenuUl').addClass('open').show(); 216 mobileMenuActiveGroup.next('ul.dropdown').show(); 217 218 mobileMenuUl.find('li.has-dropdown').each(function() { 219 var li = $(this); 220 var subLiLength = li.children('ul').children('li').length; 221 var toggler = $('<div class="toggler"></div>'); 222 if (subLiLength) { 223 li.addClass('hasSubcat'); 224 li.children('a:not(#ActiveCategory_A)').append(toggler); 225 toggler.on('click', (function() { 226 li.children('ul.dropdown').slideToggle(); 227 toggler.closest('li').toggleClass('open'); 228 return false; 229 })); 230 } 231 }); 232 233 openMobileMenu(); 234 235 mobileMenu.on('click', (function(e) { 236 if (e.target !== this) { 237 return; 238 } 239 else { 240 closeMobileMenu(); 241 } 242 })); 243 244 } 245 else { 246 openMobileMenu(); 247 } 248 249 }); 250 251 function openMobileMenu() { 252 $('.mobileMenu').fadeIn(200, function() { 253 $('.mobileMenuContainer').animate({left: '0'}, 200); 254 }); 255 } 256 function closeMobileMenu() { 257 $('.mobileMenuContainer').animate({left: '-400px'}, 200, function() { 258 $('.mobileMenu').fadeOut(200); 259 }); 260 } 261 262 $('.btnSearch').on('click',function() { 263 searchForm.slideToggle(function() { 264 searchForm.find('input[type="text"]').focus(); 265 }); 266 }); 267 268 } 269 else { // desktop 270 271 272 // transform productmenu 273 var maxColumnItems = 15; 274 var maxColumnItemsBrands = 20; 275 if (window.innerWidth < 1200) { 276 maxColumnItemsBrands = 30; 277 } 278 $('#ProductMenu_List').children('li.has-dropdown').each(function () { 279 280 var li = $(this); 281 var ul = li.children('ul'); 282 var url = li.children('a:not(#ActiveCategory_A)').attr('href'); 283 284 var timer; 285 li.on('mouseenter', function(){ 286 timer = setTimeout(function () { 287 li.addClass('hover'); 288 }, 200); 289 }); 290 li.on('mouseleave', function(){ 291 clearTimeout(timer); 292 li.removeClass('hover'); 293 }); 294 295 //if (ul.find('.SubCategory2_Productmenu').length) { 296 if (li.children('a').last().attr('href').indexOf('401s1') !== -1) { 297 li.addClass('megaMenu');
298 var megaMenuContainer = $('<div class="megaMenuContainer"></div>'); 299 li.append(megaMenuContainer); 300 megaMenuContainer.append(ul); 301 302 if (typeof productmenuBanners !== 'undefined') { 303 304 for(var i=0;i<productmenuBanners.length;i++){ 305 if (url.indexOf(productmenuBanners[i].categoryUrl) !== -1) { 306 ul.prepend('<li class="productMenuBanner"><a href="' + productmenuBanners[i].pageUrl + '"><img src="' + productmenuBanners[i].imageUrl + '" /></a></li>'); 307 } 308 } 309 310 } 311 312 } 313 else { 314 var div = $('<div></div>'); 315 ul.children('li').each(function () { 316 $(this).find('a:not(#ActiveCategory_A)').first().appendTo(div); 317 }); 318 ul.replaceWith(div); 319 320 321 if (li.children('a').last().attr('href').indexOf('-397s1') !== -1) { // brands 322 323 function asc_sort(a, b){ 324 return ($(b).text()) < ($(a).text()) ? 1 : -1; 325 } 326 div.children('a').sort(asc_sort).appendTo(div); 327 328 li.addClass('fullwidth').addClass('brandsLi'); 329 330 331 let letter = ''; 332 div.children('a').each(function() { 333 let a = $(this); 334 let subatext = a.text(); 335 let firstletter = subatext.charAt(0).toLowerCase(); 336 if (firstletter !== letter) { 337 letter = firstletter; 338 a.before('<strong class="letter">'+letter+'</strong>'); 339 } 340 }); 341 342 } 343 else { 344 li.addClass('autoColumns'); 345 } 346 } 347 348 349 }); 350 351 $('#ProductMenu_List').children('.autoColumns').each(function() { 352 var maxItems = maxColumnItems; 353 if ($(this).hasClass('brandsLi')) { 354 maxItems = maxColumnItemsBrands; 355 } 356 var NumberOfItems = parseInt($(this).find("div:first a").length); 357 var NumberOfCols = Math.ceil(NumberOfItems / maxItems); 358 var NumberOfItemsInCols = Math.ceil(NumberOfItems / NumberOfCols); 359 for (i = 1; i < NumberOfCols + 1; i++) { 360 $(this).find("div:first").append('<div class="AllCols ColNo' + i + '"></div>'); 361 var OverflowItem = (($(this).find("div:first .AllCols a").length + NumberOfItemsInCols) - NumberOfItems); 362 if (OverflowItem > 0) { 363 NumberOfItemsInCols = NumberOfItemsInCols - OverflowItem; 364 } 365 $(this).find(".ColNo" + i).html($(this).find("div:first a").slice(0, NumberOfItemsInCols)); 366 } 367 }); 368 369 $('#ProductMenu_List').prepend('<li class="home"><a href="/shop/frontpage.html"><img alt="Hjem" width="24" height="24" src="/images/skins/Bewise/images/icon-home.svg"></a></li>'); 370 371 372 373 /* 374 var sticky = new Waypoint.Sticky({ 375 element: $('#ProductmenuContainer_DIV')[0] 376 }); 377 */ 378 379 380 if (productsCount > 0 && !$('body').hasClass('webshop-checkout') && !$('body').hasClass('webshop-orderstep4')) { 381 382 $.get('/shop/ajaxwrapper.asp?fc=getsessionvaluesJSON').success(function(data){ 383 384 var info = data; 385 386 var basketData = data.basket; 387 var vatDecimal = (info.vatPercentage / 100) + 1; 388 var miniBasketItems = $('<div class="items"></div>'); 389 basketData.forEach(function(item){ 390 var key = item.index; 391 392 var imageSrc = item.productImageUrl, replacement = '-t.'; 393 imageSrc = imageSrc.replace(/.([^.]*)$/,replacement+'$1'); 394 var productItem = $('<div class="item"><div class="image"></div><div class="info"><a href="/shop/default.asp?productid=' + item.productNumber + '">' + item.productName + '</a><small>' + item.productNumber + '</small></div><div class="price">' + (item.totalPrice * vatDecimal).numberFormat(2) + ' ' + currency + '</div></div>'); 395 if (imageSrc !== '') { 396 productItem.find('.image').append('<img src="' + imageSrc + '">'); 397 } 398 399 if (item.totalPrice > 0) { 400 productItem.append('<a href="/shop/basket.asp?caller=showbasket&remove=1&keyid=' + key + '"><img src="/images/skins/Bewise/images/icon-delete.svg"></a>'); 401 } 402 403 miniBasketItems.append(productItem); 404 405 }); 406 407 408 409 $('.miniBasket').addClass('active').prepend(miniBasketItems); 410 411 $('.miniBasket .item a[href*="remove"]').each(function() { 412 var a = $(this); 413 a.on('click',function() { 414 $.get(a.attr('href'),function() { 415 location.reload(); 416 });
417 418 return false; 419 }) 420 }); 421 422 }); 423 424 } 425 426 } 427 428 if (getCookie('DDCookiePolicyDialog') == 'hide') { 429 transformProductlist(); 430 } 431 432 433 if (AddedToBasketMessageTriggered || getCookie('AddedToBasketMessageTriggered') !== '') { 434 $.getScript('/images/skins/Bewise/js/advancedpopup.v3.js'); 435 } 436 437//}); 438 439function transformArticles() { 440 //console.log('run'); 441 var hasArticles = false; 442 443 $('[data-type*="type"]:not(.transformed):not(.cardArticle)').each(function() { 444 var article = $(this); 445 article.addClass('transformed'); 446 hasArticles = true; 447 var type = article.attr('data-type'); 448 var url = article.find('a').eq(0).attr('href'); 449 var articleName = article.find('.text h3').eq(0).text(); 450 var image1Src = article.attr('data-image'); 451 var image1SrcLarge = article.attr('data-image'); 452 if ($(window).outerWidth() > 880) { 453 image1SrcLarge = article.attr('data-image').replace('-t.','.'); 454 } 455 456 457 var image1Container = article.find('.image1'); 458 var image1 = image1Container.find('img'); 459 var textContainer = article.find('.text'); 460 var image1Alt = image1.attr('alt'); 461 462 if (image1Alt !== '' && image1Alt !== articleName) { 463 464 var imageTitleContainer = '<a href="' + url + '" class="imageTitle">' + image1Alt + '</a>'; 465 //console.log(article.closest('form').find('[name="ProductID"]').val()); 466 if (type == 'type1') { 467 textContainer.append(imageTitleContainer) 468 } 469 else if (type == 'type2') { 470 textContainer.append(imageTitleContainer) 471 } 472 else if (type == 'type3') { 473 textContainer.append(imageTitleContainer); 474 console.log('3'); 475 } 476 else if (type == 'type4') { 477 image1Container.append(imageTitleContainer); 478 } 479 else if (type == 'type5') { 480 textContainer.append(imageTitleContainer) 481 } 482 else if (type == 'type6') { 483 article.append(imageTitleContainer); 484 } 485 486 } 487 488 489 if (image1Src !== '') { 490 article.find('.image1 img').attr('src',image1SrcLarge); 491 } 492 493 var image1Container = article.find('.image1'); 494 var textContainer = article.find('.text'); 495 496 // type 2 497 if (type == 'type2') { 498 article.append(textContainer,image1Container); 499 } 500 501 // type 6 502 if (type == 'type6') { 503 504 article.parallax({imageSrc: image1SrcLarge}); 505 506 } 507 508 }); 509 510 if (hasArticles) { 511 $('#ProductFilter-Container,#btn-filter').remove(); 512 } 513 514} 515function loadStockNotification(id) { 516 $.get('/shop/default.asp?productid='+id,function(response) { 517 518 // remove existing 519 $('.StockEmailNotificationWrapper, [aria-describedby*="StockEmailNotificationDialog_Container"]').remove(); 520 521 // add new 522 $('.productcard .buy').before($(response).find('.StockEmailNotificationWrapper')); 523 let url = $('#stock-notification-captcha-script').attr('data-src'); 524 525 if (typeof grecaptcha == 'undefined') { 526 $.getScript(url); 527 } 528 }); 529} 530function loadBestPrice(id) { 531 //console.log(id); 532 533 $.get('/images/skins/Bewise/API/Product/getCheapestVariant.asp?masterId=' + id, function(data) { 534 //console.log(data); 535 536 var product = data; 537 //console.log(product); 538 var variants = product.items; 539 var masterId = ''; 540 var masterPrice = 0; 541 var variantPrices = []; 542 543 for(var v=0;v<variants.length;v++){ 544 //console.log(variants[v]); 545 546 var priceObject = variants[v].prices.items[0]; 547 548 if (variants[v].isVariantMaster) { 549 masterId = variants[v].number; 550 masterPrice = priceObject.unitPrice; 551 if (priceObject.specialOfferPeriodId !== undefined && (priceObject.specialOfferPeriodId == 'Boardfy' || priceObject.specialOfferPeriodId == 'P1')) { 552 masterPrice = priceObject.specialOfferPrice; 553 } 554 //console.log(variants[v]); 555 } 556 else if (variants[v].stockCount > 0 && variants[v].settings.items[0].isHidden == false) { 557 558 var variantPrice = variantPrice = priceObject.unitPrice; 559 560 if (priceObject.specialOfferPeriodId !== undefined && (priceObject.specialOfferPeriodId == 'Boardfy' || priceObject.specialOfferPeriodId == 'P1')) { 561 variantPrice = priceObject.specialOfferPrice; 562 } 563 564 565 variantPrices.push(variantPrice); 566 567 } 568 569 570 571 } 572 573 if (variantPrices.length && masterId !== '') { 574 575 variantPrices.sort(); 576 var bestPrice = variantPrices[0]; 577 var worstPrice = $(variantPrices).get(-1); 578; 579 580 if (worstPrice > masterPrice) { 581 $('[name="ProductID"][value="' + masterId + '"]').closest('li').find('.price').html(texts.priceFrom + bestPrice.numberFormat(2) + ' DKK'); 582 } 583 584 } 585 586 587 588 589 590 });
591 592} 593function transformProductlist() { 594 595 let catdesctd = $('.category-description td.CmsPageStyle'); 596 if (catdesctd.length) { 597 let categorydescription = $.trim($('.category-description .CmsPageStyle').text()); 598 if (categorydescription == '') { 599 catdesctd.closest('.category-description').remove(); 600 } 601 } 602 603 604 605 $('li .product:not(.transformed)').each(function() { 606 607 608 var product = $(this); 609 product.addClass('transformed'); 610 var url = product.find('a').eq(0).attr('href'); 611 var id = product.closest('li').find('[name="ProductID"]').val(); 612 var hasVariants = false; 613 614 /* 615 var buyButtonText = 'Læg i kurven'; 616 //var newBuyButton = $('<input class="buyAble" type="submit" value="' + buyButtonText + '" />'); 617 var newBuyButton = $('<a href="' + url + '">' + texts.selectVariantText + '</a>'); 618 if (product.find('input[type="image"]').length) { 619 product.find('input[type="image"]').replaceWith(newBuyButton); 620 621 } 622 else if (product.find('.buy a').length) { 623 product.find('.buy a').html(texts.selectVariantText); 624 } 625 */ 626 627 /* 628 var strikePriceContainer = product.find('.price strike'); 629 630 if (strikePriceContainer.length) { 631 632 // add dynamic discount badge 633 if (!product.find('.Element_Overlay').length) { 634 var beforePrice = parseFloat($.trim(strikePriceContainer.text().replace('.','').replace(',','.'))); 635 var priceContainerClone = product.find('.price').clone(); 636 priceContainerClone.children().remove(); 637 var unitPrice = parseFloat($.trim(priceContainerClone.text().replace('.','').replace(',','.'))); 638 639 if (!isNaN(beforePrice) && !isNaN(unitPrice)) { 640 if (beforePrice > unitPrice) { 641 var discountPercent = Math.round(( (beforePrice - unitPrice) / beforePrice ) * 100); 642 if (discountPercent > 0) { 643 var offerBadge = '<div class="Element_Overlay_ProdList_SavingsContainer_DIV"><div class="Element_Overlay_ProdList_SavingsText_DIV">-' + discountPercent + '%</div></div>'; 644 product.find('.image').append(offerBadge); 645 } 646 } 647 } 648 } 649 650 var strikePriceText = $.trim(strikePriceContainer.text()); 651 strikePriceContainer.html(strikePriceText); 652 product.find('.price').addClass('offer'); 653 } 654 */ 655 656 657 658 659 // variants 660 661 product.find('select').each(function() { 662 //$(this).hide(); 663 var str = ''; 664 var counts = this.options.length; 665 var opts = []; 666 var added = []; 667 668 for(var i = 0; i < counts; i++) { 669 if(!this.options[i].text) continue; 670 671 var colorData = this.options[i].text/* .split(' - ')[0] */; 672 var sizeData = this.options[i].text/* .split(' - ')[1] */; 673 674 opts.push({"value" : this.options[i].value, "text" : sizeData, "color": colorData}); 675 } 676 677 for(var i = 0; i < opts.length ; i++) { 678 if(added.indexOf(opts[i].text) == -1) { 679 str += '<a data-color="' + opts[i].color + '" href="' + opts[i].value + '">' + opts[i].text + '</a>' + (i != opts.length-1 ? '' : ''); 680 added.push(opts[i].text); 681 } 682 } 683
684 var advancedContainer = $('<div class="advanced"><b>Varianter</b>' + str + '</div>'); 685 686 if(counts > 1) { 687 $(this).before(advancedContainer); 688 hasVariants = true; 689 } 690 691 692 }); 693 694 695 if (hasVariants && id !== undefined && id !== '') { 696 697 var productInview = new Waypoint.Inview({ 698 element: product, 699 enter: function() { 700 if (!product.hasClass('bestpriceloaded')) { 701 product.addClass('bestpriceloaded'); 702 loadBestPrice(id); 703 } 704 } 705 }); 706 707 } 708 709 710 }); 711 712} 713 714 715AddFavorite = function(id,count){ 716 var form = 'ProductID='+id+'&amount='+count+'&AddProduct=1&ShowAjaxResponse=1'; 717 718 if($('body').hasClass("webshop-productinfo")) { 719 var prodElement = $('.productcard'); 720 if(prodElement != undefined){ 721 prodElement.find('.FavAddButton_ProductInfo').attr('src',checkFavoriteUrl); 722 } 723 }else{ 724 var prodElement = $('#productlistBuyForm'+id); 725 if(prodElement != undefined){ 726 prodElement.find('.FavAddButton_Productlist').attr('src',checkFavoriteUrl); 727 } 728 } 729 730 $.post('/shop/Favorites.asp',form).done(function(data){ 731 UpdateFavoritesCount(); 732 }); 733} 734function UpdateFavoritesCount(){ 735 736 $.get('/shop/ajaxwrapper.asp?fc=getsessionvaluesJSON').success(function(data){ 737 738 739 var favoritesCount = 0; 740 741 if (data.customerLoggedIn) { 742 $.get('/shop/favorites.html?rawxml=1', function (xml) { 743 $(xml).find('Product').each(function () { 744 745 if($('body').hasClass("webshop-productinfo")) { 746 var number = $(this).find('ProductNumber').text(); 747 var prodElement = $('[name=ProductID][value="'+number+'"]'); 748 if(prodElement != undefined) { 749 prodElement.parent().find('.FavAddButton_ProductInfo').attr('src',checkFavoriteUrl); 750 } 751 }else{ 752 var id = $(this).find('ProductID').text(); 753 var prodElement = $('#productlistBuyForm'+id); 754 if(prodElement != undefined){ 755 prodElement.find('.FavAddButton_Productlist').attr('src',checkFavoriteUrl); 756 } 757 } 758 759 favoritesCount += 1; 760 }); 761 setFavoritesCount(favoritesCount); 762 }); 763 } 764 else { 765 //var favorites = $.cookie('DanDomainWebShop5Favorites'); 766 var favorites = getCookie('DanDomainWebShop5Favorites'); 767 if(favorites !== '') { 768 var favoritesCookie = decodeURIComponent(favorites); 769 var ids = favoritesCookie.split('|').filter(function(v,i){ 770 return i % 4 == 0; 771 }); 772 ids.forEach(function(id){ 773 var prodElement = $('[name="ProductID"][value="'+id+'"]'); 774 if(prodElement != undefined){ 775 776 var favoritesA = prodElement.parent().find('a[href*="AddFavorite"]'); 777 favoritesA.find('img').attr('src',checkFavoriteUrl); 778 779 780 var str = favoritesA.attr('href') 781 if (str !== undefined) { 782 783 var pos = str.indexOf("'") + 1; 784 str = str.slice(pos, str.lastIndexOf("'")); 785 favoritesA.attr('href','#AddFavorite'); 786 787 favoritesA.on('click',function(e) { 788 e.preventDefault(); 789 //console.log('/shop/favorites.html&RemProduct=1&ProductID=' + str); 790 791 $.get('/shop/favorites.html&RemProduct=1&ProductID=' + str,function() { 792 location.reload(); 793 }); 794 795 return false 796 }); 797 798 } 799 800 801 /* 802 if($('body').hasClass("webshop-productinfo")){ 803 prodElement.parent().find('.FavAddButton_ProductInfo').attr('src',checkFavoriteUrl); 804 }else{ 805 prodElement.parent().find('.FavAddButton_Productlist').attr('src',checkFavoriteUrl); 806 } 807 */ 808 } 809 }); 810 811 favoritesCount = parseInt((favoritesCookie.split('|').length-1)/4); 812 setFavoritesCount(favoritesCount); 813 } 814 } 815 816 817 }); 818 819} 820function setFavoritesCount(count) { 821 if (count > 0) { 822 $('.btnFavorites .count').html(count); 823 } 824 else { 825 $('.btnFavorites .count').empty(); 826 } 827} 828function heyloyaltyNewsletterSignup(signupForm) { 829 var form = $(signupForm); 830 if (!form.find('[name="_token"]').length) { 831 form.prepend('<input type="hidden" name="_token" value="' + newsletterConfig.heyLoyaltyToken + '">'); 832 } 833 $.ajax({
834 url: newsletterConfig.heyLoyaltyUrl, 835 type: 'post', 836 crossdomain: true, 837 data: form.serialize() 838 }); 839 form.html(newsletterConfig.thankyoutext); 840 createCookie('newsletterDone','1'); 841} 842function newsletterSignup(signupForm) { 843 var form = $(signupForm); 844 $.ajax({ 845 url: '/images/skins/Bewise/mailchimpv3.asp', 846 type: "GET", 847 data: {'list' : newsletterConfig.mailChimpList, 'email' : form.find('input[type="email"]').val(),'fname' : form.find('input[name="fname"]').val(),'lname' : ''}, 848 complete: function() { 849 form.html(newsletterConfig.thankyoutext); 850 createCookie('newsletterDone','1'); 851 } 852 }); 853} 854 855function loadProducts(url,title,appendto,slider,random) { 856 857 $.ajax({ 858 type: "GET", 859 url: url, 860 success: function(response) { 861 var ul = $('<ul class="autoRelatedUl"></ul>'); 862 863 var li; 864 if (appendto.hasClass('buyPopup')) { 865 li = $(response).find('.Related_Custom_UL > li'); 866 867 } 868 else { 869 li = $(response).find('.ProductList_Custom_UL > li:nth-child(-n+25)'); 870 } 871 872 873 if (li.length) { 874 875 876 li.each(function() { 877 var thisLi = $(this); 878 thisLi.find('[name="BuyReturnUrl"]').val(CurrencyReturnUrl); 879 880 //var stockCount = parseFloat($.trim(thisLi.find('.stock').text())); 881 //var variantButton = thisLi.find('img[src*="variant"]'); 882 //if (variantButton.length < 1 && stockCount > 0) { 883 884 ul.append(thisLi); 885 //} 886 }); 887 888 //ul.append(li); 889 890 891 892 if (random) { 893 ul.randomize('li'); 894 } 895 896 /* 897 insertSlider(ul,title,insertAfter); 898 */ 899 900 if (title !== '') { 901 appendto.append('<div class="autoRelatedHeader">' + title + '</div>'); 902 } 903 904 appendto.append(ul).addClass('active'); 905 906 907 transformProductlist(); 908 //setImageSize(); 909 910 if (slider) { 911 ul.slick({ 912 infinite: true, 913 slidesToShow: 4, 914 slidesToScroll: 1, 915 autoplay: false, 916 autoplaySpeed: 4000, 917 arrows:true, 918 prevArrow: '<i class="fa fa-chevron-left slick-prev"></i>', 919 nextArrow: '<i class="fa fa-chevron-right slick-next"></i>', 920 responsive: [ 921 { 922 breakpoint: 800, 923 settings: { 924 slidesToShow: 3, 925 slidesToScroll: 2, 926 variableWidth: false 927 } 928 }, 929 { 930 breakpoint: 600, 931 settings: { 932 slidesToShow: 2, 933 slidesToScroll: 2, 934 variableWidth: false 935 } 936 } 937 ] 938 }); 939 } 940 else { 941 ul.addClass('noSlick'); 942 } 943 } 944 945 } 946 }); 947} 948(function($) { 949 $.fn.randomize = function(childElem) { 950 return this.each(function() { 951 var $this = $(this); 952 var elems = $this.children(childElem); 953 954 elems.sort(function() { return (Math.round(Math.random())-0.5); }); 955 956 $this.detach(childElem); 957 958 for(var i=0; i < elems.length; i++) 959 $this.append(elems[i]); 960 961 }); 962 } 963})(jQuery); 964function loadBlogItems(container,catid,amount) { 965 966 $.get('/shop/AjaxWrapper.asp?FC=changesortorder&SortField=Default',function() { 967 $.get('/shop/blog-513c1.html',function(data) { 968 $('.blogFrontpage').append($(data).find('.ProductList_Custom_DIV > div:nth-child(-n+2)')); 969 transformArticles(); 970 }); 971 }); 972 973} 974function orderByCreatedDateDesc(a, b) { 975 return (b.info.createdDate > a.info.createdDate) ? 1 : -1; 976} 977function orderByCreatedDate(a, b) { 978 return (b.info.createdDate < a.info.createdDate) ? 1 : -1; 979} 980function formatDate(date) { 981 var monthNames = [ 982 "Januar", "Februar", "Marts", 983 "April", "Maj", "Juni", "Juli", 984 "August", "Septemper", "Oktober", 985 "November", "December" 986 ]; 987 988 var day = date.getDate(); 989 var monthIndex = date.getMonth(); 990 var year = date.getFullYear(); 991 992 return day + '. ' + monthNames[monthIndex] + ' ' + year; 993} 994function padStr(n, width, z) { 995 z = z || '0'; 996 n = n + ''; 997 return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n; 998} 999function setTimeToNextDelivery(day, daysOffset) { 1000 var date = new Date(); 1001 if (!day) { 1002 day = date.getDay(); 1003 } 1004 day = day % 7; 1005 1006 if (!daysOffset) { 1007 daysOffset = 0; 1008 } 1009 1010 if (!closingHours[day]) { 1011 return setTimeToNextDelivery(day + 1, daysOffset + 1); 1012 } 1013 1014 var timePieces = closingHours[day].split(":"); 1015 if (!daysOffset && date.getHours() > timePieces[0]) { 1016 return setTimeToNextDelivery(day + 1, daysOffset + 1); 1017 } else if (!daysOffset && date.getHours() == timePieces[0] && date.getMinutes() > timePieces[1]) { 1018 return setTimeToNextDelivery(day + 1, daysOffset + 1); 1019 } else if (!daysOffset && date.getHours() == timePieces[0] && date.getMinutes() == timePieces[1] && date.getSeconds() > 0) { 1020 return setTimeToNextDelivery(day + 1, daysOffset + 1); 1021 } 1022 1023 hours = timePieces[0] - date.getHours(); 1024 if (date.getMinutes() > timePieces[1]) { 1025 hours--; 1026 } 1027 hours += daysOffset * 24; 1028 if (timePieces[1] >= date.getMinutes()) { 1029 minutes = Math.abs(date.getMinutes() - timePieces[1]); 1030 } else { 1031 minutes = 60 - Math.abs(date.getMinutes() - timePieces[1]); 1032 } 1033 seconds = 0; 1034 if (date.getSeconds() > 0) { 1035 if (minutes == 0) { 1036 if (hours != 0) { 1037 hours = hours - 1; 1038 minutes = 59; 1039 seconds = 59; 1040 } 1041 } else { 1042 minutes--; 1043 } 1044 1045 seconds = 60 - date.getSeconds(); 1046 } 1047} 1048function updateCountdown() { 1049 if (seconds == 0) { 1050 if (minutes == 0) { 1051 if (hours != 0) { 1052 hours = hours - 1; 1053 minutes = 59; 1054 seconds = 59; 1055 } 1056 } else { 1057 seconds = 59; 1058 minutes = minutes - 1 1059 } 1060 } else { 1061 seconds = seconds - 1; 1062 } 1063 1064 $(".shippingtime").html('<span>' + padStr(hours, 2) + ' timer</span><span>' + padStr(minutes, 2) + ' minutter</span><span>' + padStr(seconds, 2) + ' sekunder</span>'); 1065 1066} 1067function initCountdown() {
1068 var countdownContainer = $('<div class="countdown"><img src="/images/skins/Bewise/images/icon-delivery-white.svg"><div><p>Vi sender din pakke om:</p><div class="shippingtime"></div></div></div>'); 1069 1070 $('.productcard .info').prepend(countdownContainer); 1071 1072 setTimeToNextDelivery(); 1073 updateCountdown(); 1074 setInterval("updateCountdown()", 1000); 1075} 1076function updateVariantProductData(select) { 1077 var product = $(select).closest('div[data-id]'); 1078 var optionSelected = $('option:selected', select); 1079 product.attr('data-id',optionSelected.data().vnumber); 1080 product.find('.image img').attr('src',optionSelected.data().vimage); 1081 product.find('.name strong').html(optionSelected.data().vname); 1082 product.find('.extraInfo').html(optionSelected.data().vinfo); 1083 $(select).addClass('chosen'); 1084} 1085function initTrustpilot() { 1086 if (getCookie('DDCookiePolicyDialog') == 'hide' && !$('[src*="widget.trustpilot.com"]').length) { 1087 var w = document.createElement("script"); 1088 w.type = "text/javascript"; 1089 w.src = "//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js"; 1090 w.async = true; 1091 document.head.appendChild(w); 1092 } 1093} 1094function sleekReverseDate(sleekDateString) { 1095 var sleekDateParts = sleekDateString.split('-'); 1096 return sleekDateParts[2] + '-' + sleekDateParts[1] + '-' + sleekDateParts[0]; 1097} 1098function reverseDate(dateString) { 1099 var dateParts = dateString.split('-'); 1100 return dateParts[2] + '-' + dateParts[1] + '-' + dateParts[0]; 1101} 1102 1103if (ProductNumber == '') { 1104 if (ismobile) { 1105 var footerTrustpilotInviewLoaded = false; 1106 var footerTrustpilotInview = new Waypoint.Inview({ 1107 element: $('footer')[0], 1108 enter: function() { 1109 if (!footerTrustpilotInviewLoaded) { 1110 footerTrustpilotInviewLoaded = true; 1111 1112 $('header .trustpilot').remove(); 1113 initTrustpilot(); 1114 } 1115 } 1116 }); 1117 } 1118 else { 1119 initTrustpilot(); 1120 } 1121 1122} 1123function initFit(fit,element) {
1124 var fitContainer = $('<div class="fitContainer"><strong>Hvordan er størrelsen?</strong><div class="fitBar"><span><small>lille</small></span><span></span><span><small>normal</small></span><span></span><span><small>stor</small></span></div></div>'); 1125 fitContainer.find('.fitBar').children('span').eq(fit-1).addClass('active'); 1126 element.after(fitContainer); 1127} 1128function addExtraProductsToBasket(button,reload) { 1129 1130 button.prop('disabled',true); 1131 1132 var hasBulkActive = false; 1133 1134 var productsString = ''; 1135 var quantityString = ''; 1136 1137 var showVariantMessage = false; 1138 1139 $('.extraProductsContainer input:checked').each(function() { 1140 1141 if ($(this).closest('.extraProduct').find('select:not(.chosen)').length) { 1142 showVariantMessage = true; 1143 } 1144 1145 productsString += $(this).closest('.extraProduct').attr('data-id') + '|'; 1146 quantityString += '1|'; 1147 1148 hasBulkActive = true; 1149 1150 }); 1151 1152 1153 if (hasBulkActive) { 1154 1155 if (showVariantMessage) { 1156 button.prop('disabled',false); 1157 alert('Du skal vælge variant'); 1158 } 1159 else { 1160 button.prop('disabled',true); 1161 productsString = productsString.slice(0,-1); 1162 quantityString = quantityString.slice(0,-1); 1163 1164 var addToBasketUrl = '/shop/showbasket.html?AddMultiple=1&ProductID=' + productsString + '&Amount=' + quantityString; 1165 1166 $.get(addToBasketUrl,function() { 1167 if (!$('.hasadvancedvariants').length) { 1168 $('#BUYSECTION input[type="submit"]').closest('form').submit(); 1169 } 1170 else if (reload !== undefined && reload == true) { 1171 createCookie('AddedToBasketMessageTriggered','true'); 1172 location.reload(); 1173 1174 } 1175 1176 1177 }); 1178 1179 } 1180 1181 } 1182 else { 1183 if (reload !== undefined && reload == true) { 1184 createCookie('AddedToBasketMessageTriggered','true'); 1185 location.reload(); 1186 } 1187 else { 1188 $('#BUYSECTION input[type="submit"]').closest('form').submit(); 1189 } 1190 1191 } 1192} 1193
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.