2020-09-07 18:37:19 +02:00
|
|
|
// -- GESTION DE LA PAGE DU FINANCEMENT PARTICIPATIF (SANS DEVOIR ÊTRE CONNECTÉ)
|
|
|
|
|
|
|
|
/// Permet d'afficher les boutons de paiement WP suivant le choix de l'utilisateur.
|
2020-10-06 16:34:17 +02:00
|
|
|
/// Matomo est également activé si l'internaute n'est pas connecté.
|
2020-09-07 18:37:19 +02:00
|
|
|
|
|
|
|
// Fichier de configuration tirés du backend :
|
|
|
|
import { availableLangs, theme } from "../../config/instance.js";
|
|
|
|
const lang=availableLangs[0];
|
|
|
|
|
|
|
|
const configTemplate = require("../../views/"+theme+"/config/"+lang+".js");
|
|
|
|
|
|
|
|
// Fonctions utiles au script :
|
|
|
|
import { getLocaly } from "./tools/clientstorage.js";
|
|
|
|
import { helloDev, updateAccountLink } from "./tools/everywhere.js";
|
|
|
|
import { loadMatomo } from "./tools/matomo.js";
|
|
|
|
import { checkSession } from "./tools/users.js";
|
|
|
|
import { showBtnPayment, unCheckAllOthers } from "./tools/webportage.js";
|
|
|
|
|
|
|
|
helloDev();
|
|
|
|
|
|
|
|
const initialise = async () =>
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
const isConnected=await checkSession();
|
|
|
|
if(isConnected)
|
|
|
|
{
|
|
|
|
// on change le lien du compte en haut :
|
|
|
|
const user=getLocaly("user", true);
|
|
|
|
updateAccountLink(user.status, configTemplate);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
loadMatomo();
|
|
|
|
|
|
|
|
// Les boutons de paiement WP :
|
|
|
|
const CGV=document.getElementById("CGVOk");
|
2020-12-07 18:07:01 +01:00
|
|
|
const abo1=document.getElementById("abo1");
|
|
|
|
const abo2=document.getElementById("abo2");
|
|
|
|
const abo3=document.getElementById("abo3");
|
|
|
|
const abo4=document.getElementById("abo4");
|
2020-09-07 18:37:19 +02:00
|
|
|
const divWPBtns=document.getElementById("WPBtns");
|
|
|
|
divWPBtns.style.display="none";
|
2020-12-07 18:07:01 +01:00
|
|
|
abo1.addEventListener("change", function(e)
|
2020-09-07 18:37:19 +02:00
|
|
|
{
|
2020-12-07 18:07:01 +01:00
|
|
|
unCheckAllOthers("abo1");
|
2020-09-07 18:37:19 +02:00
|
|
|
});
|
2020-12-07 18:07:01 +01:00
|
|
|
abo2.addEventListener("change", function(e)
|
2020-09-07 18:37:19 +02:00
|
|
|
{
|
2020-12-07 18:07:01 +01:00
|
|
|
unCheckAllOthers("abo2");
|
2020-09-07 18:37:19 +02:00
|
|
|
});
|
2020-12-07 18:07:01 +01:00
|
|
|
abo3.addEventListener("change", function(e)
|
2020-09-07 18:37:19 +02:00
|
|
|
{
|
2020-12-07 18:07:01 +01:00
|
|
|
unCheckAllOthers("abo3");
|
2020-09-07 18:37:19 +02:00
|
|
|
});
|
2020-12-07 18:07:01 +01:00
|
|
|
abo4.addEventListener("change", function(e)
|
2020-09-07 18:37:19 +02:00
|
|
|
{
|
2020-12-07 18:07:01 +01:00
|
|
|
unCheckAllOthers("abo4");
|
2020-09-07 18:37:19 +02:00
|
|
|
});
|
|
|
|
CGV.addEventListener("change", function(e)
|
|
|
|
{
|
|
|
|
if(CGV.checked===true)
|
|
|
|
{
|
|
|
|
divWPBtns.style.display="block";
|
2020-12-07 18:07:01 +01:00
|
|
|
if(abo1.checked===true)
|
|
|
|
showBtnPayment("btn1");
|
|
|
|
else if(abo2.checked===true)
|
|
|
|
showBtnPayment("btn2");
|
|
|
|
else if(abo3.checked===true)
|
|
|
|
showBtnPayment("btn3");
|
|
|
|
else if(abo4.checked===true)
|
|
|
|
showBtnPayment("btn4");
|
2020-09-07 18:37:19 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
divWPBtns.style.display="none";
|
|
|
|
CGV.checked=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
divWPBtns.style.display="none";
|
|
|
|
});
|
|
|
|
}
|
|
|
|
catch(e)
|
|
|
|
{
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
initialise();
|