Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <style>
- .slider-item img {
- display: none;
- }
- .slider-item .productImage {
- background-image: url(https://adoric-fonts.s3.amazonaws.com/product_placeholder.svg);
- background-repeat: no-repeat;
- background-position: center;
- background-size: contain;
- left: 0px !important;
- right: 0px !important;
- margin: 0 auto !important;
- }
- .productImage,
- .productTitle,
- .productButton {
- left: 0px !important;
- right: 0px !important;
- margin: 0 auto !important;
- }
- .slider-item .productPrice {
- width: 50% !important;
- left: 0px !important;
- }
- .slider-item .productSalePrice {
- width: 50% !important;
- right: 0px !important;
- left: unset !important;
- }
- .slider-item .productSalePrice SPAN{
- color: rgb(0, 0, 0) !important;
- text-decoration: none !important;
- }
- </style>
- <script>
- (function() {
- var productChanel = 'https://feeds.datafeedwatch.com/59896/c413cbaf3a5fffb4186bb420db4fac1e24390f7f.json';
- function updateSlideContent(campaignSlide, sourceSlide) {
- /* productImage productTitle productButton productPrice ₪*/
- var productLink = sourceSlide.link;
- if (productLink) {
- campaignSlide.querySelector('.productButton a').href = productLink;
- }
- var productTitle = sourceSlide.title;
- if (productTitle) {
- campaignSlide.querySelector('.productTitle SPAN').textContent = productTitle;
- }
- var productImage = sourceSlide.image_link;
- if (productImage) {
- campaignSlide.querySelector('.productImage').style.setProperty('background-image', 'url(' + productImage + ')', 'important');
- }
- var productPrice = sourceSlide.price;
- var slidePriceElement = campaignSlide.querySelector('.productPrice SPAN');
- if (productPrice && slidePriceElement) {
- slidePriceElement.textContent = productPrice.replace('ILS', '') + '₪';
- }
- var productSalePrice = sourceSlide.sale_price;
- var salePriceSlideElement = campaignSlide.querySelector('.productSalePrice SPAN');
- if (productSalePrice && productSalePrice.length > 0) {
- salePriceSlideElement.textContent = productSalePrice.replace('ILS', '') + '₪';
- slidePriceElement.style.setProperty('color', 'rgb(244, 67, 54)', 'important');
- slidePriceElement.style.setProperty('text-decoration', 'line-through', 'important');
- slidePriceElement.style.setProperty('font-family', '"Open Sans Hebrew", sans-serif', 'important');
- } else {
- salePriceSlideElement.style.display = 'none';
- slidePriceElement.parentNode.style.setProperty('left', '0px', 'important');
- slidePriceElement.parentNode.style.setProperty('right', '0px', 'important');
- slidePriceElement.parentNode.style.setProperty('margin', '0 auto', 'important');
- slidePriceElement.style.setProperty('text-align', 'center', 'important');
- }
- }
- var sliderItems = document.querySelectorAll('.' + self.identifier + '.__ADORIC__ [tabindex] .slider-item');
- var sliderWrapper = document.querySelector('.' + self.identifier + '.__ADORIC__ [tabindex] .slider-content');
- try {
- var data = null;
- var xhr = new XMLHttpRequest();
- xhr.withCredentials = true;
- xhr.addEventListener('readystatechange', function() {
- if (this.readyState === 4) {
- var responseJson = JSON.parse(this.responseText);
- var pageProducts = responseJson.products;
- for (var i = 1; i < sliderItems.length; i++) {
- var pageItemIndex = i - 1;
- if (i <= pageProducts.length) {
- updateSlideContent(sliderItems[i], pageProducts[pageItemIndex]);
- } else {
- sliderWrapper.removeChild(sliderItems[i]);
- }
- if (i == sliderItems.length - 1 && pageProducts.length >= i) {
- updateSlideContent(sliderItems[0], pageProducts[i]);
- }
- }
- }
- });
- xhr.open('GET', productChanel);
- xhr.setRequestHeader('cache-control', 'no-cache');
- xhr.send(data);
- } catch (error) {
- console.log(error);
- }
- })();
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement