function marketDropDown() { if(document.getElementById("OwMarketSelection")){ var localeValue = document.querySelector('.dropdown-locale-value').value; var allLocales = ["ru","ar","en","fr","es","de-de","ru-ru","pt-pt","da-dk","de-ch","fr-be","nl-nl","ro-ro","sv-se","zh-hk","it-it","nb-no"]; if(!allLocales.includes(localeValue.toLowerCase())){ document.getElementById('OwMarketSelection').style.display = 'none'; }else{ document.getElementById('OwMarketSelection-trigger').innerHTML = document.getElementsByClassName('selected')[0].childNodes[1].innerHTML; if(getMarketCookieValue("MSCOMMarketCk")){ updateUrl(); optionSelected(); } else if (!hasRequiredQueryParams(window.location.href)){ var countryValue = document.querySelector('.selected').getAttribute("value"); if(hasQueryParams(window.location.href)){ var myArray = window.location.href.split("?"); var newUrl = myArray[0]+"?market="+countryValue+"&"+myArray[1]; window.location.href = newUrl; }else{ var newUrl = window.location.href+"?market="+countryValue; window.location.href = newUrl; } } document.querySelector('.dropdown-load-default').classList.remove("dropdown-load-default"); } var trigger = $('.dropdown-selector-button'); var list = $('.dropdown-unordered-list'); trigger.click(function(event) { trigger.toggleClass('active'); list.slideToggle(200); event.stopPropagation(); }); list.click(function(event) { trigger.click(); event.stopPropagation(); }); window.addEventListener("click", function(event) { if(document.querySelector('.dropdown-selector-button').classList.contains('active')){ trigger.toggleClass('active'); list.slideToggle(200); } }); } } function optionSelected(){ var selectedValue = getMarketCookieValue("MSCOMMarketCk"); document.querySelector('.selected').classList.remove("selected"); $( 'span[ value=' + selectedValue + ']' ).addClass( 'selected' ); document.getElementById('OwMarketSelection-trigger').innerHTML = document.getElementsByClassName('selected')[0].childNodes[1].innerHTML; var componentClass = ""; var componentNewClass = ""; /**Compare Chart V1*/ if(document.getElementsByClassName("compare-chart-v1").length > 0){ componentClass = ".compare-chart-v1"; componentNewClass = ".compare-chart-v1 a"; updateClcidvalue(componentClass); updateModal(componentNewClass); var productcompareUrl = document.getElementsByClassName("product-compare-url")[0].value; $.ajax({ url : updateCompareUrl(productcompareUrl), type : 'GET', data : { }, dataType:'json', success : function(data) { var myJSONLength = JSON.stringify(data.products.length); var jsonArray = []; for(var counter = 0; counter 0){ componentClass = ".buy-now-v1"; componentNewClass = ".buy-now-v1 a"; updateClcidvalue(componentClass); updateModal(componentNewClass); var buynowUrl = document.getElementsByClassName("product-buynow-url")[0].value; $.ajax({ url : updateCompareUrl(buynowUrl), type : 'GET', data : { }, dataType:'json', success : function(data) { var myJSONLength = JSON.stringify(data.products.length); var jsonArray = []; for(var counter = 0; counter 0){ var skuInfoList = result.products[0].skuInfo; if((result.locale!="ru-ru")&&(result.locale!="ru-by")){ if(!$('.dynamicfeaturehero__content .dynamicfeaturehero__staticDescription').hasClass("hide-content")){ $('.dynamicfeaturehero__content .dynamicfeaturehero__staticDescription').addClass('hide-content'); } if($('.dynamicfeaturehero__content .dynamic-data').hasClass("hide-content")){ $('.dynamicfeaturehero__content .dynamic-data').removeClass('hide-content'); } } if(skuInfoList){ for(let value of Object.values(skuInfoList)){ priceValueDFH.push(value["price"]); } } if(skuInfoList){ if(($('#feature-dynamic-price')[0].innerText.length > 0) && (priceValueDFH[0])){ $('#feature-dynamic-price')[0].innerText = dynamicDescription.replace(dynamicSkuprice, priceValueDFH[0].recurrencePrice); } if(($('.dynamicfeaturehero__content .dynamicfeaturehero__alternate-desc .dynamic-feature-hero-sku2Price')[0].value.length > 0) && (priceValueDFH[0].recurrencePrice != null)){ $('.dynamicfeaturehero__content .dynamicfeaturehero__alternate-desc .dynamic-feature-hero-sku2Price')[0].value = priceValueDFH[0].recurrencePrice; } if(result.locale=="ru-by"){ handleHide(); } } else{ handleHide(); } } }, error : function(request,error) { handleHide(); console.log("Request: "+JSON.stringify(request)); } }) } } /**Dynamic Feature */ if (document.querySelector(".dynamic-feature-component-v1")) { var dfno = $('div.dynamic-feature-component-v1').length; for(var dfCounter = 0; dfCounter 0){ jsonArray.push(JSON.stringify(data.products[0])); var currentProductId = JSON.stringify(data.products[0].id).replaceAll('"',''); if((data.locale!="ru-ru")&&(data.locale!="ru-by")){ if($('.dynamic-feature-component-v1 .'+currentProductId+' .perYearPriceCta').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .'+currentProductId+' .perYearPriceCta').removeClass('hide-content'); } if($('.dynamic-feature-component-v1 .'+currentProductId+' .link-group').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .'+currentProductId+' .link-group').removeClass('hide-content'); } } var priceValue = []; var recurrenceValue = []; var neededUserValue = ""; if($('.dynamic-feature-component.'+currentProductId+' .user-condition-enabled').length > 0){ if(getLocalUserValue() !=="novalue"){ neededUserValue = getLocalUserValue(); } else { neededUserValue = $('.dynamic-feature-component.'+currentProductId+' .override-user-text')[0].value; } } var skuInfoList = data.products[0].skuInfo; var valueChange1 = $('.dynamic-feature-component-v1 .'+currentProductId+' .c-paragraph.ow-padding-price span.c-heading.x-weight-semibold'); var netValue2 = ($('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' input.dynamic-feature-sku1Price').length > 0 && $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' input.dynamic-feature-sku1Price')[0].value.length > 0) ? $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' input.dynamic-feature-sku1Price')[0].value : 'placeholder' ; var tempNetValue = netValue2; if($('.dynamic-feature-component-v1 .'+currentProductId+' .link-group a')[0]){ var valueChange2 = $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' .link-group .c-paragraph a'); } if(skuInfoList){ for(let value of Object.values(skuInfoList)){ priceValue.push(value["price"]); recurrenceValue.push(value["recurrencePolicy"]); } } else { $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' input.dynamic-feature-sku1Price')[0].value = "placeholder"; if(valueChange2 && ((!$('.dynamic-feature-component.'+currentProductId+' .dynamicfeature-hide-yearly-price').length > 0) && (!$('.dynamic-feature-component.'+currentProductId+' .dynamicfeature-hide-monthly-price').length > 0))){ valueChange2[0].innerText = valueChange2[0].innerText.replace(tempNetValue ,"placeholder"); } checkNullDynamicFeature(); } if($('.dynamic-feature-component-v1 section.m-area-heading .dynamic-feature-component.'+currentProductId+'').hasClass("hide-content")){ $('.dynamic-feature-component-v1 section.m-area-heading .dynamic-feature-component.'+currentProductId+'').removeClass('hide-content'); } if($('.dynamic-feature-component-v1 .'+currentProductId+' .c-paragraph.ow-padding-price span.c-heading.x-weight-semibold').hasClass("hide-content")){ $('.dynamic-feature-component-v1 .'+currentProductId+' .c-paragraph.ow-padding-price span.c-heading.x-weight-semibold').removeClass('hide-content'); } if($('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' .link-group').hasClass("hide-content")){ $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' .link-group').removeClass('hide-content'); } const ctaList = $('.dynamic-feature-component.'+currentProductId+' .link-group a'); updateCTALinks(ctaList); if(priceValue[0]!=null){ if(valueChange1){ if($('.dynamic-feature-component.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length > 0 && priceValue.length > 1){ valueChange1[0].innerText = (neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice); } else if($('.dynamic-feature-component.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length > 0 && priceValue.length == 1){ valueChange1[0].innerText = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } else if ($('.dynamic-feature-component.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length == 0 && priceValue.length == 1){ if(valueChange2){ valueChange2[0].innerHTML = $('.dynamic-feature-component.'+currentProductId+' .unprocessed-yearly-text')[0].value; if(!$('.dynamic-feature-component.'+currentProductId+' .unprocessed-yearly-text')[0].value.includes("skuprice")){ valueChange2[0].innerHTML = (valueChange2[0].innerHTML + " "+(neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice)).toString(); } else { valueChange2[0].innerHTML = valueChange2[0].innerHTML.replace("skuprice" ,(neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice)).toString(); } $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' input.dynamic-feature-sku1Price')[0].value = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } } else { if(priceValue.length == 2 && $('.dynamic-feature-component.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length == 0){ valueChange1[0].innerText = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } } } } else { if(!valueChange1.hasClass("hide-content")){ valueChange1.addClass('hide-content'); } } if(priceValue[1]!=null){ if($('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' .c-paragraph a').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' .c-paragraph a').removeClass('hide-content') } if(valueChange2){ if((!$('.dynamic-feature-component.'+currentProductId+' .dynamicfeature-hide-yearly-price').length > 0) && (!$('.dynamic-feature-component.'+currentProductId+' .dynamicfeature-hide-monthly-price').length > 0)){ if($('.dynamic-feature-component.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length > 0){ valueChange2[0].innerHTML = $('.dynamic-feature-component.'+currentProductId+' .unprocessed-monthly-price')[0].value; if(!$('.dynamic-feature-component.'+currentProductId+' .unprocessed-monthly-price')[0].value.includes("skuprice")){ valueChange2[0].innerHTML = (valueChange2[0].innerHTML + " "+(neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice)).toString(); } else { valueChange2[0].innerHTML = valueChange2[0].innerHTML.replace("skuprice" ,(neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice)).toString(); } $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' input.dynamic-feature-sku1Price')[0].value = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } else { valueChange2[0].innerHTML = $('.dynamic-feature-component.'+currentProductId+' .unprocessed-yearly-text')[0].value; if(!$('.dynamic-feature-component.'+currentProductId+' .unprocessed-yearly-text')[0].value.includes("skuprice")){ valueChange2[0].innerHTML = (valueChange2[0].innerHTML + " "+(neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice)).toString(); } else { valueChange2[0].innerHTML = valueChange2[0].innerHTML.replace("skuprice" ,(neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice)).toString(); } $('.dynamic-feature-component-v1 .dynamic-feature-component.'+currentProductId+' input.dynamic-feature-sku1Price')[0].value = (neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice); } } } } else { if(valueChange2){ if(!valueChange2.hasClass("hide-content") && valueChange2.length == 0){ valueChange2.addClass('hide-content'); } } } if((data.locale=="ru-ru")||(data.locale=="ru-by")){ if(!$('.dynamic-feature-component-v1 .'+currentProductId+' .perYearPriceCta').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .'+currentProductId+' .perYearPriceCta').addClass('hide-content'); } if(!$('.dynamic-feature-component-v1 .'+currentProductId+' .link-group').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .'+currentProductId+' .link-group').addClass('hide-content'); } } } else { if(!$('.dynamic-feature-component-v1 .perYearPriceCta').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .perYearPriceCta').addClass('hide-content'); } if(!$('.dynamic-feature-component-v1 .link-group').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .link-group').addClass('hide-content'); } } }, error : function(request,error) { if(!$('.dynamic-feature-component-v1 .perYearPriceCta').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .perYearPriceCta').addClass('hide-content'); } if(!$('.dynamic-feature-component-v1 .link-group').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .link-group').addClass('hide-content'); } console.log("Request: "+JSON.stringify(request)); } }); } checkNullDynamicFeature(); } } } /**Buy Now V2*/ if (document.querySelector(".buy-now-v2")) { componentClass = ".buy-now-v2"; componentNewClass = ".buy-now-v2 a"; updateClcidvalue(componentClass); updateModal(componentNewClass); var buynowUrl = document.getElementsByClassName("product-buynow-v2-url")[0].value; if(buynowUrl){ var productsIds = buynowUrl.split("productIds=")[1].split("&")[0].split("%2C"); var productsLength = productsIds.length; for (let i = 0; i < productsLength; i++){ $('.buy-now-v2 .ContainerBuy')[i].classList.add(productsIds[i]); } var updatedValue = updateCompareUrl(buynowUrl); if(updatedValue){ $.ajax({ url : updatedValue, type : 'GET', data : { }, dataType:'json', success : function(data) { var myJSONLength = JSON.stringify(data.products.length); var jsonArray = []; for(var counter = 0; counter 0){ if(getLocalUserValue() !=="novalue"){ neededUserValue = getLocalUserValue(); } else { neededUserValue = $('.col.'+currentProductId+' .override-user-text')[0].value; } } if((data.locale!="ru-ru")&&(data.locale!="ru-by")){ if($('.content-card-v2-component .col.'+currentProductId+' .h6.sku2price').css("display") == 'none'){ $('.content-card-v2-component .col.'+currentProductId+' .h6.sku2price')[0].style.removeProperty('display'); } if($('.content-card-v2-component .col.'+currentProductId+' .link-group-container .link-group').css("display") == 'none'){ $('.content-card-v2-component .col.'+currentProductId+' .link-group-container .link-group')[0].style.removeProperty('display'); } if($('.content-card-v2-component .link-group.'+currentProductId+'').css("display") == 'none'){ $('.content-card-v2-component .link-group.'+currentProductId+'')[0].style.removeProperty('display'); } if($('.content-card-v2-component .col.'+currentProductId+' .link-group').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+currentProductId+' .link-group').removeClass('value-hidden'); } if($('.content-card-v2-component .sticky-link-group-container .link-group.'+currentProductId+' .inner').hasClass("value-hidden")){ $('.content-card-v2-component .sticky-link-group-container .link-group.'+currentProductId+' .inner').removeClass('value-hidden'); } if($('.content-card-v2-component .col.'+currentProductId+' .cc-card-flex-grow .sku2price').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+currentProductId+' .cc-card-flex-grow .sku2price').removeClass('value-hidden'); } if($('.content-card-v2-component .col.'+currentProductId+' .cc-card-flex-grow .sku1price').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+currentProductId+' .cc-card-flex-grow .sku1price').removeClass('value-hidden'); } if(!$('.content-card-v2-component .col.'+currentProductId+' .not-available-text').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+currentProductId+' .not-available-text').addClass('value-hidden'); } if($('.content-card-v2-component .col.'+currentProductId+' .link-group .sku2price').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+currentProductId+' .link-group .sku2price').removeClass('value-hidden'); } } if(data.products[counter].skuInfo !=null){ for(let value of Object.values(data.products[counter].skuInfo)){ priceValue.push(value["price"]); recurrenceValue.push(value["recurrencePolicy"]); } } var valueChange1 = $('.content-card-v2-component .'+currentProductId+' .sku2price')[0]; var valueChange2 = $('.content-card-v2-component .'+currentProductId+' .link-group .sku2price a')[0]; var valueChange3 = $('.content-card-v2-component .compare-chart-synchronized-scroll .link-group.'+currentProductId+' a')[0]; var netChange2 = ($('.content-card-v2-component .'+currentProductId+' .link-group .sku2price .compare-chart-sku1Price')[0] ? $('.content-card-v2-component .'+currentProductId+' .link-group .sku2price .compare-chart-sku1Price')[0].value : ''); if($('.content-card-v2-component .compare-chart-synchronized-scroll .link-group.'+currentProductId+' .compare-chart-sku2Price')[0]){ var netChange3 = $('.content-card-v2-component .compare-chart-synchronized-scroll .link-group.'+currentProductId+' .compare-chart-sku2Price')[0].value; } if(priceValue[0]){ if((valueChange1 != null)&&(priceValue[0].recurrencePrice != null)){ if($('.col.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length > 0 && priceValue.length > 1){ valueChange1.innerText = (neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice); } else if($('.col.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length > 0 && priceValue.length == 1){ valueChange1.innerText = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } else if ($('.col.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length == 0 && priceValue.length == 1){ if(valueChange2){ valueChange2Price = valueChange2.innerText.replace(netChange2, (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice)); valueChange2.innerText = valueChange2Price; valueChange2.setAttribute('data-bi-cn', valueChange2Price); valueChange2.setAttribute('data-bi-ecn', valueChange2Price); $('.content-card-v2-component .col.'+currentProductId+' .link-group-container .link-group .sku2price .compare-chart-sku1Price')[0].value = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } } else { if(priceValue.length == 2 && $('.col.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length == 0){ valueChange1.innerText = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } } } else if((valueChange1 != null)&&(priceValue[0].currentPrice != null)){ valueChange1.innerText = priceValue[0].currentPrice; } } else { valueChange1.innerText = ''; } if(valueChange2 && (!$('.col.'+currentProductId+' .hide-MonthlyPrice-condition-enabled').length > 0)){ var valueChange2Price = valueChange2.innerText; if($('.content-card-v2-component .link-group.'+currentProductId+'').css("display") == 'none'){ $('.content-card-v2-component .link-group.'+currentProductId+'')[0].style.removeProperty('display'); } if(priceValue[1]){ if($('.col.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length > 0){ valueChange2Price = valueChange2.innerText.replace(netChange2, (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice)); valueChange2.innerText = valueChange2Price; valueChange2.setAttribute('data-bi-cn', valueChange2Price); valueChange2.setAttribute('data-bi-ecn', valueChange2Price); $('.content-card-v2-component .col.'+currentProductId+' .link-group-container .link-group .sku2price .compare-chart-sku1Price')[0].value = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } else { valueChange2Price = valueChange2.innerText.replace(netChange2, (neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice)); valueChange2.innerText = valueChange2Price; valueChange2.setAttribute('data-bi-cn', valueChange2Price); valueChange2.setAttribute('data-bi-ecn', valueChange2Price); $('.content-card-v2-component .col.'+currentProductId+' .link-group-container .link-group .sku2price .compare-chart-sku1Price')[0].value = (neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice); } } } if(valueChange3){ var valueChange3Price = valueChange3.innerText; if(priceValue[0]){ if((valueChange3 != null)&&(priceValue[0].recurrencePrice != null)){ if($('.col.'+currentProductId+' .defaultMonthlyPrice-condition-enabled').length > 0 && priceValue.length > 1){ valueChange3Price = valueChange3.innerText.replace(netChange3, (neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice)); valueChange3.innerText = valueChange3Price; valueChange3.setAttribute('data-bi-cn', valueChange3Price); valueChange3.setAttribute('data-bi-ecn', valueChange3Price); $('.content-card-v2-component .material-backdrop.container.compare-chart-sticky-content.sticky-show-stuck .link-group.'+currentProductId+' .compare-chart-sku2Price')[0].value = (neededUserValue !=="" ? priceValue[1].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[1].recurrencePrice); } else { valueChange3Price = valueChange3.innerText.replace(netChange3, (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice)); valueChange3.innerText = valueChange3Price; valueChange3.setAttribute('data-bi-cn', valueChange3Price); valueChange3.setAttribute('data-bi-ecn', valueChange3Price); $('.content-card-v2-component .material-backdrop.container.compare-chart-sticky-content.sticky-show-stuck .link-group.'+currentProductId+' .compare-chart-sku2Price')[0].value = (neededUserValue !=="" ? priceValue[0].recurrencePrice.replace("/", " "+neededUserValue+"/") : priceValue[0].recurrencePrice); } }else if((valueChange1 != null)&&(priceValue[0].currentPrice != null)){ valueChange3Price = valueChange3.innerText.replace(netChange3, priceValue[0].currentPrice); valueChange3.innerText = valueChange3Price; valueChange3.setAttribute('data-bi-cn', valueChange3Price); valueChange3.setAttribute('data-bi-ecn', valueChange3Price); $('.content-card-v2-component .material-backdrop.container.compare-chart-sticky-content.sticky-show-stuck .link-group.'+currentProductId+' .compare-chart-sku2Price')[0].value = priceValue[0].currentPrice; } } } const ctaList = $('.comparechart .content-card-v2 .compare-chart-card .link-group a'); updateCTALinks(ctaList); if((data.locale=="ru-ru")||(data.locale=="ru-by")){ if(!$('.content-card-v2-component .col.'+currentProductId+' .link-group').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+currentProductId+' .link-group').addClass('value-hidden'); } if(!$('.content-card-v2-component .sticky-link-group-container .link-group.'+currentProductId+' .inner').hasClass("value-hidden")){ $('.content-card-v2-component .sticky-link-group-container .link-group.'+currentProductId+' .inner').addClass('value-hidden'); } if(!$('.content-card-v2-component .col.'+currentProductId+' .cc-card-flex-grow .sku2price').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+currentProductId+' .cc-card-flex-grow .sku2price').addClass('value-hidden'); } if(!$('.content-card-v2-component .col.'+currentProductId+' .cc-card-flex-grow .sku1price').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+currentProductId+' .cc-card-flex-grow .sku1price').addClass('value-hidden'); } if($('.container .content-card-v2-component .material-backdrop.container.compare-chart-sticky-content.sticky-show-stuck .compare-chart-head .hide-at-short-viewport .col').length > 0){ $('.container .content-card-v2-component .material-backdrop.container.compare-chart-sticky-content.sticky-show-stuck .compare-chart-head .hide-at-short-viewport .col').addClass('display-padding'); } } if(valueChange2 && (!$('.col.'+currentProductId+' .hide-MonthlyPrice-condition-enabled').length > 0)){ if(valueChange2Price.includes("placeholder")){ if(!$('.content-card-v2-component .col.'+currentProductId+' .link-group .sku2price').hasClass('value-hidden')){ $('.content-card-v2-component .col.'+currentProductId+' .link-group .sku2price').addClass('value-hidden'); } } } if(valueChange1){ if(valueChange1.innerText.includes("placeholder")){ if($('.content-card-v2-component .col.'+currentProductId+' .h6.sku2price')){ $('.content-card-v2-component .col.'+currentProductId+' .h6.sku2price')[0].style.display = 'none'; } } } } diffProductId = productIdArray.filter(x => !responseProductIdArray.includes(x)); if(diffProductId.length > 0){ if(!$('.content-card-v2-component .col.'+diffProductId+' .link-group').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+diffProductId+' .link-group').addClass('value-hidden'); } if(!$('.content-card-v2-component .sticky-link-group-container .link-group.'+diffProductId+' .inner').hasClass("value-hidden")){ $('.content-card-v2-component .sticky-link-group-container .link-group.'+diffProductId+' .inner').addClass('value-hidden'); } if(!$('.content-card-v2-component .col.'+diffProductId+' .cc-card-flex-grow .sku2price').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+diffProductId+' .cc-card-flex-grow .sku2price').addClass('value-hidden'); } if(!$('.content-card-v2-component .col.'+diffProductId+' .cc-card-flex-grow .sku1price').hasClass("value-hidden")){ $('.content-card-v2-component .col.'+diffProductId+' .cc-card-flex-grow .sku1price').addClass('value-hidden'); } if($('.container .content-card-v2-component .material-backdrop.container.compare-chart-sticky-content.sticky-show-stuck .compare-chart-head .hide-at-short-viewport .col').length > 0){ $('.container .content-card-v2-component .material-backdrop.container.compare-chart-sticky-content.sticky-show-stuck .compare-chart-head .hide-at-short-viewport .col').addClass('display-padding'); } } }, error : function(request,error) { for (let i = 0; i < productsLength; i++){ if($('.content-card-v2-component .not-available-text')[i]){ $('.content-card-v2-component .not-available-text')[i].classList.remove('value-hidden'); } if($('.content-card-v2-component .col .h6.sku2price')[i]){ $('.content-card-v2-component .col .h6.sku2price')[i].style.display = 'none'; } if($('.content-card-v2-component .link-group')[i]){ $('.content-card-v2-component .link-group')[i].style.display = 'none'; } if($('.content-card-v2-component div.compare-chart-synchronized-scroll .link-group')[i]){ $('.content-card-v2-component div.compare-chart-synchronized-scroll .link-group')[i].style.display = 'none'; } } console.log("Request: "+JSON.stringify(request)); } }); } } } /**Feature Component*/ if (document.querySelector(".feature")) { componentClass = ".feature"; componentNewClass = ".feature a"; updateClcidvalue(componentClass); updateModal(componentNewClass); if (document.querySelector(".feature-card")) { const ctaList = $('.feature-card .card-body .link-group a'); updateCTALinks(ctaList); } } /**Content Card Component*/ if ($('.content-card').length > 0) { componentClass = ".content-card"; componentNewClass = ".content-card a"; updateClcidvalue(componentClass); updateModal(componentNewClass); if (document.querySelector(".content-card")) { const ctaList = $('.content-card .card-footer .link-group a'); updateCTALinks(ctaList); } } } function updateModal(componentNewClass) { var modalLength = $('.modal').length; if(modalLength > 0){ var modalIds = []; for(var mcounter=0; mcounter < modalLength; mcounter++){ var modalValue = $('.modal')[mcounter].id; if(modalValue.length > 0){ var compAnchorLength = $(componentNewClass).length; if(compAnchorLength > 0){ for(var mcounter1=0; mcounter1 < compAnchorLength; mcounter1++){ if((($(componentNewClass)[mcounter1]).href).includes(modalValue)){ let componentClass = "#"+modalValue+".modal"; updateClcidvalue(componentClass); } } } } } const ctaList = $('.modal .modal-body .link-group a'); updateCTALinks(ctaList); } } function updateClcidvalue(componentClass){ var localeValue = document.querySelector('.dropdown-locale-value').value; if(localeValue=="fr"){ localeValue="fr-fr"; } else if (localeValue=="en"){ localeValue = "en-us"; } else if (localeValue=="ar"){ localeValue="ar-sa"; } else if (localeValue=="es"){ localeValue="es-us"; }else if (localeValue=="ru"){ localeValue="ru-kz"; } var clcicdValue = $("li[value="+localeValue+"]")[0].innerHTML.toString(); var selectedValue = $(".dropdown-item.selected").attr("value").toString(); var marketValue = localeValue.slice(0, -2) + selectedValue; var selectedClcicd = $("li[value="+marketValue+"]")[0].innerHTML.toString(); selectedClcicd = "clcid="+selectedClcicd; var selectedCountryValue = "country="+selectedValue; var selectedCultureValue = "culture="+localeValue; var newHref =""; var noOfCompo = $(componentClass).length; for(var compoNo=0; compoNo < noOfCompo; compoNo++){ if($(componentClass)[compoNo].getElementsByTagName('a').length > 0){ $(componentClass+" a").each(function() { if($(this).attr('href')){ var hrefValue = $(this).attr('href').toString(); var currentClcid = ((hrefValue.split('CLCID=').pop()).split('&')[1]); if((hrefValue.includes("CLCID="))||(hrefValue.includes("country=" ))||(hrefValue.includes("culture=" ))){ if (hrefValue.includes("CLCID=") || hrefValue.includes("clcid=")) { newHref = hrefValue.replace(currentClcid, selectedClcicd).toString(); } if (hrefValue.includes("country=" )) { var countryHref = newHref.split('country=').pop(); countryHref = "country="+countryHref; newHref = newHref.replace(countryHref, selectedCountryValue).toString(); } if (hrefValue.includes("culture=" )) { var cultureHref = (newHref.split('culture=').pop()).split('&')[0]; cultureHref = "culture="+cultureHref; newHref = newHref.replace(cultureHref, selectedCultureValue).toString(); } $(this).attr("href", newHref); } } }); } } } function updateCompareUrl(compareUrl){ var localValue = document.querySelector('.dropdown-locale-value').value; if(localValue=="fr"){ localValue="fr-fr"; } else if (localValue=="en"){ localValue = "en-us"; } else if (localValue=="ar"){ localValue="ar-sa"; } else if (localValue=="es"){ localValue="es-us"; }else if (localValue=="ru"){ localValue="ru-kz"; } var locale = ""; var localLength = localValue.length; if(localLength < 3){ if(getMarketCookieValue("MSCOMMarketCk")){ locale = "en-"+getMarketCookieValue("MSCOMMarketCk"); }else{ locale = "en-"+document.querySelector('.selected').getAttribute("value"); } } else { if(getMarketCookieValue("MSCOMMarketCk")){ var partLocal = localValue.substring(0, 3); locale = partLocal+getMarketCookieValue("MSCOMMarketCk"); }else{ locale = partLocal+document.querySelector('.selected').getAttribute("value"); } } var oldLocale = compareUrl.split("?")[1].split("&")[0].split("=")[1]; var newUrl = ""; if(locale === oldLocale){ newUrl = compareUrl; }else{ locale = "locale="+locale; newUrl = compareUrl.replace(compareUrl.split("?")[1].split("&")[0], locale); } if(!newUrl.includes("isM365Page=true")){ newUrl = newUrl+"&isM365Page=true"; } return newUrl; } function hasQueryParams(url) { return url.includes('?'); } function updateProductPrice(productId, price, productNumber) { document.querySelector('[href*="'+productId+'"]').parentElement.parentElement.previousElementSibling.children[1] } function updateUrl(){ var currentUrl = window.location.href; var stateObj = { id: "100" }; if(getMarketCookieValue("MSCOMMarketCk") && !hasRequiredQueryParams(currentUrl)){ if(hasQueryParams(currentUrl)){ var myArray = currentUrl.split("?"); var newUrl = myArray[0]+"?market="+getMarketCookieValue("MSCOMMarketCk")+"&"+myArray[1]; window.location.href = newUrl; }else{ var newUrl = currentUrl+"?market="+getMarketCookieValue("MSCOMMarketCk"); window.location.href = newUrl; } } else if(getMarketCookieValue("MSCOMMarketCk") && hasRequiredQueryParams(currentUrl)){ if(currentUrl.includes("&")){ var myNewArray = (currentUrl.split("?"))[1].split("&"); }else { var myNewArray = (currentUrl.split("?"))[1]; } if(getMarketCookieValue("MSCOMMarketCk") != (myNewArray[0].split("="))[1]){ var mySplitArray = currentUrl.split("market="); if(mySplitArray[1].includes("&")){ let queryParams = mySplitArray[1].split("&")?.splice(1).join("&"); var newUrl = mySplitArray[0] + "market=" + getMarketCookieValue("MSCOMMarketCk") + "&" + queryParams; } else { var newUrl = mySplitArray[0]+"market="+getMarketCookieValue("MSCOMMarketCk"); } newUrl = newUrl.replace(window.location.origin,''); window.history.pushState(stateObj, document.title, newUrl); } } } function updateCTALinks(ctaList) { const urlParams = new URLSearchParams(window.location.search); const ocid = urlParams.get('ocid'); if (ocid) { ctaList.each((i, cta) => { if (cta.href) { if (cta.href.includes('ocid=') || cta.href.includes('#')) { return; } if (cta.href.match(/\?./)) { cta.href = cta.href + '&ocid=' + ocid; } else { cta.href = cta.href + '?ocid=' + ocid; } } }); } } function hasRequiredQueryParams(url) { return url.includes('market='); } function getMarketCookieValue(name) { var dc = document.cookie; var myCookieArray = dc.split(";"); var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else { begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) { end = dc.length; } } var myCookieArray = dc.substring(begin + prefix.length, end).split(";"); return myCookieArray[0]; } function checkNullDynamicFeature(){ if(($('.dynamic-feature-sku1Price')[0].value) == "placeholder"){ if(!$('.c-paragraph .dynamic-feature-sku1Price-anchor').hasClass('hide-content')){ $('.c-paragraph .dynamic-feature-sku1Price-anchor').addClass('hide-content') } } else { if($('.dynamic-feature-component-v1 .dynamic-feature-component .c-paragraph a').hasClass('hide-content')){ $('.dynamic-feature-component-v1 .dynamic-feature-component .c-paragraph a').removeClass('hide-content') } } } function getLocalUserValue(){ var uLocalValue = document.querySelector('.dropdown-locale-value').value; if(uLocalValue=="fr"){ uLocalValue="fr-fr"; } else if (uLocalValue=="en"){ uLocalValue = "en-us"; } else if (uLocalValue=="ar"){ uLocalValue="ar-sa"; } else if (uLocalValue=="es"){ uLocalValue="es-us"; } else if (uLocalValue=="ru"){ uLocalValue="ru-kz"; } var selectedUserValue = ""; if($("li.market-user-locale-value[value="+uLocalValue+"]").length > 0){ var userLocalValue = $("li.market-user-locale-value[value="+uLocalValue+"]")[0].innerHTML.toString(); var uSelectedValue = $(".dropdown-item.selected").attr("value").toString(); var uMarketValue = uLocalValue.slice(0, -2) + uSelectedValue; selectedUserValue = $("li.market-user-locale-value[value="+uMarketValue+"]")[0].innerHTML.toString(); } else { selectedUserValue = "novalue"; } return selectedUserValue; } $(function() { marketDropDown(); var ul = document.querySelector('ul.dropdown-unordered-list'); var nodes = document.querySelectorAll('li.dropdown-no-bullets span.dropdown-item'); var selected = 0; if($('#dropdown-list').length!=0){ const targetNode = document.getElementById("dropdown-list"); const config = { attributes: true}; const callback = (mutationList, observer) => { for (const mutation of mutationList) { if (mutation.type === "attributes") { if($('#dropdown-list').attr("style") == 'display: none;'){ enableBodyScroll(); } else if($('.dropdown-selector-button')[0].classList.contains('active')) { disableBodyScroll({ savePosition: true }); } } } }; const observer = new MutationObserver(callback); observer.observe(targetNode, config); function enableBodyScroll() { if (document.readyState === 'complete') { document.body.style.position = ''; document.body.style.overflowY = ''; if (document.body.style.marginTop) { const scrollTop = -parseInt(document.body.style.marginTop, 10); document.body.style.marginTop = ''; window.scrollTo(window.pageXOffset, scrollTop); } } else { window.addEventListener('load', enableBodyScroll); } } function disableBodyScroll({ savePosition = false } = {}) { if (document.readyState === 'complete') { if (document.body.scrollHeight > window.innerHeight) { if (savePosition) document.body.style.marginTop = `-${window.pageYOffset}px`; //document.body.style.position = 'fixed'; document.body.style.overflowY = 'scroll'; } } else { window.addEventListener('load', () => disableBodyScroll({ savePosition })); } } [].forEach.call(nodes, function(el) { el.addEventListener('click', function() { select(this); }) }); document.addEventListener('keydown', function(e) { if (e.keyCode === 38) { // up select(nodes[selected - 1]); } if (e.keyCode === 40) { // down select(nodes[selected + 1]); } if (e.keyCode === 13) { // enter var x = document.getElementsByClassName("dropdown-item selected")[0].attributes[0].value; document.cookie = "MSCOMMarketCk=" + x ; updateUrl(); optionSelected(); } if (e.keyCode === 32) { // space var x = document.getElementsByClassName("dropdown-item selected")[0].attributes[0].value; document.cookie = "MSCOMMarketCk=" + x ; updateUrl(); optionSelected(); } }); function select(el) { var s = [].indexOf.call(nodes, el); if (s === -1) return; selected = s; var elHeight = $(el).height(); elHeight = elHeight + 24; var scrollTop = $(ul).scrollTop(); var viewport = scrollTop + $(ul).height(); var elOffset = elHeight * selected; $(ul).scrollTop(elOffset); document.querySelector('li.dropdown-no-bullets span.dropdown-item.selected').classList.remove('selected'); el.classList.add('selected'); } } $("span.dropdown-item").click(function() { var x = this.getAttribute("value"); document.cookie = "MSCOMMarketCk=" + x ; document.querySelector('.selected').classList.remove("selected"); this.classList.add("selected"); updateUrl(); optionSelected(); }); });