SAVE OVER 60% ON STARTER DIGITAL
Subscribe to unlock this article
This article is for subscribers only.
window.onpageshow = function(event) {
if (event.persisted) {
window.location.reload()
}
};
const widget = document.querySelector('.multiCTAModal');
const widgetScope = angular.element(widget).scope();
const subBtn = document.querySelector('#subscribeUrl');
widgetScope.timeoutCall = function(callFn, duration) {
setTimeout(callFn, duration);
}
widgetScope.selectedPackage = 1
widgetScope.changePackage = function(id, subOffer){
if (id == widgetScope.selectedPackage){
return
}
// set selected css style
widgetScope.selectedPackage = id;
// get trackingId and callback url
widgetScope.subURL = new URL(subBtn.href);
widgetScope.trackingId = widgetScope.subURL.searchParams.get("tracking_id");
widgetScope.returnURL = widgetScope.subURL.searchParams.get("new_callback_uri");
// generate new subscribe url
const subUrl = `${subOffer}&tracking_id=${encodeURIComponent(widgetScope.trackingId)}&new_callback_uri=${encodeURIComponent(widgetScope.returnURL)}`
subBtn.href = subUrl
}