`;i++;i==data.length&&(i=0);html+=`
`;i++;el.outerHTML=html}})}})}))})),document.querySelector(“html”).classList.add(“user–subscriber”)):(document.querySelector(“html”).classList.add(“user–non-subscriber”),Publico2022.GetPromo());dataLayer.push({isSubscriber:userOnPage.isSubscriber?userOnPage.isSubscriber:!1,”user.id”:userOnPage.id?userOnPage.id:userOnPage.clientId?userOnPage.clientId:null,”user.isSubscriber”:userOnPage.isSubscriber?userOnPage.isSubscriber:!1,”user.name”:userOnPage.name?userOnPage.name:null,”user.reputation”:userOnPage.rep?userOnPage.rep:null,”user.subscriptionEnd”:userOnPage.subscriptionEnd?userOnPage.subscriptionEnd:null,”user.subscriptionStart”:userOnPage.subscriptionStart?userOnPage.subscriptionStart:null,”user.trackingEnable”:userOnPage.trackingEnable?userOnPage.trackingEnable:!1,”user.userGuid”:userOnPage.userGuid?userOnPage.userGuid:null,”user.anonymousId”:userOnPage.anonymousId?userOnPage.anonymousId:null,”user.rfv”:userOnPage.rfv?userOnPage.rfv:null,”user.rfvName”:userOnPage.rfvName?userOnPage.rfvName:null,”user.country”:userOnPage.country,”user.levels”:userOnPage.levels,”user.customerType”:userOnPage.customerType,”user.businessType”:userOnPage.businessType,”user.product”:userOnPage.product,”user.cluster”:userOnPage.cluster,”user.programType”:userOnPage.programType,”user.isPublico”:userOnPage.isPublico,”user.regSource”:userOnPage.regSource});document.querySelectorAll(“.user-data”).forEach(el=>{el.setAttribute(“title”,Publico2022.userSession.username),el.querySelectorAll(“.user-data-letter”).forEach(ell=>{ell.innerHTML=Publico2022.userSession.username[0].toUpperCase()}),el.querySelectorAll(“.user-data-id”).forEach(elp=>{elp.href=elp.href.replace(“[USER_ID]”,Publico2022.userSession.userId),elp.href+=(elp.href.indexOf(“?”)>-1?”&”:”?”)+”rnd=”+Math.random()}),el.querySelectorAll(“.user-data-name”).forEach(elp=>{elp.innerHTML=elp.innerHTML.replace(“[USER_NAME]”,Publico2022.userSession.username)})});var comWorker=new Worker(“/js/workers/comunication.min.js”);comWorker.onmessage=function(event){var notificationCloseEvent;document.location.pathname.indexOf(“/utilizador/conta/”)<0&&(event.data.type==”user_message_notification”?(dataLayer.push({userMessage:{detail:event.data.detail}}),dataLayer.push({event:”user_message_notification”}),notificationCloseEvent=new CustomEvent(“user_message_notification_2022”,{detail:event.data.detail}),document.dispatchEvent(notificationCloseEvent),Publico.Track.Event(“Messages”,”show”,typeof event.data.detail.analyticEvent!=”undefined”&&event.data.detail.analyticEvent!=””?event.data.detail.analyticEvent:event.data.detail.messageId)):event.data.type==”user_message_ticker”?(comWorker.postMessage({action:”read”,user:Publico.userSession,messageId:event.data.detail.messageId}),notificationCloseEvent=new CustomEvent(“user_message_ticker_2022″,{detail:event.data.detail})):event.data.type==””)};comWorker.postMessage({action:”get”,user:Publico2022.userSession,lastId:localStorage.getItem(“_lstm”)});document.addEventListener(“user_message_close”,function(data){if(data&&data.detail&&data.detail.act&&(comWorker.postMessage({action:”read”,user:Publico.userSession,detail:data.detail}),comWorker.postMessage({action:”read”,user:Publico.userSession,detail:data.detail}),Publico.Track.Event(“Messages”,data.detail.act,typeof data.detail.cat!=”undefined”&&data.detail.cat!=””?data.detail.cat:data.detail.messageId),data.detail.messageId))try{localStorage.setItem(“_lstm”,data.detail.messageId)}catch(e){}});try{eval(“Publico2022.userReputations.”+Publico2022.userSession.reputation)>2&&(document.querySelector(“.user–moderation-link”).style.display=”block”)}catch(e){}},ValidateUser:()=>{try{Publico2022.userSession=JSON.parse(sessionStorage.getItem(“user_session”));document.cookie.indexOf(“_publico=”)<0&&(Publico2022.userSession=null)}catch(e){}Publico2022.userSession==null||typeof Publico2022.userSession.username==”undefined”?(Publico2022.userSession={isSubscriber:!1},Publico2022.Cookies.get(“_publico”)==”true”?fetch(“/api/user/validate”,{method:”post”,headers:{“Content-Type”:”application/json”}}).then(el=>{el.status==200?el.json().then(d=>{Publico2022.userSession=d,Publico2022.WorkUser(),document.dispatchEvent(publicoUserEvent),sessionStorage.setItem(“user_session”,JSON.stringify(d))}):(document.dispatchEvent(publicoUserEvent),Publico2022.CheckLoggedOffUser())}).catch(()=>{document.dispatchEvent(publicoUserEvent),Publico2022.CheckLoggedOffUser()}):(document.dispatchEvent(publicoUserEvent),Publico2022.CheckLoggedOffUser())):(Publico2022.WorkUser(),document.dispatchEvent(publicoUserEvent))},LastMinute:()=>{var runDate=new Date,cbUrl=runDate.getFullYear()+””+runDate.getMonth()+””+runDate.getDate()+””+runDate.getHours()+””+Math.floor(runDate.getMinutes()/2);fetch(” result.json().then(function(data){if(data){clearInterval(Publico2022.lastMinuteInterval);var html=”
`;
el.insertAdjacentHTML(“afterend”, html);
iCount = 1;
vertCount++;
firstSlotFilled = true;
}
});
}
class VideoAutoPlayHandler {
constructor(el) {
this.el = el;
if (el.parentElement && el.clientWidth > el.parentElement.clientWidth) {
el.style.width = “100%”;
}
el.play();
try {
this.title = el.dataset.title ? el.dataset.title : el.querySelector(“source”).src;
} catch (e) {
this.title = “n/a”;
}
if (el.parentElement) {
var unmuted = el.parentElement.querySelector(“.unmuted”);
var muted = el.parentElement.querySelector(“.muted”);
muted.classList.add(“hide”);
unmuted.classList.remove(“hide”);
el.parentElement.querySelector(“.btn–mute”).addEventListener(“click”, function () {
el.muted = !el.muted;
el.play();
if (el.muted) {
muted.classList.add(“hide”);
unmuted.classList.remove(“hide”);
} else {
muted.classList.remove(“hide”);
unmuted.classList.add(“hide”);
}
});
}
el.addEventListener(“play”, function (ev) {
dataLayer.push({
“event”: “video_auto_play”,
“action”: “play”,
title: this.title
});
});
el.addEventListener(“pause”, function (ev) {
dataLayer.push({
“event”: “video_auto_play”,
“action”: “pause”,
title: this.title
});
});
el.addEventListener(“timeupdate”, function (ev) {
var el = ev.target;
var curTime = el.currentTime;
var elapsed = curTime * 100 / el.duration;
//dataLayer.push({
// “event”: “video_auto_play”,
// “elapsed”: 0,
// title: this.title
//});
});
}
Play() {
this.el.play();
}
Pause() {
this.el.pause();
}
Update(pos) {
if (pos == 0) {
this.Pause();
} else {
this.Play();
}
}
}
deferredScripts.push(function () {
if (Publico.Cookies.get(“_publico”) == null && (!userOnPage || !userOnPage.userGuid) && (!Publico.userSession || !Publico.userSession.userId)) {
if (typeof jQuery == “undefined”) {
Publico.LoadScript(“/js/googleCallback.min.js”).then(function () {
//AppendGSignInButton(“”, “”, “”, “”, “”);
initGoogle();
document.dispatchEvent(new Event(“GoogleAuthReady”));
});
} else {
$.getScript(“/js/googleCallback.min.js”).then(function () {
//AppendGSignInButton(“”, “”, “”, “”, “”);
initGoogle();
document.dispatchEvent(new Event(“GoogleAuthReady”));
});
}
}
Publico.ValidateLogin = function (params) {
window.params = params;
return new Promise(function (resolve, reject) {
if (userOnPage.userGuid && userOnPage.userToken) {
resolve(userOnPage);
} else {
window.hasJobAfterLogin = “pianoAfterLoginEventHandler”;
$(“.item-type”).html(“”);
$(“.item-description”).html(“”);
$(“.item-price”).html(“”);
$(“.item-renew-price”).html(“”);
$(“.item-duration”).html(“”);
$(“body”).removeClass(“is-gift”).removeClass(“is-group”);
var startScreen = window.startScreen || “#modal-login-email”;
showLogin(startScreen, undefined, true).then(function () {
fetch(“/api/piano/term/” + window.params.offerId + ” + window.params.termId).then(function (response) {
if (response.status == 200) {
response.json().then(function (data) {
if (data && data.result) {
//if (data.offer.isGift) $(“body”).addClass(“is-gift”);
//if (data.offer.isGroup) $(“body”).addClass(“is-group”);
$(“.form-step-wrapper”).show();
$(“.item-type”).html(data.offer.periodName);
$(“.item-description”).html(data.offer.description);
if (data.offer.price != data.offer.nextPrice && data.offer.nextPrice != “”) {
$(“.item-price”).html(“” + data.offer.nextPrice + “€ ” + data.offer.price + “€”);
$(“.item-renew-price”).html(“Renova a ” + data.offer.nextPrice + “€”);
$(“.item-renew-price”).show();
} else {
$(“.item-price”).html(data.offer.price + “€”);
$(“.item-renew-price”).html(“Renova a ” + data.offer.price + “€”);
$(“.item-renew-price”).show();
}
$(“.item-duration”).html(data.offer.period);
}
});
}
});
document.addEventListener(window.hasJobAfterLogin, function () {
$(“.reveal”).each(function (el) {
try {
$(“#” + this.id).foundation(“close”);
} catch (e) { }
});
resolve(userOnPage);
});
});
}
});
}
Publico.TrackLink = function (el, isPiano) {
if (!isPiano || typeof window.pianoTrackingId == “undefined”) {
setTimeout(function () { Publico.TrackLink(el) }, 500);
}
if (el && el.href && el.href.indexOf(“trackingId”) < 0) {
el.href += (el.href.indexOf(“?”) < 0 ? “?” : “&”) + “trackingId=” + encodeURIComponent(window.trackingId);
el.addEventListener(“click”, function (e) {
var name = “”, campain = “”;
var $el = $(this);
name = typeof $el.data(“name”) !== “undefined” ? $el.data(“name”) : (typeof $el.data(“nome”) !== “undefined” ? $el.data(“nome”) : $el[0].className);
campain = $el.data(“campanha”);
var data = {
init: name,
exp: (typeof campain != “undefined” ? campain : “none”),
trackingId: window.trackingId,
url: document.location.href,
userId: window.userId
};
Publico.Cookies.save(“_conv”, JSON.stringify(data));
//is-paywalled
if (document.body.classList.contains(“is-paywalled”)) {
Publico.Track.Event(“PAYWALL”, “click”, name + “_” + (typeof campain != “undefined” ? campain : “none”));
} else {
Publico.Track.Event(“Subscribe”, “click”, name + “_” + (typeof campain != “undefined” ? campain : “none”));
}
if (typeof pingLog == “undefined”)
Publico.PingLog(data);
else
pingLog(data);
createMicroConvertion(name, data);
});
}
}
var markLink = Publico.TrackLink;
if (typeof Publico.Url != “undefined” || typeof Publico.Utils != “undefined”) {
var fn = (Publico.Url && Publico.Url.param) || Publico.Utils.GetUrlParam;
if (fn(“showoffer”) == “1”) {
tp.push([“init”, function () {
var terms = [];
if (fn(“term”)) {
terms.push(fn(“term”));
}
setTimeout(function () {
window.tp.offer.show({
formNameByTermId: ‘{“‘ + fn(“term”) + ‘”:”checkoutWithInvoice”}’,
offerId: fn(“offer”),
termId: fn(“term”),
termIds: terms,
checkoutFlowId: fn(“flow”),
promoCode: fn(“promo”),
close: function () {
Publico.Track.Event(“Piano”, “close”, “showOffer”);
},
complete: function (obj) {
console.log(obj);
Publico.Track.Event(“Piano”, “complete”, “showOffer”);
}
});
}, 500);
}]);
}
}
var paramFunc = Publico.Utils.GetUrlParam || Publico.Url.param;
if (typeof paramFunc === “function”) {
window.activateToken = paramFunc(“activate_user”);
if (window.activateToken != null && window.activateToken != “”) {
openActivation();
/*
if (typeof Publico.ShowLogin != “undefined”) {
Publico.LoadDependencies([“jQuery”, “Foundation”]).then(() => {
openActivation();
});
} else {
openActivation();
}
*/
}
}
});
function markHPAnchor(el) {
if (el.href && el.href.indexOf(“ref=”) < 0) {
var href = el.attributes[“href”].value;
var isLocal = false;
if (href[0] == ” || href.indexOf(“://www.publico.pt”) > -1 || href.indexOf(“://beta-prod.publico.pt”) > -1) {
isLocal = true;
}
var newHref = href;
if (href.indexOf(“#”) > -1) newHref = href.split(“#”)[0];
newHref += (newHref.indexOf(“?”) > -1 ? “&” : “?”) + “ref=” + path;
if (href.indexOf(“#”) > -1) newHref += “#” + href.split(“#”)[1];
if (typeof el.closest == “function”) {
var parent = el.closest(“section”);
if (el.dataset.collection) {
parent = el;
}
else if (parent != null) {
if (parent.dataset.collection) {
newHref += “&cx=” + parent.dataset.collection;
} else if (parent.classList.length > 0) {
newHref += “&cx=” + parent.classList[0];
}
}
else if (el.closest(“nav”) != null) {
parent = el.closest(“nav”);
newHref += “&cx=” + (parent.dataset.collection ? parent.dataset.collection : parent.classList[parent.classList.length – 1]);
}
else if (el.closest(“aside”) != null) {
parent = el.closest(“aside”);
newHref += “&cx=” + (parent.dataset.collection ? parent.dataset.collection : parent.classList[parent.classList.length – 1]);
}
else if (el.closest(“ul”) != null) {
parent = el.closest(“ul”);
newHref += “&cx=” + (parent.dataset.collection ? parent.dataset.collection : parent.classList[parent.classList.length – 1]);
}
else if (el.closest(“.block”) != null) {
parent = el.closest(“.block”);
newHref += “&cx=” + (parent.dataset.collection ? parent.dataset.collection : parent.classList[parent.classList.length – 1]);
}
if (parent) {
var collectionName = parent.dataset.collection ? parent.dataset.collection : parent.classList[parent.classList.length – 1];
el.addEventListener(“click”, function (e) {
Publico.Track.Event(“Homepage”, “click”, collectionName); // + “_” + this.href);
if (collectionName == “temas_editoriais”) {
dataLayer.push({
“event”: “editorial_themes”,
“sub_menu”: el.innerText
});
}
if (document.location.pathname == “) {
dataLayer.push({
event: “homepage”,
clicked: collectionName,
url: el.href
})
}
});
}
}
if (isLocal) el.href = newHref;
}
}
document.addEventListener(“DOMContentLoaded”, function () {
document.querySelector(“.masthead–thin”).querySelectorAll(“a”).forEach(function (el) {
markHPAnchor(el)
});
});
document.addEventListener(“user_message_notification_2022”, function (data) {
if (data && data.detail) {
var e = data;
if (typeof e.detail.analyticEvent == “undefined” || e.detail.analyticEvent == “”) e.detail.analyticEvent = “”;
if (typeof e.detail.actionText == “undefined” || e.detail.actionText == “”) e.detail.actionText = “Saiba mais”;
var userNotificationThumb = ”, userNotificationTitle=””, userNotificationText=””, userNotificationLink = ‘#’, userNotificationCategory = ”;
if (e.detail) {
if (e.detail.thumbnail && e.detail.thumbnail != ”) {
userNotificationThumb = ‘
‘
}
if (e.detail.title && e.detail.title != ”) {
userNotificationTitle=”
” + e.detail.title + ‘
‘
}
if (e.detail.text && e.detail.text != ”) {
userNotificationText = e.detail.text
}
if (e.detail.link && e.detail.link != ”) {
userNotificationLink = e.detail.link
}
if (typeof e.detail.category != “undefined” && e.detail.category != null && e.detail.category != “”) {
userNotificationCategory = e.detail.category;
}
var html=”
” +
‘
userNotificationThumb +
‘
userNotificationTitle +
” +
‘
‘ + e.detail.actionText + ‘
‘ +
‘
‘;
document.querySelector(“main”).insertAdjacentHTML(“beforeend”, html);
var message = document.querySelector(“#subscriber-warning-notification”);
setTimeout(function () {
message.classList.add(‘visible’);
}, 50);
message.querySelector(“button”).addEventListener(‘click’, function () {
message.classList.add(‘hidden’);
var notificationCloseEvent = new CustomEvent(e.detail.eventName, { detail: { act: “close”, messageId: e.detail.messageId, cat: e.detail.analyticEvent } });
document.dispatchEvent(notificationCloseEvent);
});
message.querySelector(“a”).addEventListener(‘click’, function () {
message.classList.add(‘hidden’);
var notificationCloseEvent = new CustomEvent(e.detail.eventName, { detail: { act: “read”, messageId: e.detail.messageId, cat: e.detail.analyticEvent } });
document.dispatchEvent(notificationCloseEvent);
});
//Publico.TrackLink(document.querySelector(“.user-notification”));
}
}
});
document.addEventListener(“user_message_ticker_2022″, function (data) {
if (data && data.detail) {
var e = data;
if (e.detail) {
var userTickerIcon = ”,
closeButton = ”;
if (e.detail.allowClose && e.detail.allowClose === true) {
closeButton = ‘‘;
}
if (e.detail.token && e.detail.token != ”) {
userTickerIcon = ”
}
var html=”
” +
‘
userTickerIcon +
‘Inicie sessão para ler os conteúdos exclusivos. Clique aqui‘ +
‘
‘ +
closeButton +
‘
‘;
document.querySelector(“#masthead”).insertAdjacentHTML(“beforebegin”, html);
var ticker = document.querySelector(“#subscriber-warning–ticker”);
ticker.querySelector(“a”).addEventListener(‘click’, function () {
var notificationCloseEvent = new CustomEvent(e.detail.eventName, { detail: { messageId: e.detail.messageId } });
document.dispatchEvent(notificationCloseEvent);
});
if (ticker.querySelector(“button”) != null) {
ticker.querySelector(“button”).addEventListener(‘click’, function () {
ticker.style.display = “none”;
var notificationCloseEvent = new CustomEvent(e.detail.eventName, { detail: { act: “close”, messageId: e.detail.messageId } });
document.dispatchEvent(notificationCloseEvent);
});
}
}
}
});
document.addEventListener(“keydown”, function (e) {
if (e.key == “Escape”) {
var userMenu = document.querySelector(“#user-menu”);
if (userMenu.classList.contains(“is-active”)) {
toggleUserMenu();
}
if (mainMenu.classList.contains(“is-open”)) {
toggleMainMenu();
}
if (bodyEl.classList.contains(“search-panel-is-open”)) {
toggleSearch();
}
}
});
document.addEventListener(“piano_tracking_id”, function (e) {
var regex = new RegExp(“[\\?&]trackingId=([^]*)”);
results = regex.exec(location.search);
var trackingId = results === null ? “” : decodeURIComponent(results[1].replace(/\+/g, ” “));
if (trackingId != “”) e.detail = trackingId;
window.pianoTrackingId = window.trackingId = e.detail;
document.querySelectorAll(“.call-to-action a, .subscribe-link”).forEach(el => {
Publico.TrackLink(el, true);
});
});
document.addEventListener(“piano_show_datawall”, function () {
if (typeof Publico != “undefined” && typeof Publico.CleanBody != “undefined”) {
Publico.CleanBody(false);
var body = document.querySelector(“#story-content”);
body.querySelectorAll(“#story-body .ad-slot”).forEach(el => {
el.remove()
});
try {
var el;
var pos = “afterend”;
if (Publico.Utils.IsMobile) {
if (body.querySelector(“#story-body”).children[0].classList.contains(“pw-container”)) {
pos = “afterbegin”;
el = body.querySelector(“#story-body”);
} else {
el = body.querySelector(“#story-body”).children[0];
}
} else {
el = body.querySelector(“#story-body”).children[1];
}
el.insertAdjacentHTML(pos, “
var cusEvent = new Event(“pub.inContent”);
document.dispatchEvent(cusEvent);
} catch (e) { }
fetch(“/content/inlineLogin2020.html?v=2020&cb=” + Publico.cbJS).then(function (result) {
if (result.status == 206) {
result.text().then(function (html) {
$(“#inline2021”).remove();
$(“#story-body .modal–user-login”).remove();
$(“.article–a”).remove();
$(“.subscription-disclaimer”).remove();
$(“.pw-container”).remove();
var body = document.querySelector(“#story-content”);
body.querySelectorAll(“#story-body .ad-slot”).forEach(el => {
el.remove()
});
$(“#story-body”).children().eq(0).after(“”);
try {
var el;
var pos = “afterend”;
if (Publico.Utils.IsMobile) {
if (body.querySelector(“#story-body”).children[0].classList.contains(“pw-container”)) {
pos = “afterbegin”;
el = body.querySelector(“#story-body”);
} else {
el = body.querySelector(“#story-body”).children[0];
}
} else {
el = body.querySelector(“#story-body”).children[1];
}
el.insertAdjacentHTML(pos, “
var cusEvent = new Event(“pub.inContent”);
document.dispatchEvent(cusEvent);
} catch (e) { }
$(“.paywall-block__content”).append(”);
$(“.paywall-block__datawall”).append(html);
});
}
});
}
});
document.addEventListener(“user_loggedin”, function () {
var start = window.startPoint || “login”;
dataLayer.push({ “method”: start });
dataLayer.push({ “event”: “login” });
});
document.addEventListener(“user_registration_start”, function () {
var start = window.startPoint || “login”;
dataLayer.push({ “method”: start });
dataLayer.push({ “event”: “sign_up” });
if (tp && tp.log) {
tp.log.logConversion(
window.trackingId,
“TMDPF936CJ47”,
“Datawall Registration”,
2, “”, “”, “”,
“registration”
);
}
});
document.addEventListener(“user_registration_end”, function () {
var start = window.startPoint || “login”;
dataLayer.push({ “method”: start });
dataLayer.push({ “event”: “signed_up” });
});
document.addEventListener(“user.entityReady”, function () {
if (userOnPage && userOnPage.isSubscriber && userOnPage.subId == undefined) {
fetch(“/api/user/validate”, {
“method”: “post”, headers: {
‘Content-Type’: ‘application/json’
}
}).then(el => {
if (el.status == 200) {
el.json().then(d => {
sessionStorage.setItem(“user_session”, JSON.stringify(d));
});
}
});
}
});
document.addEventListener(“piano_show_blur”, function () {
$(“#story-body”).css(“filter”, “blur(3px)”);
});
document.addEventListener(“floorAdAvailable”, function () {
function addCloseButtonToFloorAd() {
var targetElement = document.querySelector(‘ins’);
var customHTML = ”;
if (targetElement) {
if (!targetElement.querySelector(‘.ins-wrapper’)) {
targetElement.style.backgroundColor=”transparent”;
targetElement.insertAdjacentHTML(‘afterbegin’, customHTML);
targetElement.querySelector(‘.btn-close’).addEventListener(‘click’, function () {
targetElement.remove();
});
}
}
}
window.anchorInterval = setInterval(function () {
document.querySelectorAll(“ins”).forEach(el => {
if (el.id.indexOf(“gpt_unit_/4458504/HORZ/”) > -1 && parseInt(el.style.bottom) < 5) {
clearInterval(window.anchorInterval);
el.style.visibility = “hidden”;
el.children[0].style.display = “none”;
el.children[1].style.display = “none”;
addCloseButtonToFloorAd();
Publico2022.AddScrollEvent(function () {
var horzEl = document.querySelector(“#banner-and-header .pubHorz”);
var minHeight = 100;
if (horzEl != null)
minHeight = horzEl.offsetHeight;
var scrolled = document.scrollingElement.scrollTop;
if (scrolled > Math.max(minHeight, 100)) {
el.children[2].style.display = “block”;
el.querySelector(“.ins-wrapper .btn-close”).style.display = “block”;
} else {
el.children[2].style.display = “none”;
el.style.zIndex = 999;
el.querySelector(“.ins-wrapper .btn-close”).style.display = “none”;
}
});
setTimeout(function () {
el.style.bottom = Publico.Utils.IsMobile ? “37px” : “57px”;
}, 2500);
}
});
}, 50);
});
document.addEventListener(“radiantPlayerReady”, function (ev) {
var player = ev.detail;
var el = document.getElementById(player.id);
if (el != null && el.dataset.shareUrl) {
el.querySelectorAll(“.rmp-quality”).forEach(rmp => {
rmp.remove();
});
var parent = el.parentElement;
parent.insertAdjacentHTML(‘beforeend’, `
`);
var shareData = {
title: el.dataset.videoTitle,
url: el.dataset.shareUrl
};
player.on(“ended”, function () {
player.setControls(false);
parent.querySelector(“.coming-next”).classList.add(“show”);
document.getElementById(`share_${player.id}`).addEventListener(“click”, function () {
if (navigator.share) {
navigator.share(shareData)
}
});
document.getElementById(`replay_${player.id}`).addEventListener(“click”, function () {
parent.querySelector(“.coming-next”).classList.remove(“show”);
player.setControls(true);
player.seekTo(0);
player.play();
});
});
}
});
if ((path == ” || path.split(“).length == 2)) {
path = path == ” ? “hp” : path.split(“)[1];
window.anchorObserver = new IntersectionObserver(function (entries) {
var visibles = entries.filter(function (f) { return f.isIntersecting; });
visibles.forEach(function (v) {
var el = v.target;
try {
observer.unobserve(el);
} catch (e) { }
markHPAnchor(el);
});
}, { threshold: [0] });
document.querySelectorAll(“a”).forEach(function (el) {
anchorObserver.observe(el);
});
}
if (typeof fetch != “undefined” && document.querySelector(‘#install-pwa-cta’) != null) {
var deferredPrompt;
var addBtn = document.querySelector(‘#install-pwa-cta’).parentElement;
addBtn.style.display = ‘none’;
window.addEventListener(‘beforeinstallprompt’, (e) => {
e.preventDefault();
deferredPrompt = e;
addBtn.style.display = ‘block’;
var deferredScripts = window.deferredScripts || [];
deferredScripts.push(function () {
var $pwaCta = $(‘#install-pwa-cta’);
if ($pwaCta.length > 0 && typeof (Storage) != “undefined”) {
if (!localStorage.notificationPopover) {
$pwaCta.attr(‘title’, ‘Adicione o PÚBLICO ao ecrã principal’)
$pwaCta.one(‘click’, function () {
localStorage.setItem(‘notificationPopover’, ‘shown’);
});
} else {
$pwaCta.attr(‘title’, ‘Instalar’);
}
}
});
addBtn.addEventListener(‘click’, (e) => {
Publico.Track.Event(“PWA”, “start”, “install”);
deferredPrompt.prompt();
deferredPrompt.userChoice.then((choiceResult) => {
if (choiceResult.outcome === ‘accepted’) {
Publico.Track.Event(“PWA”, “accepted”, “install”);
console.log(‘User accepted the A2HS prompt’);
} else {
Publico.Track.Event(“PWA”, “denied”, “install”);
console.log(‘User dismissed the A2HS prompt’);
}
deferredPrompt = null;
});
});
});
}
if (document.querySelectorAll(“.btn–play.single”).length > 0) {
var intervals = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100];
var actualInterval = […intervals];
var btnPlay = ‘‘;
var btnPause=”“;
var lastPlayed = null;
var newsDetails = {};
try {
newsDetails = JSON.parse(document.querySelector(“script[type=”application/ld+json”]”).innerHTML);
} catch (e) {
newsDetails = {};
}
document.querySelectorAll(“.btn–play.single”).forEach(el => {
el.addEventListener(“click”, function () {
if (this.dataset.src && this.dataset.duration)
playPauseVideo(this);
});
});
function playPauseVideo(el) {
if (lastPlayed !== null && lastPlayed !== el) {
lastPlayed.classList.remove(“btn–pause”);
lastPlayed.classList.add(“btn–play”);
lastPlayed.innerHTML = btnPlay;
if (window[“video” + lastPlayed.dataset.id] != undefined) {
window[“video” + lastPlayed.dataset.id].pause();
pingAdudioGA4(“audio_paused”, 0, window[“video” + lastPlayed.dataset.id].duration, 0);
}
actualInterval = […intervals];
}
var id = el.dataset.id;
var duration = el.dataset.duration;
var progressBar = el.parentElement.querySelector(“.rmplayer__progress-bar-and-time”);
var passed = progressBar.querySelector(“.rmplayer__tracked”);
if (window[“video” + id] != undefined) {
if (el.classList.contains(“btn–play”)) {
window[“video” + id].play();
pingAdudioGA4(“audio_resumed”, 0, window[“video” + id].duration, 0);
pauseAudioElement(el);
} else {
window[“video” + id].pause();
pingAdudioGA4(“audio_paused”, 0, window[“video” + id].duration, 0);
playAudioElement(el);
}
} else {
var video = document.createElement(“video”);
video.src = el.dataset.src;
video.addEventListener(“timeupdate”, function (ev) {
var el = ev.target;
var curTime = el.currentTime;
var elapsed = curTime * 100 / el.duration;
el.progressBar.querySelector(“.rmplayer__current-time”).innerText = new Date(curTime * 1000).toISOString().slice(14, 19);
el.progressBar.querySelector(“.rmplayer__passed”).style.cssText = “width:” + elapsed + “%”;
if (elapsed > -1) {
var lastInterval = intervals.indexOf(Math.floor(elapsed));
if (lastInterval > -1) {
intervals.splice(lastInterval, 1);
pingAdudioGA4(“audio_progress”, curTime, this.duration, Math.floor(elapsed));
}
}
});
video.addEventListener(“ended”, function () {
progressBar.querySelector(“.rmplayer__passed”).style.cssText = “width:100%”;
pingAdudioGA4(“audio_completed”, this.duration, this.duration, 100);
playAudioElement(el);
});
video.progressBar = progressBar;
video.play();
window[“video” + id] = video;
pingAdudioGA4(“audio_start”, 0, parseInt(el.dataset.duration), 0);
passed.addEventListener(“click”, function (e) {
var perc = e.offsetX / $(this).width() * 100;
window[“video” + id].currentTime = perc * duration / 100;
});
pauseAudioElement(el)
}
lastPlayed = el;
}
function pingAdudioGA4(name, curTime, duration, elapsed) {
dataLayer.push({
“audio_current_time”: curTime,
“audio_duration”: duration,
“audio_percent”: Math.floor(elapsed),
“audio_provider”: “PUBLICO”,
“audio_title”: newsDetails.headline ? newsDetails.headline.toSlug() : “”,
“audio_url”: newsDetails.url || document.location.href
});
dataLayer.push({ ‘event’: name });
}
function pauseAudioElement(el) {
el.classList.remove(“btn–play”);
el.classList.add(“btn–pause”);
el.innerHTML = btnPause;
}
function playAudioElement(el) {
el.classList.remove(“btn–pause”);
el.classList.add(“btn–play”);
el.innerHTML = btnPlay;
}
}
if (document.querySelectorAll(“.video-autoplay”).length > 0) {
var videoObserver = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.intersectionRatio > 0) {
if (typeof entry.target.videoHandler == “undefined”) {
var videoHandler = new VideoAutoPlayHandler(entry.target);
videoHandler.Play();
entry.target.videoHandler = videoHandler
}
}
if (entry.target.videoHandler)
entry.target.videoHandler.Update(entry.intersectionRatio);
});
}, { rootMargin: “-50px 0px 0px 0px” });
document.querySelectorAll(“.video-autoplay”).forEach(el => {
videoObserver.observe(el);
});
}
if (document.querySelector(“#story-callout-contact”)) {
deferredScripts.push(function () {
var func = Publico.LoadScript == undefined ? Publico.Utils.GetScript : Publico.LoadScript;
func(”
document.querySelector(“#story-callout-contact”).addEventListener(“submit”, function (e) {
e.preventDefault();
var submit = this.querySelector(“input[type=”submit”]”);
var widgetId = this.dataset.widgetId;
var text = this.querySelector(“#story-email”).value;
var email = this.querySelector(“#story-email-address”).value;
var contact = this.querySelector(“#story-contact”).value;
if (widgetId == null) return;
var token = grecaptcha.getResponse(widgetId);
if (text.isEmpty()) return;
if (email.isEmpty()) return;
if (token.isEmpty()) return;
submit.value = “Aguarde…”;
submit.setAttribute(“disabled”, “disabled”);
var form = this;
text += “\r\n” + document.location.href;
fetch(“/api/contact”, {
method: “post”,
headers: {
‘Content-Type’: ‘application/json’
},
body: JSON.stringify({ email: email, text: text, token: token, contact: contact })
}).then(response => {
if (response.status == 200) {
Publico.Track.Event(“FORM”, “CONTACT”, “SENT”);
var el = form.parentElement.parentElement.querySelector(“.card__text”);
if (el) {
el.insertAdjacentHTML(“beforeend”, “
“)
}
submit.remove();
} else {
submit.value = “Enviar”
submit.removeAttribute(“disabled”);
}
});
});
});
}
Publico.TrackLink = function (el, isPiano) {
setTimeout(function () {
Publico.TrackLink(el, isPiano);
}, 500);
};
var createMicroConvertion = function (name, data) {
if (typeof tp != “undefined” || typeof tp.log != “undefined”) {
tp.log.logMicroConversion(window.pianoTrackingId, name, data);
}
}
var markLink = function (el) {
setTimeout(function () {
markLink(el);
}, 500);
}
/*
var openActivation = function () {
fetch(“/content/activate.html”).then(response => {
if (response.status == 200) {
response.text().then(function (html) {
const newElement = document.createRange().createContextualFragment(html);
document.body.appendChild(newElement);
if (typeof jQuery != “undefined”) {
$(“#consentimento-container”).foundation();
$(“#consentimento-container”).foundation(“open”);
}
});
} else {
//reject();
}
});
window.history.replaceState({}, ”, ‘ + document.location.host + document.location.pathname);
}
*/
/*Autofill Piano Iframes*/
let fnLastSaved, lnLastSaved, nrLastSaved;
function targetIframeAction(){
fnLastSaved = localStorage.getItem(‘fnSaved’);
lnLastSaved = localStorage.getItem(‘lnSaved’);
nrLastSaved = localStorage.getItem(‘nrSaved’);
let targetIframe = document.querySelector(‘.ifrm’);
let message = {
savedValue1: fnLastSaved,
savedValue2: lnLastSaved,
savedValue3: nrLastSaved
};
if(targetIframe) {
targetIframe.contentWindow.postMessage(message, ‘*’);
}
}
window.addEventListener(‘message’, (event) => {
if (event.origin == ‘ {
localStorage.setItem(event.data.key1, event.data.value1);
localStorage.setItem(event.data.key2, event.data.value2);
localStorage.setItem(event.data.key3, event.data.value3);
}
});
var idFromIframe = “”;
var tp_params = {
rid: “RJ1VIB5″
};
tp.push([“addHandler”, “checkoutComplete”, function (conversion) {
Publico.Track.Event(“LOJA”, “success”, userOnPage.userGuid);
window.marfeel.cmd.push([‘compass’, function (compass) {
compass.trackConversion(‘subscription’);
}]);
}]);
tp.push([“addHandler”, “customEvent”, function (event, b, c, d) {
switch (event.eventName) {
case “login-provider”:
var urlProvider = “”;
switch (event.params.provider) {
case “apple”:
urlProvider = “/api/user/apple”;
break;
case “google”:
urlProvider = “/api/user/google”;
break;
case “meta”:
case “facebook”:
urlProvider = “/api/user/facebook”;
break;
}
if (urlProvider != “”) {
var redirectUrl = `${document.location.protocol}//${document.location.host}${document.location.pathname}`;
const popupH = 600;
var popupW = 450;
if (event.params.provider === ‘apple’) {
popupW = 660;
}
const availLeft = window.screen && window.screen.availLeft
? window.screen.availLeft
: 0;
const popupWindowParams = [
`height=${popupH}`,
`width=${popupW}`,
`left=${availLeft + window.screen.width / 2 – popupW / 2}`,
`top=${Math.max(window.screen.height / 2 – popupH / 2 – 20, 0)}`,
‘scrollbars=1’,
].join(‘,’);
var templateUrl = document.querySelector(‘#piano–paywall-bottom iframe’).src;
var templateUrlParams = new URLSearchParams(templateUrl.split(‘?’)[1]);
var templateId = templateUrlParams.get(‘templateId’);
var section;
switch (templateId) {
case “OTZQ2FL692U8”:
section = ‘MULTIMEDIA’;
break;
case “OTA8DXLP2OGN”:
section = ‘MULTIMEDIA’;
break;
case “OTW7Y7ZBAU45”:
section = ‘NEWSLETTER_AUTOR’;
break;
case “OT4CK3BRJ0HV”:
section = ‘NEWSLETTERS_ABERTAS’;
break;
default:
section = “”;
break;
}
debugger;
var loginWindow = window.open(urlProvider + “?redirect_url=” + encodeURIComponent(redirectUrl + “?fromPopup=1&sec=” + section), “login”, popupWindowParams);
if (loginWindow == null || loginWindow.closed) {
document.location = urlProvider + “?redirect_url=” + encodeURIComponent(redirectUrl + “&sec=” + section );
}
}
break;
case “login-local”:
switch (event.params.datawall) {
case “iniciar_sessao”:
dataLayer.push({
‘event’: ‘datawall_interactions_a’,
‘clicked_zone’: ‘iniciar_sessao’
});
break;
}
var func = showLogin;
if (“ShowLogin” in Publico) {
func = Publico.ShowLogin
}
func().then(el => {
});
tp.offer.close();
break;
case “register-local”:
window.registerSource = “PUBLICO_LOCK”;
switch (event.params.datawall) {
case “registe-se_gratuitamente”:
dataLayer.push({
‘event’: ‘datawall_interactions_a’,
‘clicked_zone’: ‘registe-se_gratuitamente’
});
break;
case “modal-jogos-sudoku”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-sudoku”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OTO7RV4HPXLP”;
break;
case “modal-jogos-letra-a-mais”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-letra-a-mais”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OTUCIKL7OM07”;
break;
case “modal-newsletters-abertas”:
dataLayer.push({
“event”: “click_to_sign_up_modal_newsletters_abertas”
});
idFromIframe = “OT4CK3BRJ0HV”;
break;
case “modal-jogos-xadrez-new”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-xadrez-new”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OTBB7QSYCSP2”;
break;
case “modal-jogos-bridge-new”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-bridge-new”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OTB6QZJMZ9EA”;
break;
case “modal-jogos-antes-e-depois-new”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-antes-e-depois-new”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OTTMG17XNPVE”;
break;
case “modal-jogos-mini-palavras-cruzadas-new”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-mini-palavras-cruzadas-new”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OTNXWVHJFNQO”;
break;
case “modal-jogos-palavras-cruzadas-new”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-palavras-cruzadas-new”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OT1M5OBJ9K5J”;
break;
case “modal-jogos-sopa-de-letras-new”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-sopa-de-letras-new”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OT1DANMHZWDQ”;
break;
case “modal-jogos-sudoku-new”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-sudoku-new”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OTL2MH8Y1FW1”;
break;
case “modal-jogos-letra-a-mais-new”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-letra-a-mais-new”,
“action”: “click”,
“label”: “registe-se_gratuitamente”
});
idFromIframe = “OTHIDHL315IQ”;
break;
}
var func = showLogin;
if (“ShowLogin” in Publico) {
func = Publico.ShowLogin
}
func(true).then(el => {
});
tp.offer.close();
break;
case “subscribe-button-paywall”:
if(pageTags.includes(‘EXCLUSIVE’)){
dataLayer.push({
‘event’: ‘subscriptions_buttons’,
‘action’: ‘click’,
‘label’:’comprar_assinatura’,
‘location’: ‘Assine já – Paywall Exclusiva’
});
} else {
dataLayer.push({
‘event’: ‘subscriptions_buttons’,
‘action’: ‘click’,
‘label’:’comprar_assinatura’,
‘location’: ‘Assine já – Paywall Métrica’
});
}
break;
case “subscribe-button-ticker”:
const lastUrl = window.location.href;
localStorage.setItem(‘lastUrl’, lastUrl);
dataLayer.push({
‘event’: ‘subscriptions_buttons’,
‘action’: ‘click’,
‘label’:’comprar_assinatura’,
‘location’: ‘Assine já – Ticker’
});
break;
case “subscribe-button-aominuto”:
dataLayer.push({
‘event’: ‘subscriptions_buttons’,
‘action’: ‘click’,
‘label’:’comprar_assinatura’,
‘location’: ‘Assine já – Ao Minuto’
});
break;
case “subscribe-button-modal-jogos”:
dataLayer.push({
‘event’: ‘subscriptions_buttons’,
‘action’: ‘click’,
‘label’:’comprar_assinatura’,
‘location’: ‘Assine já – Modal Jogos’
});
break;
case “login-button-modal-jogos”:
dataLayer.push({
‘event’: ‘modal_jogos’,
‘clicked_zone’: ‘iniciar_sessao’
});
break;
case “subscribe-button-modal-ed-impressa”:
dataLayer.push({
‘event’: ‘subscriptions_buttons’,
‘action’: ‘click’,
‘label’:’comprar_assinatura’,
‘location’: ‘Assine já – Modal Ed. Impressa’
});
break;
case “login-button-modal-ed-impressa”:
dataLayer.push({
‘event’: ‘modal_ed-impressa’,
‘clicked_zone’: ‘iniciar_sessao’
});
break;
case “renew-button-myaccount”:
fetch(“/api/subscriptions/renew/link/get?userId=” + userOnPage.id).then(response => {
response.json().then(data => {
document.location = data.url
})
});
dataLayer.push({
‘event’: ‘renew_button’,
‘action’: ‘click’,
‘location’: ‘Renovar Assinatura’
});
break;
case “modal-legal-consent”:
if (userOnPage.userGuid || userOnPage.userId) {
fetch(“/utilizador/conta/” + (userOnPage.userGuid || userOnPage.userId) +”/mkt/true”, {
method: “post”,
credentials: “include”
});
}
dataLayer.push({
‘event’: ‘marketing_authorization_accepted’,
‘label’: ‘autorizar’
});
break;
case “modal-legal-consent-data-true”:
dataLayer.push({
‘event’: ‘registers_updatedata’,
‘label’: ‘marketing_true’
});
break;
case “modal-legal-consent-data-false”:
dataLayer.push({
‘event’: ‘registers_updatedata’,
‘label’: ‘marketing_false’
});
break;
case “cta-article-not-subscriber”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “bloco_fim_artigo”,
“action”: “click”,
“label”: “assine_ja”
});
break;
case “cta-article-is-subscriber”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “bloco_fim_artigo”,
“action”: “click”,
“label”: “saiba_mais”
});
break;
case “get-local-data”:
targetIframeAction();
break;
case “subscribe-button-paywall-campaign”:
if(tp.tags.includes(‘Multimédia’) && tp.contentSection.includes(‘Exclusivo’)) {
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “paywall_com_campanha_multimedia-exclusivo”,
“action”: “click”,
“label”: “comprar_assinatura”
});
} else if (tp.tags.includes(‘Multimédia’)){
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “paywall_com_campanha_multimedia-metrica”,
“action”: “click”,
“label”: “comprar_assinatura”
});
} else {
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “paywall_com_campanha”,
“action”: “click”,
“label”: “comprar_assinatura”
});
}
break;
case “modal-jogos-xadrez”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal_xadrez”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-jogos-palavras-cruzadas”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-palavras-cruzadas”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-jogos-mini-palavras-cruzadas”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-mini-palavras-cruzadas”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-jogos-sopa-de-letras”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-sopa-de-letras”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-jogos-bridge”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-bridge”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-jogos-antes-e-depois”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-antes-e-depois”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-area-leitor-exassinante-publico”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “banner-area-leitor-exassinante”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-area-leitor-registados”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “banner-area-leitor-registados”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-final-do-artigo-assinar”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “banner-final-artigo-assinar”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-final-do-artigo-saiba-mais”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “banner-final-artigo-saiba-mais”,
“action”: “click”,
“label”: “saiba_mais”
});
break;
case “cta-paywall-exclusiva-newsletter-autor-campanha”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “cta-paywall-exclusiva-newsletter-autor-campanha”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-paywall-exclusiva-newsletter-autor-design”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “cta-paywall-exclusiva-newsletter-autor-design”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-paywall-metrica-newsletter-autor-campanha”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “cta-paywall-metrica-newsletter-autor-campanha”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-paywall-metrica-newsletter-autor-design”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “cta-paywall-metrica-newsletter-autor-design”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-paywall-vantagens”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “cta-paywall-vantagens”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-estantep”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-estantep”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-edição-impressa-jornal-dia-diaria”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-edição-impressa-jornal-dia-diaria”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-edição-impressa-jornal-dia-assinar”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-edição-impressa-jornal-dia-assinar”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal-edição-impressa-jornal-arquivo”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal-edição-impressa-jornal-arquivo”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-area-leitor-exassinante-piano”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “cta-area-leitor-exassinante-piano”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “modal_fluxo_registo_newsletters_exclusivas”:
dataLayer.push({
“event”: “subscriptions_buttons”,
“location”: “modal_fluxo_registo_newsletters_exclusivas”,
“action”: “click”,
“label”: “comprar_assinatura”
});
break;
case “cta-final-do-artigo-oferecer-artigo”:
$(“#modal-exclusive-offer”).foundation(“open”);
break;
}
}]);
window.__tcfapiInterval = setInterval(function () {
if (typeof __tcfapi != “undefined”) {
__tcfapi(‘addEventListener’, 2, function (tcData, success) {
if (success && (tcData.eventStatus === ‘tcloaded’ || tcData.eventStatus === ‘useractioncomplete’)) {
clearInterval(window.__tcfapiInterval);
setTimeout(function () {
document.dispatchEvent(new Event(“pub.cmpReady”));
}, 500)
}
});
} else {
if (_tcfapiNotLoadedTiming != null) {
_tcfapiNotLoadedTiming += 100;
if (_tcfapiNotLoadedTiming > 10000) {
_tcfapiNotLoadedTiming = null;
var consentUserType = “anonymous”;
if (userOnPage.userId || userOnPage.userGuid) {
consentUserType = userOnPage.isSubscriber ? “assinante” : “registado”;
}
Publico.Track.Event(“CONSENT”, consentUserType, “blocked”);
}
}
}
}, 100);
window.EndRegistration = (source, data) => {
if (userOnPage.userGuid || userOnPage.userId) {
fetch(`/utilizador/perfil/${userOnPage.userGuid || userOnPage.userId}/updateNumber`, {
method: “post”,
credentials: “include”,
headers: {
‘Content-Type’: ‘application/json’
},
body: JSON.stringify({
firstName: data.fName,
lastName: data.lName,
mobile: data.phone,
allowMarketing: data.termsChecked
})
}).then(response => {
if (response.status == 200)
source.postMessage({ command: ‘registrationResult’, payload: { status: true, reason: “” } }, ‘*’);
else {
response.json().then(data => {
source.postMessage({
command: ‘registrationResult’,
payload: { status: false, reason: data.message ? data.message : “Erro ao actualizar dados, tente de novo” }
}, ‘*’);
});
}
});
}
}
var liveElements = document.querySelectorAll(“.video-element-live”);
if (liveElements.length > 0) {
var tag = document.createElement(‘script’);
tag.src = ”
var firstScriptTag = document.getElementsByTagName(‘script’)[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
function onPlayerReady(event) {
event.target.playVideo()
}
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING)
window.canRefresh = false;
else
window.canRefresh = true;
}
liveElements.forEach(el => {
el.addEventListener(“click”, ev => {
var parent = ev.target.parentElement;
var dataUrl = parent.dataset.url;
if (dataUrl) {
var reg = new RegExp(‘src=\\”(.*?)\\”‘)
var matches = reg.exec(dataUrl);
if (matches == null) return;
var uri = new URL(matches[1]);
var videoId = uri.pathname.split(“)[2];
ev.target.id = ‘frame-‘ + parent.id;
parent.querySelector(“.media-badge”).remove();
window.player = new YT.Player(ev.target.id, {
height: ev.target.offsetHeight,
width: ev.target.offsetWidth,
videoId: videoId,
playerVars: {
‘playsinline’: 1
},
events: {
‘onReady’: onPlayerReady,
‘onStateChange’: onPlayerStateChange
}
});
}
});
})
}