« MediaWiki:Common.js » : différence entre les versions
Apparence
Page créée avec « →Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. : var _paq = _paq || []; _paq.push([function() { var self = this;... » |
Aucun résumé des modifications |
||
| (4 versions intermédiaires par 2 utilisateurs non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */ | /* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */ | ||
/* Le code JavaScript pour la version mobile se trouve dans le fichier MediaWiki:Mobile.js */ | |||
function waitForCookieConsent(callback) { | |||
if (window.cookieConsent) { | |||
return callback(); | |||
} | } | ||
return setTimeout(() => waitForCookieConsent(callback), 100); | |||
}] | } | ||
_paq.push([' | |||
_paq.push([' | waitForCookieConsent(() => { | ||
( | if (window.cookieConsent.isConsentGiven('statistics')) { | ||
initMatomo(); | |||
_paq.push([' | } else { | ||
_paq.push([' | removeMatomo(); | ||
} | |||
g.type='text/javascript'; g.async=true; g.defer=true; g.src= | }); | ||
})(); | |||
function initMatomo() { | |||
window._paq = window._paq || []; | |||
const _paq = window._paq; | |||
_paq.push(['setDoNotTrack', false]); | |||
_paq.push(['rememberConsentGiven']); | |||
_paq.push(['setVisitorCookieTimeout', 33696000]); | |||
_paq.push(['setTrackerUrl', 'https://piwik2.inist.fr/piwik.php']); | |||
_paq.push(['setSiteId', '43']); | |||
_paq.push(['trackPageView']); | |||
_paq.push(['enableLinkTracking']); | |||
const d = document; | |||
const g = d.createElement('script'); | |||
const s = d.getElementsByTagName('script')[0]; | |||
g.type = 'text/javascript'; | |||
g.async = true; | |||
g.defer = true; | |||
g.src = 'https://piwik2.inist.fr/piwik.js'; | |||
g.id = 'matomo-script'; | |||
s.parentNode.insertBefore(g, s); | |||
} | |||
function removeMatomo() { | |||
const script = document.getElementById('matomo-script'); | |||
if (script) { | |||
script.remove(); | |||
} | |||
document.cookie.split(';').forEach((cookie) => { | |||
const cookieName = cookie.split('=').at(0).trim(); | |||
if (cookieName.startsWith('_pk_id') || cookieName.startsWith('_pk_ses') || cookieName === 'mtm_consent') { | |||
document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`; | |||
} | |||
}); | |||
} | |||
function backtotop() { | |||
const place = document.querySelector('div.mw-page-container'); | |||
const div = document.createElement('div'); | |||
const link = document.createElement('a'); | |||
div.setAttribute('class', 'back-to-top-wrapper'); | |||
link.setAttribute('class', 'back-to-top-link'); | |||
link.href = '#'; | |||
link.appendChild(document.createTextNode('\u2b9d')); | |||
div.appendChild(link); | |||
place.append(div); | |||
} | |||
backtotop(); | |||
Dernière version du 23 avril 2026 à 14:32
/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
/* Le code JavaScript pour la version mobile se trouve dans le fichier MediaWiki:Mobile.js */
function waitForCookieConsent(callback) {
if (window.cookieConsent) {
return callback();
}
return setTimeout(() => waitForCookieConsent(callback), 100);
}
waitForCookieConsent(() => {
if (window.cookieConsent.isConsentGiven('statistics')) {
initMatomo();
} else {
removeMatomo();
}
});
function initMatomo() {
window._paq = window._paq || [];
const _paq = window._paq;
_paq.push(['setDoNotTrack', false]);
_paq.push(['rememberConsentGiven']);
_paq.push(['setVisitorCookieTimeout', 33696000]);
_paq.push(['setTrackerUrl', 'https://piwik2.inist.fr/piwik.php']);
_paq.push(['setSiteId', '43']);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
const d = document;
const g = d.createElement('script');
const s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript';
g.async = true;
g.defer = true;
g.src = 'https://piwik2.inist.fr/piwik.js';
g.id = 'matomo-script';
s.parentNode.insertBefore(g, s);
}
function removeMatomo() {
const script = document.getElementById('matomo-script');
if (script) {
script.remove();
}
document.cookie.split(';').forEach((cookie) => {
const cookieName = cookie.split('=').at(0).trim();
if (cookieName.startsWith('_pk_id') || cookieName.startsWith('_pk_ses') || cookieName === 'mtm_consent') {
document.cookie = `${cookieName}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`;
}
});
}
function backtotop() {
const place = document.querySelector('div.mw-page-container');
const div = document.createElement('div');
const link = document.createElement('a');
div.setAttribute('class', 'back-to-top-wrapper');
link.setAttribute('class', 'back-to-top-link');
link.href = '#';
link.appendChild(document.createTextNode('\u2b9d'));
div.appendChild(link);
place.append(div);
}
backtotop();