Popup Test Page

.email-popup-con{
display: block;
}

var already_appeared = false,
timer,
delay_timer,
delay_popup =false,
check_once = false,
expire,
date = new Date(),
date_close = new Date(),
on_leave_already_appeared = false,
unload_happened = false,
element,
scrollPosition = 0,
on_leave_already_appeared = true,
currentScroll,
scrollPercent,
scrollUpAmount = 0;
var hidden = document.getElementById(“x-btn”);
var pageHeight = $(“body”).height();
jQuery(document).ready(function() {
/*$(“.email-popup-inner-con”).dblclick(function(e){
e.stopPropagation();
});*/
function timeDelay() {
if(!(already_appeared)) {
already_appeared = true;
jQuery(“.email-popup-con”).fadeIn();
delay_popup = true;
}
}
if (!document.cookie.split(“;”).filter(function(item) {
return item.indexOf(“already_submitted=”) >= 0;
}).length) {
if (document.cookie.split(“;”).filter(function(item) {
return item.indexOf(“already_viewed=”) >= 0;
}).length) {
already_appeared = true;
}
else {
timer = setTimeout(timeDelay, 22000);
}
}
function addEvent(obj, evt, fn) {
if (obj.addEventListener) {
obj.addEventListener(evt, fn, false);
}
else if (obj.attachEvent) {
obj.attachEvent(“on” + evt, fn);
}
}
addEvent(window,”load”,function(e) {
addEvent(document, “mouseout”, function(e) {
e = e ? e : window.event;
var from = e.relatedTarget || e.toElement;
if ((!from || from.nodeName === “HTML”) && (e.clientY = 0;
}).length) {
$(window).off(“beforeunload”);
}
else {
if (!document.cookie.split(“;”).filter(function(item) {
return item.indexOf(“on_leave_viewed=”) >= 0;
}).length) {
/*if (already_appeared && !delay_popup) {
document.getElementById(“popup-img”).src=”https://nrsplus.com/wp-content/uploads/2019/06/popupart-1179.jpg”;
document.getElementById(“x-btn”).classList.add(“on-close”);
$(“.email-popup-con”).show();
$(“.on_open_form”).hide();
$(“.on_close_form”).css(“visibility”, “visible”);
on_leave_already_appeared = true;
check_once = true;
clearTimeout(delay_timer);
}*/
if(!on_leave_already_appeared && !already_appeared) {
$(“.email-popup-con”).show();
already_appeared = true;
delay_popup = true;
clearTimeout(timer);
}
}
}
}
if ( document.getElementById(“x-btn”).offsetParent === null ) {
$(window).off(“beforeunload”);
}
});
});
document.addEventListener(‘touchend’, function(event) {
var touch = event.touches[0];
$(window).scroll(function () {
currentScroll = window.scrollY;
if (currentScroll > pageHeight / 10 && currentScroll > scrollPosition ) {
scrollPosition = currentScroll;
}
if ( scrollPosition > 0) {
scrollUpAmount = scrollPosition – currentScroll;
if (!document.cookie.split(“;”).filter(function(item) {
return item.indexOf(“already_submitted=”) >= 0;
}).length) {
if (!document.cookie.split(“;”).filter(function(item) {
return item.indexOf(“on_leave_viewed=”) >= 0;
}).length) {
/*if (scrollUpAmount > 100 && already_appeared && !delay_popup){
on_leave_already_appeared = true;
document.getElementById(“popup-img”).src=”https://nrsplus.com/wp-content/uploads/2019/06/popupart-1179.jpg”;
document.getElementById(“x-btn”).classList.add(“on-close”);
$(“.email-popup-con”).show();
$(“.on_open_form”).hide();
$(“.on_close_form”).css(“visibility”, “visible”);
}*/
}
}
}
});
}, false);
});
function closeButton(tag) {
clearTimeout(timer);
$(“.email-popup-con”).hide();
date.setTime(date.getTime() + (900 * 1000));
expire = “expires=” + date.toUTCString();
document.cookie = “already_viewed=1; ” + expire + “; path=/”;
clearTimeout(delay_timer);
delay_popup = false;
if ( $(tag).hasClass(“on-close”) ) {
$(hidden).hide();
date_close.setTime(date_close.getTime() + (900 * 1000));
expire_close = “expires=” + date_close.toUTCString();
document.cookie = “on_leave_viewed=1; ” + expire_close + “; path=/”;
}
else {
delay_popup = true;
delay_timer = setTimeout(function() { delay_popup = false;}, 15000);
}
}