+$(document).ready(function () { $("#modalPopRegistration").on("hide.bs.modal", function () { var retrievedPopupRegistration = localStorage.getItem('popRegistration'); var pop = JSON.parse(retrievedPopupRegistration); pop.close += 1; localStorage.setItem('popRegistration', JSON.stringify(pop)); }); $('body').click(function (event) { if(!$(event.target).closest('#modalPopRegistration').length && !$(event.target).is('#modalPopRegistration')) { $(".modalDialog").hide(); } }); }); function showModalRegistration(lang) { console.log('ici') // var popImages = \[{ // img: 'https://ws-public-images.s3.amazonaws.com/Prod/webSaver/images/websaver\_popup\_1\_'+lang+'.jpg', // script: { // en: gtag('event', 'click', { 'event\_label': 'EN Pop Up 1', 'event\_category': 'Contest', 'value': 1 }), // fr: gtag('event', 'click', { 'event\_label': 'FR Pop Up 1', 'event\_category': 'Contest', 'value': 1 }), // }, // }, { // img: 'https://ws-public-images.s3.amazonaws.com/Prod/webSaver/images/websaver\_popup\_2\_'+lang+'.jpg', // script: { // en: gtag('event', 'click', { 'event\_label': 'EN Pop Up 2', 'event\_category': 'Contest', 'value': 2 }), // fr: gtag('event', 'click', { 'event\_label': 'FR Pop Up 2', 'event\_category': 'Contest', 'value': 2 }), // }, // }, { // img: 'https://ws-public-images.s3.amazonaws.com/Prod/webSaver/images/websaver\_popup\_3\_'+lang+'.jpg', // script: { // en: gtag('event', 'click', { 'event\_label': 'EN Pop Up 3', 'event\_category': 'Contest', 'value': 3 }), // fr: gtag('event', 'click', { 'event\_label': 'FR Pop Up 3', 'event\_category': 'Contest', 'value': 3 }), // }, // }\]; // var randomNumber = Math.floor(Math.random() \* 3); // $('#popRegistrationImg').attr('src', popImages\[randomNumber\].img); // var el = document.getElementById('clickRegistrationPopup'); // el.onclick = popImages\[randomNumber\].script\[lang\]; var retrievedPopupRegistration = localStorage.getItem('popRegistration'); if (retrievedPopupRegistration === null) { var pop = {date: Date.now(), endDate: Date.now() + (86400000 \* 7), close: 1}; localStorage.setItem('popRegistration', JSON.stringify(pop)); } var retrievedPopupRegistration = localStorage.getItem('popRegistration'); if (retrievedPopupRegistration != null) { var pop = JSON.parse(retrievedPopupRegistration); if (pop.close < 3 && pop.endDate >= Date.now()) { setTimeout(function () { $('#modalPopRegistration').modal(); }, 12000); } } }
0 commit comments