stream=null; notification_ok=0; mobile_admin=0; StatusBar_overlaysWebView=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); $("html").addClass("isCordovaApp"); //$("[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 = $("
"); 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;
}
async function getLocalStream() {
console.log("getLocalStream");
stream = await navigator.mediaDevices
.getUserMedia({ video: true, audio: true })
.then((stream_) => {
stream_.getTracks().forEach(function(track) {
track.stop();
});
})
.catch((err) => {
console.error("getLocalStream error: ",err);
});
}
$(document).ready(function(){
$=jQuery;
_popups_= new Array();
_popups_['test']=1602427;
_popups_['maj_description_enfant']=1595111;
_popups_['maj_besoins_particuliers']=1595103;
_popups_['maj_besoins_gardes']=1595090;
_popups_['popup_url']=1592562;
_popups_['modifier_email']=1592225;
_popups_['recharger_compte']=1591976;
_popups_['modifier_telephone']=1591719;
_popups_['modifier_adresse']=1591715;
_popups_['test']=1589782;
_popups_['joyeux-noel']=20380;
_popups_['maj_profil_enfant']=19491;
_popups_['demande-inscription']=16176;
_popups_['maj_qualifications']=11691;
_popups_['maj_experiences']=11689;
_popups_['maj_apropos']=11040;
_popups_['maj_alaiseavec']=10390;
_popups_['maj_disponibilites']=10382;
_popups_['menu']=41;
$(document).on('click', 'a[href$="/wp-login.php?action=logout"]', function (e) {
// e.preventDefault();
// e.stopPropagation();
return confirm("Veux-tu te déconnecter ?");
});
if($(".tab_disponibilite").length>0){
if(typeof _dispos!="undefined" && _dispos!="" && _dispos!="[]"){
$(".tab_disponibilite>div").html("");
convert(_dispos,$(".tab_disponibilite>div"));
}
}
if($(".tab_experience").length>0){
if($(".tab_experience>div").html().trim()!=""){
var tab_experience=$(".tab_experience>div").html().trim();
tab_experience=tab_experience.replaceAll("\n","");
tab_experience=tab_experience.replaceAll("\t","");
tab_experience=tab_experience.replaceAll('“','"');
tab_experience=tab_experience.replaceAll('”','"');
tab_experience=tab_experience.replaceAll('″','"');
if(isJsonString(tab_experience)){
$(".tab_experience>div").html("");
tab_experience=JSON.parse(tab_experience);
convert(tab_experience,$(".tab_experience>div"));
}
}
}
if($(".tab_qualifications").length>0){
if($(".tab_qualifications>div").html().trim()!=""){
var tab_qualifications=$(".tab_qualifications>div").html().trim();
tab_qualifications=tab_qualifications.replaceAll("\n","");
tab_qualifications=tab_qualifications.replaceAll("\t","");
tab_qualifications=tab_qualifications.replaceAll('“','"');
tab_qualifications=tab_qualifications.replaceAll('”','"');
tab_qualifications=tab_qualifications.replaceAll('″','"');
if(isJsonString(tab_qualifications)){
$(".tab_qualifications>div").html("");
tab_qualifications=JSON.parse(tab_qualifications);
convert(tab_qualifications,$(".tab_qualifications>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('”','"');
_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){
//si on trouve un loop d'enfants, on attribue une valeur de post_id à chaque checkbox pour qu'il soit pris en compte par Fluentform
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-", ""));
}
}
});
fluent_form_26_nb_jours=0;
interval_calcul=setInterval(function(){
var jour_garde=$('.fluent_form_26 td[data-label="Jour et heure 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",
inline:false,
enableTime: true,
dateFormat: "d/m/Y H:i",
minuteIncrement: 60,
time_24hr: true,
"disable":[
function(date_) {
var retour=true;
if(typeof _jours_off!="undefined"){
retour=_jours_off.includes(date_.getDay());
}
return retour;
}
],
onReady: function(dateObj, dateStr, instance) {
dateStr=new Date();
dateStr.setMinutes(00);
$( instance.element ).attr("required",true);
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);
dow=dateStr.getDay();
if(typeof _heures_on[dow]!="undefined"){
if(_heures_on[dow].indexOf(dateStr.getHours())<0){
dateStr.setHours(_heures_on[dow][0]);
instance.setDate(dateStr,true);
}
}
}
},
});
}
});
if(fluent_form_26_nb_jours>jour_garde.length){
jour_garde.change();
}
fluent_form_26_nb_jours=jour_garde.length;
}
},500);
$(document).on("keyup change drop paste",'.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 {
if(typeof controller_cout_total_garde!="undefined"){
controller_cout_total_garde.abort({ reason: 'canceled' });
}
controller_cout_total_garde = new AbortController();
fetch("/wp-admin/admin-ajax.php" , {
signal: controller_cout_total_garde.signal,
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);
}
}
});
}
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("#", "")] } );
}
}
}
$(document).on('click', 'a[target="#popup_url"]', function (e) {
e.preventDefault();
var url = $(this).attr('href');
var target = $(this).attr('target');
if(typeof target!="undefined"){
target=target.replace("#", "");
console.log(target);
if(target in _popups_){
console.log(_popups_[target]);
elementorProFrontend.modules.popup.showPopup( { id: _popups_[target] } );
$(".elementor-"+_popups_[target]+" iframe").attr("src",url);
}
}
});
$(document).on('click', 'a.set_stripe_customer_card_defaut[data-cus][data-ca]', function (e) {
// e.preventDefault();
var retour=false;
var customer = $(this).attr('data-cus');
var card = $(this).attr('data-ca');
if(typeof customer!="undefined" && typeof card!="undefined"){
if(confirm("Définir cette carte par défaut?")){
$(this).attr("href","/transactions/?set_stripe_customer_card_defaut=1&cus="+customer+"&ca="+card);
retour=true;
}
}
return retour;
});
$(document).on('click', 'a.delete_stripe_customer_card[data-cus][data-ca]', function (e) {
//e.preventDefault();
var customer = $(this).attr('data-cus');
var card = $(this).attr('data-ca');
if(typeof customer!="undefined" && typeof card!="undefined"){
if(confirm("Le moyen de paiement ne sera plus utilisable après sa suppression.\nContinuer?")){
$(this).attr("href","/transactions/?delete_stripe_customer_card=1&cus="+customer+"&ca="+card);
return true;
}
}
return false;
});
jQuery( document ).on( 'elementor/popup/show', ( event,id,instance ) => {
event.preventDefault();
let link = event.currentTarget.activeElement;
//si c'est la popup iframe
if ( id === 1592562 ) {
var url = $(link).attr('data-url');
if (!(typeof url != 'undefined' && url !== false)){
if(typeof $(link).attr('href') != 'undefined'){
url = $(link).attr('href').replace("#popup_", "");
}
}
if (typeof url != 'undefined' && url !== false) {
$(".elementor-"+id+" iframe").attr("src",url);
}
}
} );
jQuery( document ).on( 'elementor/popup/hide', ( event,id,instance ) => {
//si c'est la popup iframe
if ( id === 1592562 ) {
$("iframe",instance).attr("src","about:blank");
}
} );
// $(document).on('click', '.verif_identite_stripe', function (e) {
// e.preventDefault();
// verif_identite_stripe();
// });
var timeout_google_autocomplete=window.setInterval(function(){
$=jQuery;
if($("input.google_autocomplete:not(.pac-target-input)").length>0 && typeof google === 'object' && typeof google.maps === 'object'){
var options = {
types: ["address"],
};
$('input.google_autocomplete:not(.pac-target-input)').each(function(i, obj) {
new google.maps.places.Autocomplete(obj,options);
});
}
},700);
//tooltip maison qui s'applique à tous les éléments qui ont l'attribut title
$("*[title]").on("mouseover", function(e) {
var styles = window.getComputedStyle(this,':before');
let ww = Math.max(document.documentElement.clientWidth, window.innerWidth || 0);
let hw = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
let x = parseFloat(e.clientX);
let y = parseFloat(e.clientY);
let w = parseFloat(styles['width'].replace("px",""));
let h = parseFloat(styles['height'].replace("px",""));
//trop bas
if(y +h>hw){
$(this).css("--title-top","auto");
$(this).css("--title-bottom","100%");
}
//trop à droite
if(x +w>ww){
$(this).css("--title-left","auto");
$(this).css("--title-right","50%");
}
});
wp.hooks.addFilter('better_messages_messages_list_before', 'custom_action', function(html, thread){
// Get access to thread data
// console.log( thread );
// Add custom html
html += '\
\
Prudence! Fais preuve de prudence quand on te demande ou qu\'on t\'envoie un numéro de téléphone / e-mail. Ici, nous garantissons la sécurité des échanges, c\'est pourquoi je te conseille de rester sur la messagerie pour échanger et de passer par le paiement sécurisé pour tes gardes.\
En savoir plus...\
';
return html;
});
});
if(typeof window.Better_Messages!="undefined"){
// window.Better_Messages.realtime = 0;
window.Better_Messages.ws = {};
window.Better_Messages.socket_server = false;
}
document.addEventListener("DOMContentLoaded", () => {
maj_Better_Messages=setInterval(function(){
if(typeof window.Better_Messages!="undefined"){
clearInterval(maj_Better_Messages);
// window.Better_Messages.realtime = 0;
window.Better_Messages.ws = {};
window.Better_Messages.socket_server = false;
}
},200);
});
var pwaInstall = document.getElementById("pwa-install");
// The install button.
const installButton = document.querySelector('#installer');
if(0 && 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 (typeof Stripe !="undefined") {
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);
}
});
}
} |