var ip = '18.117.152.126'; /************************************************ ************************************************* * Copyright 2021 Jason Orban, All Rights Reserved * Do not distribute or copy this code without express * Written permission from the code's creator. * Author: Jason Orban * Website: https://freshleadspro.com ************************************************* *************************************************/ console.log("REV1-3 Loaded"); console.log("version 1.3"); console.log("Written By Jason Orban"); // grab the #ID of the text paragraph that holds your custom value for your review link var urlReview = '.review_url'; var fbReview = '.fb_review_url'; var yelpReview = '.yelp_review_url'; var altReview = '.alt_review_url'; var altReviewIMG = '.alt_review_image'; var showPop = '.show_pop'; var rev_pow_by = '.rev_pow_by'; var rev_pow_by_img = '.rev_pow_by_img'; var rev_bus_logo = '.rev_bus_logo'; var rev_bus_logo_img = '.rev_bus_logo_img'; var negRevBTN = '.negRevBTN'; var locationLicense = revGetHTML(".location_id"); var locationId = revGetHTML(".location_license"); var starClicked = ""; var rsClicked = ""; var contact_id = ""; if(typeof revPage === 'undefined' || revPage === null){ var revPage = "reviews"; } const queryString = window.location.search; if(queryString){ const urlParams = new URLSearchParams(queryString); var getEmail = urlParams.get('email'); contact_id = urlParams.get('contact_id'); console.log("customer id = "+contact_id); // Check email to see if it is a gmail account. if (getEmail != null){ var isGmail = getEmail.substr(getEmail.length-9, 9); } } // grab the #ID of the text paragraph that holds your CV for your referral link (after click) var urlReferral = '.referral_url'; // add in the ID of the 4-5 Star image(s) you want to link (you can add mulitple) // Replace the Image tag in the line below with the paragraph id of your Thumbs Up // 4-5 Star image on this page. var yourImages = ['.five_star_btn']; var timedImages = ['.posBtn']; // get your form ID // Replace the form ID in the line below with the Form ID of the form on this page var yourForm = ['#form-E2N2paPFg']; // get the URL from the Pragraph text for the Review URL //var customURL = document.querySelector(urlReview + " div p").innerHTML; var customURL = ""; var numReviewLinks = ""; var customURLRef = ""; var reviewLinks = new Object; // get the URL from the Paragraph text for the Referral URL if(domainURL != "") { customURLRef = domainURL+"/referral"; console.log("new Domain URL"); }else{ customURLRef = revGetHTML(urlReferral); console.log("old Domain URL"); } if(typeof googleReviewURL === 'undefined' || googleReviewURL === null){ var googleReviewURL = revGetHTML(urlReview); if(googleReviewURL == ""){ googleReviewUrl = revGetHTML('.review_url'); } } // if(typeof smartReview1 === 'undefined' || smartReview1 === null){ var smartReview1 = revGetHTML(".smart_review1"); } if(typeof smartReview2 === 'undefined' || smartReview2 === null){ var smartReview2 = revGetHTML(".smart_review2"); } if(typeof smartReview3 === 'undefined' || smartReview3 === null){ var smartReview3 = revGetHTML(".smart_review3"); } if(typeof smartOpt1 === 'undefined' || smartOpt1 === null){ var smartOpt1 = revGetHTML(".smart_opt1"); }else{ console.log("Smart Opt 1="+smartOpt1); } if(typeof smartOpt2 === 'undefined' || smartOpt2 === null){ var smartOpt2 = revGetHTML(".smart_opt2"); }else{ console.log("Smart Opt 2="+smartOpt2); } if(typeof smartOpt3 === 'undefined' || smartOpt3 === null){ var smartOpt3 = revGetHTML(".smart_opt3"); }else{ console.log("Smart Opt 3="+smartOpt3); } if(typeof usingReferrals === 'undefined' || usingReferrals === null){ var usingReferrals = revGetHTML(".usingReferrals"); } if(typeof gmailToGoogle === 'undefined' || gmailToGoogle === null){ var gmailToGoogle = revGetHTML(".gmailToGoogle"); } if(typeof domainURL === 'undefined' || domainURL === null){ var domainURL = revGetHTML('.smart_reviews_url'); } if(typeof negRevLinkText === 'undefined' || negRevLinkText === null){ var negRevLinkText = revGetHTML('.neg_rev_link'); } if(typeof fbReviewURL === 'undefined' || fbReviewURL === null){ var fbReviewURL = revGetHTML(fbReview); } if(typeof yelpReviewURL === 'undefined' || yelpReviewURL === null){ var yelpReviewURL = revGetHTML(yelpReview); } if(typeof altReviewURL === 'undefined' || altReviewURL === null){ var altReviewURL = revGetHTML(altReview); } if(typeof altReviewImgURL === 'undefined' || altReviewImgURL === null){ var altReviewImgURL = revGetHTML(altReviewIMG); } if(typeof showPopVal === 'undefined' || showPopVal === null){ var showPopVal = revGetHTML(showPop); } if(typeof rev_pow_by_val === 'undefined' || rev_pow_by_val === null){ var rev_pow_by_val = revGetHTML(rev_pow_by); } if(typeof rev_bus_logo_val === 'undefined' || rev_bus_logo_val === null){ var rev_bus_logo_val = revGetHTML(rev_bus_logo); } if(rev_pow_by_val != ""){ revLoadImage(rev_pow_by_val, rev_pow_by_img); } if(rev_bus_logo_val != ""){ revLoadImage(rev_bus_logo_val, rev_bus_logo_img); } // check to see that the review links have been populated, if they are // add them to the reviewLinks object if (googleReviewURL != "" && googleReviewURL.length > 10){ reviewLinks["google"] = googleReviewURL; } if (fbReviewURL != "" && fbReviewURL.length > 10){ reviewLinks["facebook"] = fbReviewURL; } if (yelpReviewURL != "" && yelpReviewURL.length > 10){ reviewLinks["yelp"] = yelpReviewURL; } if (altReviewURL != "" && altReviewURL.length > 10 && altReviewImgURL.length > 10){ reviewLinks["alt"] = altReviewURL; var altBTN = altReviewImgURL; } if(smartReview1 != "" && smartReview1.length > 10 && smartOpt1.length > 10){ reviewLinks["rev1"] = smartReview1; var rev1BTN = smartOpt1; } if(smartReview2 != "" && smartReview2.length > 10 && smartOpt2.length > 10){ reviewLinks["rev2"] = smartReview2; var rev2BTN = smartOpt2; } if(smartReview3 != "" && smartReview3.length > 10 && smartOpt3.length > 10){ reviewLinks["rev3"] = smartReview3; var rev3BTN = smartOpt3; } var CheckNegRevBTN = document.querySelector(negRevBTN) != null; if(negRevLinkText != "" && negRevLinkText.length > 10){ // negative review Link if(CheckNegRevBTN){ document.querySelector(negRevBTN).addEventListener("click", function(){ window.location.href = negRevLinkText; }); } }else{ if(CheckNegRevBTN){ document.querySelector(negRevBTN).style.display = "none"; if(document.querySelector(".reviewGRow") != null){ document.querySelector(".reviewGRow").style.display = "none"; } } } if(gmailToGoogle.toLowerCase() == "yes" || gmailToGoogle.toLowerCase() == "true"){ gmailToGoogle = true; } // If the custom values are set to limit if(gmailToGoogle == true && reviewLinks.google != "" && isGmail == "gmail.com") { console.log("only adding google"); addReviewLink("google",reviewLinks.google,1); }else{ // check to see how many review sites are in Custom Values var numReviewLinks = Object.keys(reviewLinks).length; //loop through the review links and send to function to populate the modal Object.keys(reviewLinks).forEach(function (item, key) { console.log(item + " = " + reviewLinks[item]); var defaultReview = "true"; if(numReviewLinks > 1 || showPopVal == 'yes'){ if (altBTN && item == 'alt'){ addReviewLink(item, reviewLinks[item], numReviewLinks, altBTN); console.log("item = "+item); document.querySelector("."+item).addEventListener("click", function(){reviewSiteClick(item)}); defaultReview = "false"; } if (rev1BTN && item == 'rev1'){ addReviewLink(item, reviewLinks[item], numReviewLinks, rev1BTN); console.log("item = "+item); console.log("img ="+ rev1BTN); document.querySelector("."+item).addEventListener("click", function(){reviewSiteClick(item)}); defaultReview = "false"; } if (rev2BTN && item == 'rev2'){ addReviewLink(item, reviewLinks[item], numReviewLinks, rev2BTN); console.log("item = "+item); document.querySelector("."+item).addEventListener("click", function(){reviewSiteClick(item)}); defaultReview = "false"; } if (rev3BTN && item == 'rev3'){ addReviewLink(item, reviewLinks[item], numReviewLinks, rev3BTN); console.log("item = "+item); document.querySelector("."+item).addEventListener("click", function(){reviewSiteClick(item)}); defaultReview = "false"; } if(defaultReview == "true"){ addReviewLink(item, reviewLinks[item], numReviewLinks); console.log("item = "+item); document.querySelector("."+item).addEventListener("click", function(){reviewSiteClick(item)}); } }else{ customURL = reviewLinks[item]; } }); } // if the page we're loading is the timed gating page - then submit the form instead of the modal. // if(revPage == "timed"){ // timedImages.forEach(k => { // document.querySelectorAll(k).forEach(star => { // star.addEventListener("click", submitForm); // // send the star rating. // }); // }); // } // if there is only one review link don't show the popup modal if (numReviewLinks == 1 && showPopVal != 'yes'){ // go through your list of image IDs and turn them into links. yourImages.forEach(k => { //console.log("forEachRun"); // get the img from the image container document.querySelectorAll(k).forEach(item =>{ console.log("item = "+item+"

"); var image = item; var anchor = document.createElement('a'); // set the url of the anchor to the cutom value's URL anchor.href = customURL; // if we are using referrals open in new tab, otherwise open in current window if(usingReferrals.toLowerCase() == "yes" || usingReferrals == ""){ // set the target of the anchor to open in a new page anchor.target = '_blank'; }else{ anchor.target = '_self'; } // insert the anchor into the image element image.parentNode.insertBefore(anchor,image); //put closing anchor tag after image. anchor.appendChild(image); }); }); // wait until the page is loaded and select the image id // yourImages.forEach(img => { // document.querySelector(img).addEventListener("click", loadPage); // }); yourImages.forEach(img => { document.querySelectorAll(img).forEach(star => { star.addEventListener("click", loadPage); }); }); }else{ // if we have more than one reviewlink show the popup modal // Get the modal var reviewModal = document.getElementById("reviewModal"); // Get the element that closes the modal var span = document.getElementsByClassName("close")[0]; // When the user clicks on (x), close the modal span.onclick = function() { reviewModal.style.display = "none"; } // When the user clicks anywhere outside of the modal, close it window.onclick = function(event) { if (event.target == reviewModal) { reviewModal.style.display = "none"; } } // Get the button that opens the modal //
var btn = document.getElementById("myBtn"); document.querySelectorAll(".five_star_btn").forEach(item =>{ item.addEventListener('click', function (){ reviewModal.style.display = "block"; }) }); // check to see if we are doing referrals or not // if we are then call loadPage if not then do nothing. if(usingReferrals.toLowerCase() == "yes" || usingReferrals == "" || usingReferrals == "true"){ document.querySelectorAll('.reviewLinkIcons').forEach(item => { item.addEventListener('click', loadPage); }); } // check to see if we are doing referrals or not // if we are then call loadPage if not then do nothing. if(usingReferrals.toLowerCase() == "no" || usingReferrals == "false"){ document.querySelectorAll('.reviewLinkIcons').forEach(item => { item.addEventListener('click', loadPage); }); } } // Fix Star CSS Issues on Mobile revAddColClass(); var checkForm = document.getElementsByName("first_name") != null; if(checkForm){ //var first_name = document.getElementsByName("first_name")[0].value; //console.log("first_name = "+first_name); }else{ console.log("Form is Missing"); } // If we're using CSS Buttons with stars as backgrounds then execute the next section of code. var btnStars = [".btnStars1",".btnStars2",".btnStars3",".btnStars4",".btnStars5"]; Object.entries(btnStars).forEach(([key, item]) => { if(document.querySelector(item) != null){ console.log(item+" and key "+ key); document.querySelector(item).addEventListener("mouseover", function(){starOver(key) }); document.querySelector(item).addEventListener("mouseleave", function(){starOut(key) }); document.querySelector(item).addEventListener("click", function(){starRating(key)}); } });