WikiLerni/front/src/paymentPage.js

87 lines
2.8 KiB
JavaScript

// -- 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.
/// Matomo est également activité son internaute non connecté.
// 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");
const abo9=document.getElementById("abo9");
const abo18=document.getElementById("abo18");
const abo36=document.getElementById("abo36");
const abo54=document.getElementById("abo54");
const divWPBtns=document.getElementById("WPBtns");
divWPBtns.style.display="none";
abo9.addEventListener("change", function(e)
{
unCheckAllOthers("abo9");
});
abo18.addEventListener("change", function(e)
{
unCheckAllOthers("abo18");
});
abo36.addEventListener("change", function(e)
{
unCheckAllOthers("abo36");
});
abo54.addEventListener("change", function(e)
{
unCheckAllOthers("abo54");
});
CGV.addEventListener("change", function(e)
{
if(CGV.checked===true)
{
divWPBtns.style.display="block";
if(abo9.checked===true)
showBtnPayment("btn9");
else if(abo18.checked===true)
showBtnPayment("btn18");
else if(abo36.checked===true)
showBtnPayment("btn36");
else if(abo54.checked===true)
showBtnPayment("btn54");
else
{
divWPBtns.style.display="none";
CGV.checked=false;
}
}
else
divWPBtns.style.display="none";
});
}
catch(e)
{
console.error(e);
}
}
initialise();