64 lines
2.2 KiB
JavaScript
64 lines
2.2 KiB
JavaScript
// -- SCRIPT DE BASE APPELÉ DANS LES PAGES TYPE ACCUEIL DU SITE
|
|
|
|
// 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");
|
|
|
|
import { getLocaly } from "./tools/clientstorage.js";
|
|
import { helloDev, updateAccountLink } from "./tools/everywhere.js";
|
|
import { checkSession } from "./tools/users.js";
|
|
|
|
helloDev();
|
|
|
|
// Test de connexion de l'utilisateur pour adapter le lien du menu...
|
|
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
|
|
{
|
|
// chargement de matomo
|
|
var _paq = window._paq = window._paq || [];
|
|
//ajout cnil :
|
|
_paq.push([function()
|
|
{
|
|
var self = this;
|
|
function getOriginalVisitorCookieTimeout()
|
|
{
|
|
var now = new Date(),
|
|
nowTs = Math.round(now.getTime() / 1000),
|
|
visitorInfo = self.getVisitorInfo();
|
|
var createTs = parseInt(visitorInfo[2]);
|
|
var cookieTimeout = 33696000; // 13 mois en secondes
|
|
var originalTimeout = createTs + cookieTimeout - nowTs;
|
|
return originalTimeout;
|
|
}
|
|
this.setVisitorCookieTimeout( getOriginalVisitorCookieTimeout() );
|
|
}]);
|
|
//--fin ajout cnil
|
|
_paq.push(['trackPageView']);
|
|
_paq.push(['enableLinkTracking']);
|
|
(function() {
|
|
var u="https://stats.le-fab-lab.com/";
|
|
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
|
_paq.push(['setSiteId', '5']);
|
|
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
|
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
|
})();
|
|
}
|
|
}
|
|
catch(e)
|
|
{
|
|
console.error(e);
|
|
}
|
|
}
|
|
initialise(); |