/*! * Start Bootstrap - Freelancer v7.0.7 (https://startbootstrap.com/theme/freelancer) * Copyright 2013-2023 Start Bootstrap * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-freelancer/blob/master/LICENSE) */ // // Scripts // window.addEventListener('DOMContentLoaded', event => { // Navbar shrink function var navbarShrink = function () { const navbarCollapsible = document.body.querySelector('#mainNav'); if (!navbarCollapsible) { return; } if (window.scrollY === 0) { navbarCollapsible.classList.remove('navbar-shrink') } else { navbarCollapsible.classList.add('navbar-shrink') } }; // Shrink the navbar navbarShrink(); // Shrink the navbar when page is scrolled document.addEventListener('scroll', navbarShrink); // Activate Bootstrap scrollspy on the main nav element const mainNav = document.body.querySelector('#mainNav'); if (mainNav) { new bootstrap.ScrollSpy(document.body, { target: '#mainNav', rootMargin: '0px 0px -40%', }); }; // Collapse responsive navbar when toggler is visible const navbarToggler = document.body.querySelector('.navbar-toggler'); const responsiveNavItems = [].slice.call( document.querySelectorAll('#navbarResponsive .nav-link') ); responsiveNavItems.map(function (responsiveNavItem) { responsiveNavItem.addEventListener('click', () => { if (window.getComputedStyle(navbarToggler).display !== 'none') { navbarToggler.click(); } }); }); }); // $(document).ready(function () { // $('#screenshotbtn').on('click', function () { // const url = '/api/take-screenshot/'; // $.ajax({ // url: url, // type: 'POST', // data: {}, // no data to send // contentType: 'application/json', // dataType: 'json', // expect JSON response // success: function (res) { // if (res.image_url && res.image_url.includes('walmart')) { // $("#crop_container1 img").attr("src", res.image_url + '?t=' + new Date().getTime()); // } else if (res.image_url && res.image_url.includes('amazon')) { // $("#crop_container2 img").attr("src", res.image_url + '?t=' + new Date().getTime()); // } else if (res.image_url && res.image_url.includes('target')) { // $("#crop_container3 img").attr("src", res.image_url + '?t=' + new Date().getTime()); // } else if (res.image_url && res.image_url.includes('bestbuy')) { // $("#crop_container4 img").attr("src", res.image_url + '?t=' + new Date().getTime()); // } else { // alert("No image found"); // } // }, // error: function (xhr) { // console.error("Error:", xhr.responseText); // alert("Error: " + xhr.responseText); // } // }); // }); // }); $(document).ready(function () { $('#screenshotbtn').on('click', function () { const urls = [ 'walmart', 'amazon', 'target', 'bestbuy' ]; // function to call Django API one by one function processNext(index) { if (index >= urls.length) return; // stop when done $.ajax({ url: '/api/take-screenshot/', type: 'POST', data: JSON.stringify({ site: urls[index] }), // optional if you want to send current site name contentType: 'application/json', dataType: 'json', success: function (res) { const ts = '?t=' + new Date().getTime(); if (res.image_url && res.image_url.includes('walmart')) { $("#crop_container1 img").attr("src", res.image_url + ts); } else if (res.image_url && res.image_url.includes('amazon')) { console.log("hereeeeee", res.carousel_img1) $("#crop_container2 img").attr("src", res.image_url + ts); $('#crop_container5 img').attr("src", res.image_url + ts); $('#crop_container13 img').attr("src", res.image_url + ts); $('#crop_container16 img').attr("src", res.image_url + ts); $('#crop_container19 img').attr("src", res.best_seller_img1 + ts); $('#crop_container22 img').attr("src", res.best_seller_img2 + ts); $('#upload_container1 img').eq(0).attr("src", res.carousel_img1 + ts); $('#upload_container1 img').eq(1).attr("src", res.carousel_img2 + ts); $('#upload_container1 img').eq(2).attr("src", res.carousel_img3 + ts); $('#amazonCarosalLink .editable-link').attr("href", res.carousel_link1).text(res.carousel_name1); // here the best seller content taxt should be laces in a li elements for the id amazonEditableBestSellerContent try { const bestSellers = JSON.parse(res.best_seller_content1); let listHtml = '