-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b0e320c
commit c2bee6c
Showing
2 changed files
with
21 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,16 +4,16 @@ | |
(function maintainanceDialog() { | ||
// CONFIGURER ICI | ||
const config = { | ||
// CEST = heure d'été (+0200), CET = heure d'hiver (). | ||
selectedTz: 'CEST', | ||
// CEST = heure d'été (+0200), CET = heure d'hiver (+0100). | ||
selectedTz: 'CET', | ||
|
||
// Date du début de la maintenance | ||
startDateWithoutTimezone: '2024-04-10T13:00:00', | ||
startDateWithoutTimezone: '2024-11-14T17:00:00', | ||
|
||
// Durée de la maitenance prévue (en minutes). | ||
// ASTUCE: Si la maintenance dure moins longtemps que prévu, réduire a postériori la valeur de cette variable de sorte à ce qu'elle n'apparaisse plus. | ||
// Pas besoin de committer ensuite le changement dans le repo. | ||
maintainanceDurationMinutes: 60, | ||
maintainanceDurationMinutes: 180, | ||
}; | ||
// FIN CONFIGURER | ||
|
||
|
@@ -40,11 +40,13 @@ | |
timeZone: 'Europe/Paris', | ||
}); | ||
|
||
const contactMail = "[email protected]" | ||
|
||
dialog.innerHTML = ` | ||
<p> | ||
Une maintenance de Grist est prévue le ${dateFormatter.format(maintainanceStartDate)} heure de Paris | ||
jusqu'à ${timeFormatter.format(maintainanceEndDate)}, période durant laquelle le service sera momentanément indisponible. <br> | ||
Pour toute remarque ou question, merci de nous contacter via <a href="mailto:[email protected]">[email protected]</a></p> | ||
jusqu'à ${timeFormatter.format(maintainanceEndDate)}, période durant laquelle le service sera indisponible.<br> | ||
Pour toute remarque ou question, merci de nous contacter via <a href="${contactMail}">${contactMail}</a></p> | ||
<p>Merci de votre compréhension</p> | ||
<form method="dialog"> | ||
<p> | ||
|
@@ -68,58 +70,6 @@ | |
(!localStorage.maintainanceStartDateAgreement || localStorage.maintainanceStartDateAgreement !== maintainanceStartDate.toISOString())) { | ||
window.addEventListener('load', showMaitainanceDialog); | ||
} | ||
|
||
/** | ||
* Creates a link (anchor element) given the text and the href (link) passed. | ||
* We use this method to prevent XSS injection. | ||
*/ | ||
function makeLink(text, href) { | ||
const a = document.createElement('a'); | ||
a.textContent = text; | ||
a.href = href; | ||
a.target = "_blank"; | ||
a.rel = 'nofollow'; | ||
return a; | ||
} | ||
|
||
function showAgreementDialog() { | ||
const { termsOfServiceUrl } = window.gristConfig; | ||
if (!termsOfServiceUrl) { | ||
return; | ||
} | ||
|
||
const dialog = document.createElement('dialog'); | ||
dialog.id = 'agreementPopin'; | ||
const cguLinkHtml = makeLink("les conditions d'utilisation", termsOfServiceUrl).outerHTML; | ||
dialog.innerHTML = ` | ||
<p> | ||
Veuillez accepter ${cguLinkHtml} de Grist avant de continuer. | ||
</p> | ||
<p> | ||
Vous pourrez les retrouvez à tout moment via le lien en bas<br> | ||
à gauche de la page d'accueil de Grist. | ||
</p> | ||
<form method="dialog"> | ||
<p> | ||
<input type="checkbox" id="jaccepte"> | ||
<label for="jaccepte">J'ai lu et j'accepte sans réserve ${cguLinkHtml}</label> | ||
</p> | ||
<button disabled id="fermerPopinAgreement">Poursuivre sur Grist</button> | ||
</form> | ||
`; | ||
document.body.appendChild(dialog); | ||
document.getElementById('fermerPopinAgreement').onclick = function onMessageUnderstood() { | ||
localStorage.gcuAgreementDate = new Date().toISOString(); | ||
} | ||
document.getElementById('jaccepte').onchange = function (ev) { | ||
document.getElementById('fermerPopinAgreement').disabled = !ev.target.checked; | ||
} | ||
dialog.showModal(); | ||
} | ||
|
||
if (!localStorage.gcuAgreementDate) { | ||
window.addEventListener('load', showAgreementDialog); | ||
} | ||
})(); | ||
|
||
// ======================== | ||
|
@@ -138,15 +88,15 @@ window.addEventListener('load', async (event) => { | |
return; | ||
} | ||
// appObs is not populated at that point, listen for the observer to their first change | ||
let listener; | ||
let listener; | ||
listener = appObs.addListener( async (appObs) => { | ||
// Gauffre must be displayed only in home pages | ||
if (appObs.pageType.get() !== "home"){ | ||
return 1; | ||
} | ||
// We wait for header bar to be available in DOM to insert Gauffre in it | ||
await waitForElm('.test-top-header'); | ||
|
||
// Create gauffre button Tag | ||
const gristBar = document.getElementsByClassName('test-top-header')[0]; | ||
const gauffreDiv = document.createElement('div'); | ||
|
@@ -169,7 +119,7 @@ window.addEventListener('load', async (event) => { | |
gauffreScript.setAttribute('defer', true); | ||
gauffreScript.src = "https://integration.lasuite.numerique.gouv.fr/api/v1/gaufre.js"; | ||
document.head.insertBefore(gauffreScript, document.head.lastChild); | ||
|
||
// Should be disposed so we only listen for changes once, but failed to achieve doing that. | ||
// listener.dispose(); | ||
}); | ||
|