//Display content based on version
async function altOfferWaiter() {
var RxpInfoReady = setInterval(RxpInfo, 500);
let rxpInfoCheckCount = 0;
//var offersTest = "nothing";
async function RxpInfo() {
if ($Rxp?.getSavedAbOverlay && $Rxp?.respondent?.doiDate) {
clearInterval(RxpInfoReady);
await window.$Rxp.getSavedAbOverlay()
.then(value => {
overlayValue = value[0];
}
);
let doi = $Rxp.respondent.doiDate;
//Calculate Active Days
let d = Date.now();
const days = Math.floor((d - doi) / (24 * 60 * 60 * 1000));
// survey end page complete offer banner logic
//if (window.location.href.indexOf("status=complete") !== -1) {
// if (days >= 30) {
// document.getElementById("SEP-offer-banner").style.display = "block";
// } else {
// document.getElementById("SEP-offer-banner").style.display = "none";
// }
//}
if ((window.location.href.indexOf("status=disqualified") !== -1) || (window.location.href.indexOf("status=overquota") !== -1)) {
if (days >= 30) {
//document.getElementById("offer-screen").style.display = "block";
//document.getElementById("normal-screen").style.display = "none";
/****** Offer Modal ******/
/** Check Cookie Function **/
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else {
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
}
// because unescape has been deprecated, replaced with decodeURI
//return unescape(dc.substring(begin + prefix.length, end));
return decodeURI(dc.substring(begin + prefix.length, end));
}
/** If cookie exists do stuff **/
function offerReqCheck() {
var myCookie = getCookie("offerModalCookie");
if (myCookie == null) {
loadOfferModal();
}
else {
// do nothing
}
}
function loadOfferModal() {
// Get the modal
var osModal = document.getElementById('offerScreenoutModal');
// Get the buttons that opens the modal
var osBtn1 = document.getElementById("offerMaybe");
var osBtn2 = document.getElementById("offerClick");
// Get the element that closes the modals
var osSpan = document.getElementsByClassName("os_close")[0];
// When the user meets the requirements, open the initial modal
osModal.style.display = "block";
// When the user clicks Maybe Later the button
osBtn1.onclick = function () {
osModal.style.display = "none";
let offerModalCookie = 'set';
// Set a Cookie
function setCookie(cName, cValue, expDays) {
let date = new Date();
date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
}
// Apply setCookie
setCookie('offerModalCookie', offerModalCookie, 1);
}
// When the user clicks the offers button
osBtn2.onclick = function () {
let offerModalCookie = 'set';
// Set a Cookie
function setCookie(cName, cValue, expDays) {
let date = new Date();
date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
}
// Apply setCookie
setCookie('offerModalCookie', offerModalCookie, 1);
window.location.href = "/auth/offers";
}
// When the user clicks on a button that closes the modal
osSpan.onclick = function () {
osModal.style.display = "none";
let offerModalCookie = 'set';
// Set a Cookie
function setCookie(cName, cValue, expDays) {
let date = new Date();
date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
}
// Apply setCookie
setCookie('offerModalCookie', offerModalCookie, 1);
}
// When the user clicks anywhere outside of the modal, close it
/**window.onclick = function(event) {
if (event.target == osModal) {
osModal.style.display = "none";
}
}**/
}
offerReqCheck();
}
else {
}
}
}
else {
// Log each time the function is run
rxpInfoCheckCount++;
// Clear the interval if the function runs 15 times
if (rxpInfoCheckCount >= 10) {
clearInterval(RxpInfoReady);
}
else {
}
}
}
}
altOfferWaiter();