Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function() {
- function updateSlideContent(sourceSlide, index) {
- var productLink = sourceSlide.querySelector('a');
- var productImage = sourceSlide.querySelector('.image img');
- var productTitle = sourceSlide.querySelector('.description');
- var productOldPrice = sourceSlide.querySelector('.oldprice');
- var productPrice = sourceSlide.querySelector('.saleprice');
- if (!productLink) {
- console.log('index - ', index);
- console.log('productLink not exit');
- }
- if (!productImage) {
- console.log('index - ', index);
- console.log('productImage not exit');
- }
- if(!productTitle) {
- console.log('index - ', index);
- console.log('productTitle not exit');
- }
- if(!productOldPrice) {
- console.log('index - ', index);
- console.log('productOldPrice not exit');
- }
- if (!productPrice) {
- console.log('index - ', index);
- console.log('productPrice not exit');
- }
- var productData = {
- productLink: productLink.href,
- productImage: window.location.origin + '/' + productImage.getAttribute('src'),
- productTitle: productTitle.textContent,
- productOldPrice: productOldPrice.textContent,
- productPrice: productPrice.textContent
- };
- products.push(productData);
- }
- var products = [];
- var pageProducts = document.querySelectorAll('.item');
- for(var i = 0; i < pageProducts.length; i++) {
- updateSlideContent(pageProducts[i], i);
- }
- products.forEach(element => {
- console.log(JSON.stringify(element));
- });
- })();
Add Comment
Please, Sign In to add comment