"); window.location.href = "/reading-worksheets/"; }, error: function(XMLHttpRequest, textStatus, errorThrown) { $( "#modalLeadPopForm" ).remove(); document.getElementById("leadPopHeading").innerHTML = errorHeading; document.getElementById("leadPopBodyText").innerHTML = errorBody; document.getElementById("leadPopListHeader").style.display = "none"; document.getElementById("leadPopList").style.display = "none"; document.getElementById("termsConditions").style.display = "none"; mrow = $('#modalLeadPopRow') } }); } function close2() { document.querySelector('.exit-intent-popup').classList.remove('visible'); document.querySelector('.exit-intent-popup').classList.add('invisible'); } // allows the use of Jekyll: liquid tag inside javascript var debug = null; var mobile = "false"; var cookie_name = "exitIntentShowLead"; var event_label = "ExitPopup-Uk-LeadGen"; var trigger_on_scroll_to_bottom = "true"; // Cookie handling object const CookieService = { setCookie(name, value, days) { let expires = ''; if (days) { const date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); expires = '; expires=' + date.toUTCString(); } document.cookie = name + '=' + (value || '') + expires + ';path=/'; }, getCookie(name) { const cookies = document.cookie.split(';'); for (const cookie of cookies) { if (cookie.indexOf(name + '=') > -1) { return cookie.split('=')[1]; } } return null; } } var scrolling=true; // Popup handler const mouseEvent = e => { const shouldShowExitIntent = !e.toElement && !e.relatedTarget && e.clientY this.scrollY && scrolling == true) { document.removeEventListener('scroll', mouseEvent); document.removeEventListener('mouseout', mouseEvent); document.querySelector('.exit-intent-popup').classList.add('visible'); document.querySelector('.exit-intent-popup').classList.remove('invisible'); scrolling=false; } this.oldScroll = this.scrollY; // Trigger popup if user scrolls above page if (shouldShowExitIntent) { document.removeEventListener('mouseout', mouseEvent); document.removeEventListener('scroll', mouseEvent); document.querySelector('.exit-intent-popup').classList.add('visible'); document.querySelector('.exit-intent-popup').classList.remove('invisible'); } // Set the cookie when the popup is shown to the user if (cookie_name) { CookieService.setCookie(cookie_name, true, 30); } else { CookieService.setCookie('exitIntentShown', true, 30); } if (trigger_on_scroll_to_bottom) { // trigger popup if user scrolls to bottom of page if ((window.innerHeight + window.pageYOffset) >= $(document).height()) { document.removeEventListener('mouseout', mouseEvent); document.removeEventListener('scroll', mouseEvent); document.querySelector('.exit-intent-popup').classList.add('visible'); document.querySelector('.exit-intent-popup').classList.remove('invisible'); } } // Trigger event tot track popup in ga window.dataLayer.push({ 'event': 'leadPopup', 'ExitBanner-Popup': { 'eventLabel': event_label, 'eventAction': 'LeadPopup-Viewed' } }); }; // Mobile handler const mobileEvent = e => { // print "false" if direction is down and "true" if up // console.log(this.oldScroll > this.scrollY); // trigger if user scrolls up if (this.oldScroll > this.scrollY) { document.removeEventListener('scroll', mobileEvent); document.querySelector('.exit-intent-popup').classList.add('visible'); document.querySelector('.exit-intent-popup').classList.remove('invisible'); } this.oldScroll = this.scrollY; // Set the cookie when the popup is shown to the user if (cookie_name) { CookieService.setCookie(cookie_name, true, 30); } else { CookieService.setCookie('exitIntentShown', true, 30); } // Trigger event tot track popup in ga window.dataLayer.push({ 'event': 'exitBannerPopup', 'ExitBanner-Popup': { 'eventLabel': event_label, 'eventAction': 'ExitPopup-Viewed' } }); }; // Popup close handler const exit = e => { const shouldExit = [...e.target.classList].includes('exit-intent-popup') || // user clicks on mask e.target.className === 'close' || // user clicks on the close icon e.keyCode === 27; // user hits escape if (shouldExit) { document.querySelector('.exit-intent-popup').classList.remove('visible'); document.querySelector('.exit-intent-popup').classList.add('invisible'); } }; if (mobile) { // only action once everything on the page has loaded window.addEventListener('load', function() { // check width of window var targetWidth = 768; if ( $(window).width() >= targetWidth) { //Add your javascript for screens wider than or equal to 768 here if (debug) { // code below is used for testing document.addEventListener('keydown', exit); document.addEventListener('mouseout', mouseEvent); // below will triggger after 10 seconds setTimeout(() => { document.addEventListener('scroll', mouseEvent); }, 10_000); } else { if (cookie_name) { if (!CookieService.getCookie(cookie_name)) { document.addEventListener('mouseout', mouseEvent); document.addEventListener('keydown', exit); setTimeout(() => { document.addEventListener('scroll', mouseEvent); }, 120_000); } } else { if (!CookieService.getCookie('exitIntentShown')) { document.addEventListener('mouseout', mouseEvent); document.addEventListener('keydown', exit); setTimeout(() => { document.addEventListener('scroll', mouseEvent); }, 120_000); } } }; } else { //Add your javascript for screens smaller than 768 here if (debug) { // code below is used // for testing & will triggger after 10 seconds setTimeout(() => { document.addEventListener('scroll', mobileEvent); // document.querySelector('.exit-intent-popup').classList.add('visible'); }, 1_000); } else { if (cookie_name) { if (!CookieService.getCookie(cookie_name)) { setTimeout(() => { document.addEventListener('scroll', mobileEvent); }, 15_000); } } else { if (!CookieService.getCookie('exitIntentShown')) { setTimeout(() => { document.addEventListener('scroll', mobileEvent); }, 15_000); } } }; } }) // if not mobile } else { if (debug) { // code below is used // for testing & will triggger after 10 seconds setTimeout(() => { document.addEventListener('scroll', mouseEvent); document.addEventListener('mouseout', mouseEvent); document.addEventListener('keydown', exit); }, 10_000); } else { if (cookie_name) { if (!CookieService.getCookie(cookie_name)) { setTimeout(() => { document.addEventListener('mouseout', mouseEvent); document.addEventListener('keydown', exit); document.addEventListener('scroll', mouseEvent); }, 10_000); } } else { if (!CookieService.getCookie('exitIntentShown')) { setTimeout(() => { document.addEventListener('mouseout', mouseEvent); document.addEventListener('keydown', exit); document.addEventListener('scroll', mouseEvent); }, 10_000); } } }; }; window.onload = function() { (function() { // Country mapping dictionary const isoCountryMapping = { "af": "Afghanistan", "al": "Albania", "dz": "Algeria", "as": "American Samoa", "ad": "Andorra", "ao": "Angola", "ai": "Anguilla", "aq": "Antarctica", "ag": "Antigua And Barbuda", "ar": "Argentina", "am": "Armenia", "aw": "Aruba", "au": "Australia", "at": "Austria", "az": "Azerbaijan", "bs": "Bahamas", "bh": "Bahrain", "bd": "Bangladesh", "bb": "Barbados", "by": "Belarus", "be": "Belgium", "bz": "Belize", "bj": "Benin", "bm": "Bermuda", "bt": "Bhutan", "bo": "Bolivia", "ba": "Bosnia and Herzegowina", "bw": "Botswana", "bv": "Bouvet Island", "br": "Brazil", "io": "British Indian Ocean Territory", "bn": "Brunei Darussalam", "bg": "Bulgaria", "bf": "Burkina Faso", "bi": "Burundi", "kh": "Cambodia", "cm": "Cameroon", "ca": "Canada", "cv": "Cape Verde", "ky": "Cayman Islands", "cf": "Central African Republic", "td": "Chad", "cl": "Chile", "cn": "China", "cx": "Christmas Island", "cc": "Cocos (Keeling) Islands", "co": "Colombia", "km": "Comoros", "cd": "Congo", "ck": "Cook Islands", "cr": "Costa Rica", "hr": "Croatia", "cu": "Cuba", "cy": "Cyprus", "cz": "Czech Republic", "ci": "Cote d'Ivoire", "dk": "Denmark", "dj": "Djibouti", "dm": "Dominica", "do": "Dominican Republic", "ec": "Ecuador", "eg": "Egypt", "sv": "El Salvador", "gq": "Equatorial Guinea", "er": "Eritrea", "ee": "Estonia", "et": "Ethiopia", "fk": "Falkland Islands (Malvinas)", "fo": "Faroe Islands", "fj": "Fiji", "fi": "Finland", "fr": "France", "gf": "French Guiana", "pf": "French Polynesia", "ga": "Gabon", "gm": "Gambia", "ge": "Georgia", "de": "Germany", "gh": "Ghana", "gi": "Gibraltar", "gr": "Greece", "gl": "Greenland", "gd": "Grenada", "gp": "Guadeloupe", "gu": "Guam", "gt": "Guatemala", "gg": "Guernsey", "gn": "Guinea", "gw": "Guinea-Bissau", "gy": "Guyana", "ht": "Haiti", "hn": "Honduras", "hk": "Hong Kong", "hu": "Hungary", "is": "Iceland", "in": "India", "id": "Indonesia", "iq": "Iraq", "ie": "Ireland", "im": "Isle of Man", "il": "Israel", "it": "Italy", "jm": "Jamaica", "jp": "Japan", "jo": "Jordan", "kz": "Kazakhstan", "ke": "Kenya", "ki": "Kiribati", "kp": "Korea, Democratic People's Republic Of", "kr": "Korea, Republic of", "kw": "Kuwait", "kg": "Kyrgyzstan", "la": "Lao People's Democratic Republic", "lv": "Latvia", "lb": "Lebanon", "ls": "Lesotho", "lr": "Liberia", "ly": "Libyan Arab Jamahiriya", "li": "Liechtenstein", "lt": "Lithuania", "lu": "Luxembourg", "mo": "Macao", "mg": "Madagascar", "mw": "Malawi", "my": "Malaysia", "mv": "Maldives", "ml": "Mali", "mt": "Malta", "mh": "Marshall Islands", "mq": "Martinique", "mr": "Mauritania", "mu": "Mauritius", "yt": "Mayotte", "mx": "Mexico", "fm": "Micronesia, Federated States of", "md": "Moldova", "mc": "Monaco", "mn": "Mongolia", "ms": "Montserrat", "ma": "Morocco", "mz": "Mozambique", "mm": "Myanmar", "na": "Namibia", "nr": "Nauru", "np": "Nepal", "nl": "Netherlands", "an": "Netherlands Antilles", "nc": "New Caledonia", "nz": "New Zealand", "ni": "Nicaragua", "ne": "Niger", "ng": "Nigeria", "nu": "Niue", "nf": "Norfolk Island", "mp": "Northern Mariana Islands", "no": "Norway", "om": "Oman", "pk": "Pakistan", "pw": "Palau", "pa": "Panama", "pg": "Papua New Guinea", "py": "Paraguay", "pe": "Peru", "ph": "Philippines", "pn": "Pitcairn", "pl": "Poland", "pt": "Portugal", "pr": "Puerto Rico", "qa": "Qatar", "ro": "Romania", "ru": "Russian Federation", "rw": "Rwanda", "re": "Reunion", "ws": "Samoa", "sm": "San Marino", "sa": "Saudi Arabia", "sn": "Senegal", "rs": "Serbia", "sc": "Seychelles", "sl": "Sierra Leone", "sg": "Singapore", "sx": "Netherlands Antilles", "sk": "Slovakia", "si": "Slovenia", "sb": "Solomon Islands", "so": "Somalia", "za": "South Africa", "gs": "South Georgia and the South Sandwich Islands", "es": "Spain", "lk": "Sri Lanka", "bl": "Saint Barthelemy", "sh": "Saint Helena", "kn": "Saint Kitts and Nevis", "lc": "Saint Lucia", "pm": "Saint Pierre and Miquelon", "vc": "Saint Vincent and the Grenadines", "sd": "Sudan", "sr": "Suriname", "sz": "Swaziland", "se": "Sweden", "ch": "Switzerland", "sy": "Syrian Arab Republic", "st": "Sao Tome and Principe", "tw": "Taiwan", "tj": "Tajikistan", "th": "Thailand", "tl": "Timor-Leste", "tg": "Togo", "tk": "Tokelau", "to": "Tonga", "tt": "Trinidad and Tobago", "tn": "Tunisia", "tr": "Turkey", "tm": "Turkmenistan", "tc": "Turks and Caicos Islands", "tv": "Tuvalu", "um": "United States Minor Outlying Islands", "gb": "United Kingdom", "us": "United States", "ug": "Uganda", "ua": "Ukraine", "ae": "United Arab Emirates", "uy": "Uruguay", "uz": "Uzbekistan", "vu": "Vanuatu", "va": "Holy See (Vatican City State)", "ve": "Venezuela", "vn": "Viet Nam", "wf": "Wallis and Futuna", "eh": "Western Sahara", "ye": "Yemen", "zm": "Zambia", "zw": "Zimbabwe", "ax": "Aland Islands", "ps": "Palestinian Territory, Occupied", "mk": "Macedonia, The Former Yugoslav Republic Of", "md": "Moldova" }; function onGeoIpSuccess(location) { var isoCode = location.country.iso_code.toLowerCase(); var countryName = isoCountryMapping[isoCode] || "Country name not found"; var countryId = Object.keys(isoCountryMapping).indexOf(isoCode) + 1; // Assuming country_id starts from 1 // console.log("User's country:", countryName); // Update the hidden form fields with the country name and id document.getElementById('country_name').value = countryName; // document.getElementById('country_id').value = countryId; } function onGeoIpError(error) { console.error("Could not determine country:", error); } // Call geoip2.country to get the user's country information geoip2.country(onGeoIpSuccess, onGeoIpError, { w3cGeolocationDisabled: true }); })(); }; document.addEventListener('click', exit);