var getUrlParameter = function getUrlParameter(sParam) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split("&"), sParameterName, i; for (i = 0; i < sURLVariables.length; i++) { sParameterName = sURLVariables[i].split("="); if (sParameterName[0] === sParam) { return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]); } } } var style = document.createElement('style'); style.innerHTML = "#SASwrapper { position: relative; } \n" + "#SASwrapper .mailguide-extend {display:none;}\n"+ "#SASwrapper .SASwrapperOverlay {position:absolute; top:0;left:0;bottom:0;right:0; width: 100%;height:100%; backdrop-filter: blur(6px); z-index: 10000;background-color:rgba(255,255,255,0.6); display:block; } \n" + "#SASwrapper #mySASForm label{ display: inline-block; width: 100px; text-align: right;} \n" + "#SASwrapper .error_show{ color: red; margin-left: 10px;} \n" + "#SASwrapper input.invalid, #SASwrapper textarea.invalid{ border-bottom: 1px solid red !important;} \n" + "#SASwrapper .mailguide-form .login-inputs input[type=email].valid, input.valid, textarea.valid{ border-bottom: 1px solid green;} \n" + "#SASwrapper div.response p { min-height: 1rem;} \n" + "#SASwrapper div.login-inputs { min-height: 175px;} \n" + "#SASwrapper .pl-3 { padding-left: 30px;} \n" + "#content #SASwrapper button.btnConfirm { margin-top: 2rem;} \n" + "#SASwrapper .mailguide-form .response-wrapper .response { display: none; }\n"; document.head.appendChild(style); var recipient = getUrlParameter('recipient'); var id = getUrlParameter('id'); var LOGGED = 0; var LANG = 'sk'; if (recipient && id) { LOGGED = 1; } $(document).ready(function () { $(document).on('change','#SASwrapper .checkbox.pri',function() { if (this.checked) { $('.checkbox.sec').prop( "checked","checked"); } }); $(document).on('click','#SASwrapper .mailguide-form.mailguide-management button.btnSubmit',function(e) { e.preventDefault(); $('#SASwrapper form.mailguide-form.mailguide-management .response').html(' '); var form_data=$("#SASwrapper form.mailguide-form.mailguide-management").serializeArray(); $.ajax({ url: "/wp-content/themes/eyof/zozzi/newsletter-api.php", type: "post", data: form_data, success: function (response) { if (response.success) { if (LANG=='en') $('#SASwrapper form.mailguide-form.mailguide-management .response').html('

Nastavenie odberu noviniek bolo zmenené.

'); else $('#SASwrapper form.mailguide-form.mailguide-management .response').html('

Nastavenie odberu noviniek bolo zmenené.

'); } else { $('#SASwrapper form.mailguide-form.mailguide-management .response').html(' '); } } }); }); $(document).on('click','#SASwrapper button.btn.logout',function(e) { e.preventDefault(); $.ajax({ url: "/wp-content/themes/eyof/zozzi/newsletter-api.php", type: "post", data: {action: 'logout', id: id, recipient: recipient}, success: function (response) { location.href='?'; } }); }); $(document).on('click','#SASwrapper .mailguide-form.mailguide-extend button.btnSubmit',function(e) { e.preventDefault(); $('#SASwrapper form.mailguide-form.mailguide-extend .response').html(' '); var form_data=$("#SASwrapper form.mailguide-form.mailguide-extend").serializeArray(); $.ajax({ url: "/wp-content/themes/eyof/zozzi/newsletter-api.php", type: "post", data: form_data, success: function (response) { if (response.success) { if (LANG=='en') $('#SASwrapper form.mailguide-form.mailguide-extend .response').html('

Predĺženie súhlasu bolo zmenené.

'); else $('#SASwrapper form.mailguide-form.mailguide-extend .response').html('

Predĺženie súhlasu bolo zmenené.

'); } else { $('#SASwrapper form.mailguide-form.mailguide-extend .response').html(' '); } } }); }); $(document).on('click','#SASwrapper .mailguide-form.mailguide-login button.btnSubmit',function(e) { e.preventDefault(); if (!$('#SASwrapper .mailguide-form.mailguide-login input#suhlasForm').is(':checked')) { $('#SASwrapper .mailguide-form.mailguide-login label.checkbox').addClass('error'); return false; } if (emailIsValid($('#mySASFormEmail').val())) { $('#mySASFormEmail').removeClass('error'); } else { $('#mySASFormEmail').addClass('error'); console.log('no email'); return false; } var form_data=$("#SASwrapper #mySASForm").serializeArray(); $.ajax({ url: "/wp-content/themes/eyof/zozzi/newsletter-api.php", type: "post", data: form_data, success: function (response) { if (response.success) { if (LANG=='en') $('#SASwrapper #mySASForm .response').html('

We just sent a link to your email address to subscribe to and set up to receive our newsletter.

'); else $('#SASwrapper #mySASForm .response').html('

Na vašu emailovú adresu sme práve odoslali odkaz pre prihlásenie a nastavenie odberu noviniek.

'); $('#SASwrapper #mySASForm button.btnSubmit').hide(); $('#SASwrapper #mySASForm .inputSuhlas').hide(); } } }); }); function emailIsValid (email) { return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email) } }); if (LOGGED) { (function () { $('#SASwrapper .SASwrapperOverlay').show(); $('#SASwrapper button').prop('disabled',true); $.ajax({ url: "/wp-content/themes/eyof/zozzi/newsletter-api.php", type: "post", cache: false, data: {recipient: recipient, id: id, action: 'info'}, success: function (response) { if (response.success) { $('#SASwrapper .SASwrapperOverlay').hide(); $.each(response.settings, function (k,v) { if (v) { // true = checked $('#'+k).prop('checked',true); } else { // false = uncheck $('#'+k).prop('checked',false); } }); $('#SASwrapper button').prop('disabled',false); if (response.settings.isNew) { $('#SASwrapper .review-subscription').show().html('Gratulujeme!'); $('#SASwrapper .review-subscription-info').show(); } else { if (LANG=='en') { $('#SASwrapper .review-subscription').html('Your subscription is active'); } else { $('#SASwrapper .review-subscription').html('Ste prihlásený na odber noviniek'); } $('#SASwrapper .review-subscription-info').hide(); } } else { location.href='?'; } } }); })(); var str = '
' + '
' + '
' + '
' + '
' + ' ' + '
' + '
' + '

Gratulujeme!

' + '

Zaregistrovali ste sa na odber noviniek.
Nastavte si témy na odber podľa svojich preferencií.

' + '
' + '
' + ' ' + '
' + '
' + '
' + ' ' + ' ' + ' ' + ' ' + '
'; if (LANG=='en') { str +=' Your themes of intereset'; } else { str +=' Ponúkané témy'; } str += '
'; if (LANG=='en') { str += '

Please select :

'; } else { str += '

Vyberte si témy, ktoré vás zaujímajú:

'; } str += '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
' + '
 
' + '
' + '
' + ' ' + ' ' + '
' + ' Predĺženie súhlasu' + '

Tu môžete predĺžiť svoj odber noviniek:

' + '
' + ' ' + ' ' + ' ' + ' ' + '
' + '
 
' + ' ' + '
' + '
' + '
' + '
'; '
'; var Obj = document.getElementById('SASwrapper'); //any element to be fully replaced } else { //Vaše prihlásenie vypršalo. if (LANG=='en') { text = 'Please, enter your email address for newsletter subscription management'; email_txt = 'Your email address'; udaje = 'I agree with the processing of personal data'; confirm = 'Confirm'; } else { text = 'Zadajte emailovú adresu pre správu odberu noviniek'; udaje = 'Súhlasím so spracúvaním osobných údajov'; email_txt = 'Vaša emailová adresa'; confirm = 'Potvrdiť'; } var str = '
' + '

' + text + '

' + '' + '
' + '
'; var Obj = document.getElementById('wrapperOdberNoviniek'); //any element to be fully replaced } if(Obj.outerHTML) { //if outerHTML is supported Obj.outerHTML=str; ///it's simple replacement of whole element with contents of str var } else { //if outerHTML is not supported, there is a weird but crossbrowsered trick var tmpObj=document.createElement("div"); tmpObj.innerHTML=''; ObjParent=Obj.parentNode; //Okey, element should be parented ObjParent.replaceChild(tmpObj,Obj); //here we placing our temporary data instead of our target, so we can find it then and replace it into whatever we want to replace to ObjParent.innerHTML=ObjParent.innerHTML.replace('
',str); }