notification_ok=0; mobile_admin=0; StatusBar_overlaysWebView=false; window.onerror = function (msg, url, noLigne, noColonne, erreur) { if(mobile_admin){ var chaine = msg.toLowerCase(); var souschaine = "script error"; if (chaine.indexOf(souschaine) > -1){ alert('Script Error : voir la Console du Navigateur pour les Détails'); } else { var message = [ 'Message : ' + msg, 'URL : ' + url, 'Ligne : ' + noLigne, 'Colonne : ' + noColonne, 'Objet Error : ' + JSON.stringify(erreur) ].join(' - '); alert(message); } } return false; }; var app = { initialize: function () { document.addEventListener('deviceready', this.onDeviceReady.bind(this), false); }, onDeviceReady: function () { isCordovaApp=1; window.open=cordova.InAppBrowser.open; permissions = cordova.plugins.permissions; device_platform = device.platform; device_uuid = device.uuid.toLowerCase(); device_serial = device.serial; device_cordova = device.cordova; device_manufacturer = device.manufacturer; device_model = device.model; device_version = device.version; device_isVirtual = (device.isVirtual?1:0); window.setInterval(function(){StatusBar.overlaysWebView(false);},500); StatusBar.overlaysWebView(false); $("[data-elementor-type=header]>section").css("padding-top","30px"); /* console = (function(oldCons){ return { log: function(text){ oldCons.log(text); window.plugins.toast.showLongBottom(text, null, null); }, info: function (text) { oldCons.info(text); window.plugins.toast.showLongBottom('Info : '+text, null, null); }, warn: function (text) { oldCons.warn(text); window.plugins.toast.showLongBottom('Attention : '+text, null, null); }, error: function (text) { oldCons.error(text); window.plugins.toast.showLongBottom('Erreur : '+text, null, null); } }; }(window.console)); */ window.alert = function (txt,title) { if(typeof title==="undefined"){ title="Ma Tatie"; } navigator.notification.alert(txt, null, title, "Ok"); } $(document).on('click', 'a[target]', function (e) { var url = $(this).attr('href'); var target = $(this).attr('target'); //navigator.app.loadUrl(url, { openExternal: true }); cordova.InAppBrowser.open(url,target, 'location=yes'); e.preventDefault(); }); document.addEventListener("backbutton", this.onBackKeyDown.bind(this), false); document.addEventListener("offline", this.onOffline.bind(this), false); document.addEventListener("online", this.onOnline.bind(this), false); if(notification_ok==1){ $(".div_notifications").attr("hidden",true); if(typeof cordova.plugins.firebase!=="undefined"){ cordova.plugins.firebase.messaging.getToken().then(function(token){ if(device_firebase!=token){ device_firebase = token; } }); cordova.plugins.firebase.messaging.onTokenRefresh(function(token){ if(device_firebase!=token){ device_firebase = token; } }); } } ready = 1; }, onOffline: function (e) { /* online = 0; $(".offline").removeAttr("hidden"); */ }, onOnline: function (e) { /* var networkState = navigator.connection.type; if (networkState !== Connection.NONE) { online = 1; $(".offline").attr("hidden", "true"); } */ }, onBackKeyDown: function (e) { // e.preventDefault(); }, }; app.initialize(); // Function to convert JSON data to HTML table function convert(jsonData,container) { // Create the table element let table = $(""); // Get the keys (column names) of the first object in the JSON data let cols = Object.keys(jsonData[0]); // Create the header element let thead = $(""); let tr = $(""); // Loop through the column names and create header cells $.each(cols, function(i, item){ let th = $(""); // Get the values of the current object in the JSON data let vals = Object.values(item); // Loop through the values and create table cells $.each(vals, (i, elem) => { let td = $("
"); th.text(item); // Set the column name as the text of the header cell tr.append(th); // Append the header cell to the header row }); thead.append(tr); // Append the header row to the header table.append(tr) // Append the header to the table // Loop through the JSON data and create table rows $.each(jsonData, function(i, item){ let tr = $("
"); td.text(elem); // Set the value as the text of the table cell tr.append(td); // Append the table cell to the table row }); table.append(tr); // Append the table row to the table }); container.append(table) // Append the table to the container element } Date.prototype.addHours = function(h) { this.setTime(this.getTime() + (h*60*60*1000)); return this; }; function isJsonString(str) { try { JSON.parse(str); } catch (e) { return false; } return true; } $(document).ready(function(){ if($(".tab_disponibilite").length>0){ if(typeof _dispos!="undefined" && _dispos!="" && _dispos!="[]"){ $(".tab_disponibilite>div").html(""); convert(_dispos,$(".tab_disponibilite>div")); } } if($(".tab_alaiseavec").length>0){ _a_laise_avec=$(".tab_alaiseavec>div").html(); if(_a_laise_avec!=""){ _a_laise_avec=_a_laise_avec.replaceAll("\n",""); _a_laise_avec=_a_laise_avec.replaceAll("\t",""); _a_laise_avec=_a_laise_avec.replaceAll('“','"'); _a_laise_avec=_a_laise_avec.replaceAll('”','"'); if(isJsonString(_a_laise_avec)){ _a_laise_avec=JSON.parse(_a_laise_avec); _a_laise_avec=_a_laise_avec.join(", "); $(".tab_alaiseavec>div").html(_a_laise_avec); } } } if($("body:not(.single-profils.author,._author) .fluent_form_26").length>0){ $('.fluent_form_26 [name^="jour_garde"]').addClass("text-center"); $('.fluent_form_26 [name="enfant[]"]').each(function(elt){ if($(this).val()=="" || $(this).val()=="[meta ID]"){ var loop=$(this); loop=loop.closest(".e-loop-item"); loop=loop.attr("class").split(/\s+/); loop=loop.filter((classe) => classe.startsWith('post-')); if(loop.length>0){ $(this).val(loop[0].replace("post-", "")); } } }); var jour_garde_max=0; fluent_form_26_nb_jours=0; interval_calcul=setInterval(function(){ var jour_garde=$('.fluent_form_26 td[data-label="Jours de la garde"] input[name^="jour_garde"]'); if(jour_garde.length!=fluent_form_26_nb_jours){ jour_garde.each(function(jour){ if(typeof $(this)[0]._flatpickr=="undefined"){ $('td[data-label="Nombre d\'heures"] [name^="jour_garde"]',$( this ).closest("tr")).attr("min",1).attr("value",1); $('td[data-label="Nombre d\'heures"] [name^="jour_garde"]',$( this ).closest("tr")).val(1); $( this ).flatpickr({ "locale": { "firstDayOfWeek": 1 }, "minDate" : "today", dateFormat: "d/m/Y", "disable":[ function(date_) { var retour=true; if(typeof _jours_off!="undefined"){ retour=_jours_off.includes(date_.getDay()); } return retour; } ], onChange: function(selectedDates, dateStr, instance){ var select_creneau_horaire=$('td[data-label="Créneau horaire"] select[name^="jour_garde"]',$( instance.element ).closest("tr")); select_creneau_horaire.children('option').removeAttr("disabled").removeAttr("selected"); if(dateStr!=""){ dateStr=instance.parseDate(dateStr, instance.config.dateFormat); var creneaux=_dispos; for (let i = 0; i < creneaux.length; i++) { creneaux[i].jour==jours[dateStr.getDay()]; } creneaux=_dispos.filter(item => item.jour.toLowerCase()==jours[dateStr.getDay()]); creneaux=creneaux.map(item => item.heure).filter((value, index, self) => self.indexOf(value) === index); select_creneau_horaire.children('option').each(function(){ if(!creneaux.includes($(this).attr("value"))){ $(this).attr("disabled",true); } }); var tmp=select_creneau_horaire.find(':selected'); if(select_creneau_horaire[0].selectedIndex<0 || tmp.prop('disabled')){ select_creneau_horaire.children('option:enabled').eq(0).prop('selected',true); } select_creneau_horaire.change(); } }, onReady: function(dateObj, dateStr, instance) { dateStr=new Date(); if(typeof _jours_on!="undefined"){ var next_dow=_jours_on.findIndex(function(dow) { return dow >= dateStr.getDay(); }); if(next_dow<0){ next_dow=0; next_dow=_jours_on.findIndex(function(dow) { return dow >= next_dow; }); } dateStr.setDate(dateStr.getDate() + (_jours_on[next_dow]+(7-dateStr.getDay())) % 7); instance.setDate(dateStr,true); } }, }); } }); if(fluent_form_26_nb_jours>jour_garde.length){ jour_garde.change(); } fluent_form_26_nb_jours=jour_garde.length; } //calcul(); },500); /*function calcul(){ var total=0; if($('.fluent_form_12').length>0){ total=0; $(".fluent_form_12 .bouton_prix_garde").addClass("disabled").attr("disabled",true); var debut=$('.fluent_form_12 input[name=debut]').val(); if(debut!==""){ var jour_debut=debut.split(" ")[0].split("/"); var heure_debut=debut.split(" ")[1].split(":"); debut=new Date(parseInt(jour_debut[2]),parseInt(jour_debut[1]-1),parseInt(jour_debut[0]),parseInt(heure_debut[0]),parseInt(heure_debut[1])); var duree=$('.fluent_form_12 input[name=duree]').val(); var fin=new Date(debut.getTime()); fin.addHours(duree); var bebe=Number($(".fluent_form_12 input[name=bebe]").val()); var enfant=Number($(".fluent_form_12 input[name=enfant]").val()); var total_enfants=(bebe+enfant); var tmp=new Date(debut.getTime()); for(var i=0;i0){ $(".fluent_form_12 .bouton_prix_garde").removeClass("disabled").removeAttr("disabled"); $(".fluent_form_12 .bouton_prix_garde").html("Envoyer la demande à "+parseFloat(total).toFixed(2)+"€"); } } if($('.fluent_form_26').length>0 && typeof(_jours)!="undefined"){ total=0; $(".fluent_form_26 .bouton_prix_garde").addClass("disabled").attr("disabled",true); var bebe=Number($(".fluent_form_26 input[name=bebe]").val()); var enfant=Number($(".fluent_form_26 input[name=enfant]").val()); var total_enfants=(bebe+enfant); var lignes=$(".fluent_form_26 table[data-root_name=jour_garde] tbody tr"); if(lignes.length>0){ lignes.each(function(index){ var prix=0; var jour_garde=$('td[data-label="Jours de la garde"] [name^=jour_garde]',$(this)).val(); // console.log("jour_garde "+jour_garde); var creneau_horaire=$('td[data-label="Créneau horaire"] [name^=jour_garde]',$(this)).val(); // console.log("creneau_horaire "+creneau_horaire); var debut=$('td[data-label="Début"] [name^=jour_garde]',$(this)).val(); // console.log("debut "+debut); var nombre_heures=$('td[data-label="Nombre d\'heures"] [name^=jour_garde]',$(this)).val(); // console.log("nombre_heures "+nombre_heures); if(jour_garde!="" && creneau_horaire!="" && debut!="" && nombre_heures!=""){ var jour_debut=jour_garde.split("/"); var heure_debut=debut.split(":"); jour_debut=new Date(parseInt(jour_debut[2]),parseInt(jour_debut[1]-1),parseInt(jour_debut[0]),parseInt(heure_debut[0]),parseInt(heure_debut[1])); for(var i=0;i0){ $(".fluent_form_26 .bouton_prix_garde").removeClass("disabled").removeAttr("disabled"); $(".fluent_form_26 .bouton_prix_garde").html("Envoyer la demande à "+parseFloat(total).toFixed(2)+"€"); } } }*/ $(document).on("keyup change",'.fluent_form_26 select,.fluent_form_26 input',function(e) { var form=$(this).closest("form"); $('[name^="jour_garde"],[name^="jour_garde"]',form).attr("required",true); $('b.prix',form).html("-"); $('bouton_prix_garde',form).attr("disabled",true); if($('[name="enfant[]"]:checked',form).length>0 && $(":invalid",form).length==0){ var data=form.serialize(); data+="&action=cout_total_garde&nonce="+nonce_cout_total_garde; try { fetch("https://web.matatie.app/wp-admin/admin-ajax.php" , { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: data, }) .then(response => response.json()) .then(body => { if(body.success){ $('b.prix',form).html(body.data); $(".bouton_prix_garde",form).html("Envoyer la demande à "+body.data+"€"); } $('bouton_prix_garde',form).removeAttr("disabled"); }); } catch (error) { $('bouton_prix_garde',form).removeAttr("disabled"); console.log(error); } } }); $(document).on("keyup change",'.fluent_form_26 td[data-label="Créneau horaire"] select[name^="jour_garde"],.fluent_form_26 td[data-label="Créneau horaire"] input[name^="jour_garde"],.fluent_form_26 td[data-label="Début"] input[name^="jour_garde"]',function(e) { var input_jour_garde=$('td[data-label="Jours de la garde"] [name^="jour_garde"]',$( this ).closest("tr")); var select_creneau_horaire=$('td[data-label="Créneau horaire"] [name^="jour_garde"]',$( this ).closest("tr")); var input_debut=$('td[data-label="Début"] [name^="jour_garde"]',$( this ).closest("tr")); var creneau_horaire=select_creneau_horaire.find(':selected').attr("value"); if(creneau_horaire!=""){ // creneau_horaire=creneau_horaire.toLowerCase(); var premiere_heure=Math.min.apply(null, _liste_heures[creneau_horaire]); var premiere_heure2=('0' + premiere_heure).slice(-2)+':00'; var derniere_heure=Math.max.apply(null, _liste_heures[creneau_horaire]); var derniere_heure2=('0' + derniere_heure).slice(-2)+":00"; } if(typeof input_debut[0]._flatpickr=="undefined"){ input_debut[0].flatpickr({ enableTime: true, noCalendar: true, dateFormat: "H:i", time_24hr: true, minTime:premiere_heure2, maxTime:derniere_heure2, defaultDate:premiere_heure2, onChange: function(dateObj, dateStr, instance) { dateObj=dateObj[0]; var select_creneau_horaire=$('td[data-label="Créneau horaire"] [name^="jour_garde"]',$( instance.element ).closest("tr")); var creneau_horaire=select_creneau_horaire.find(':selected').attr("value"); if(creneau_horaire!=""){ // creneau_horaire=creneau_horaire.toLowerCase(); } if(!_liste_heures[creneau_horaire].includes(dateObj.getHours())){ var next_heure=_liste_heures[creneau_horaire].findIndex(function(heure) { return heure >= dateObj.getHours(); }); if(next_heure<0){ next_heure=0; next_heure=_liste_heures[creneau_horaire].findIndex(function(heure) { return heure >= next_heure; }); } next_heure=_liste_heures[creneau_horaire][next_heure]; instance.setDate(('0' + next_heure).slice(-2)+":00"); console.log(('0' + next_heure).slice(-2)+":00"); dateObj=instance.latestSelectedDateObj; } var derniere_heure=Math.max.apply(null, _liste_heures[creneau_horaire]); var input_nombre_heures=$('td[data-label="Nombre d\'heures"] [name^="jour_garde"]',$( instance.element ).closest("tr")); input_nombre_heures.removeAttr("max"); var nombre_heures=input_nombre_heures.attr("value"); if(nombre_heures==""){ nombre_heures=1; } var max_nombre_heures=((derniere_heure+1)-dateObj.getHours()); if(max_nombre_heures==0){ max_nombre_heures=1; } input_nombre_heures.attr("max",max_nombre_heures); if(input_nombre_heures.attr("value")>max_nombre_heures){ input_nombre_heures.val(max_nombre_heures); input_nombre_heures.attr("value",max_nombre_heures); } }, onReady: function(dateObj, dateStr, instance) { dateObj=new Date(); $( instance.element ).attr("required",true); var select_creneau_horaire=$('td[data-label="Créneau horaire"] [name^="jour_garde"]',$( instance.element ).closest("tr")); var creneau_horaire=select_creneau_horaire.find(':selected').attr("value"); if(creneau_horaire!=""){ // creneau_horaire=creneau_horaire.toLowerCase(); } if(!_liste_heures[creneau_horaire].includes(dateObj.getHours())){ var next_heure=_liste_heures[creneau_horaire].findIndex(function(heure) { return heure >= dateObj.getHours(); }); if(next_heure<0){ next_heure=0; next_heure=_liste_heures[creneau_horaire].findIndex(function(heure) { return heure >= next_heure; }); } next_heure=_liste_heures[creneau_horaire][next_heure]; // console.log("next_heure",next_heure); instance.setDate(('0' + next_heure).slice(-2)+":00"); dateObj=instance.latestSelectedDateObj; } var derniere_heure=Math.max.apply(null, _liste_heures[creneau_horaire]); // console.log("derniere_heure",derniere_heure); // console.log("dateObj",dateObj); // console.log("getHours",dateObj.getHours()); var input_nombre_heures=$('td[data-label="Nombre d\'heures"] [name^="jour_garde"]',$( instance.element ).closest("tr")); input_nombre_heures.removeAttr("max"); var nombre_heures=input_nombre_heures.attr("value"); if(nombre_heures==""){ nombre_heures=1; } var max_nombre_heures=((derniere_heure+1)-dateObj.getHours()); if(max_nombre_heures==0){ max_nombre_heures=1; } input_nombre_heures.attr("max",max_nombre_heures); if(input_nombre_heures.attr("value")>max_nombre_heures){ input_nombre_heures.val(max_nombre_heures); } } }); } else{ // input_debut[0]._flatpickr.setDate(premiere_heure2); input_debut[0]._flatpickr.set("minTime",premiere_heure2); input_debut[0]._flatpickr.set("maxTime",derniere_heure2); input_debut.change(); } }); //calcul(); } var hash = $(location). attr('hash'); if(hash.startsWith("#popup_")){ if(hash.replace("#popup_", "") in _popups_){ if($("#"+hash.replace("#popup_", "")).length>0){ elementorProFrontend.modules.popup.showPopup( { id: _popups_[hash.replace("#popup_", "")] } ); } } } else{ if(hash.replace("#", "") in _popups_){ if($("#"+hash.replace("#", "")).length>0){ elementorProFrontend.modules.popup.showPopup( { id: _popups_[hash.replace("#", "")] } ); } } } }); var pwaInstall = document.getElementById("pwa-install"); // The install button. const installButton = document.querySelector('#installer'); if(installButton !== null){ // Only relevant for browsers that support installation. if ('BeforeInstallPromptEvent' in window) { // Variable to stash the `BeforeInstallPromptEvent`. let installEvent = null; // Function that will be run when the app is installed. const onInstall = () => { // Disable the install button. installButton.setAttribute("hidden",true); // No longer needed. installEvent = null; }; window.addEventListener('beforeinstallprompt', function(event){ // Do not show the install prompt quite yet. //event.preventDefault(); // Stash the `BeforeInstallPromptEvent` for later. installEvent = event; // Enable the install button. installButton.removeAttribute("hidden"); return false; }); installButton.addEventListener('click', async () => { pwaInstall.showDialog(true); /*// If there is no stashed `BeforeInstallPromptEvent`, return. if (!installEvent) { installButton.setAttribute("hidden",true); return false; } // Use the stashed `BeforeInstallPromptEvent` to prompt the user. installEvent.prompt().then((choiceResult) => { if (choiceResult.outcome === 'accepted') { onInstall(); } else { console.log(choiceResult.outcome); installButton.setAttribute("hidden",true); } });*/ return false; /*const result = await installEvent.userChoice; // If the user installs the app, run `onInstall()`. if (result.outcome === 'accepted') { onInstall(); }*/ }); // The user can decide to ignore the install button // and just use the browser prompt directly. In this case // likewise run `onInstall()`. window.addEventListener('appinstalled', () => { onInstall(); }); } } //stripe identity function verif_identite_stripe(){ if (Stripe) { var stripe = Stripe('pk_test_51OYpz9FtNwhDfn4PhGToGsu5doybxVg2MWs6Svmbvpl82PbW2liZmhUOYV4TBUuVAK6jZdVfvTJUr8mw4Onlv7Pl00MoNyQUeD'); // Call your backend to create the VerificationSession fetch('/create-verification-session', { method: 'POST', }) .then(function(response) { return response.json(); }) .then(function(verificationSession) { return stripe.verifyIdentity(verificationSession.client_secret); }) .then(function(result) { // If `verifyIdentity` fails due to a browser or network // error, you should display the localized error message to your // customer using `error.message`. if (result.error) { console.log(result); } }); } }