forked from DGNum/metis
Permet de basculer du partage en base64 à un partage normal
This commit is contained in:
parent
29bce486d2
commit
4a7414cb11
1 changed files with 27 additions and 8 deletions
|
@ -8,12 +8,24 @@
|
|||
|
||||
let isOpen = false;
|
||||
let isToastOpen = false;
|
||||
let isBinary = false;
|
||||
|
||||
let toastText = '';
|
||||
|
||||
const toggle = () => {
|
||||
isOpen = !isOpen;
|
||||
updateShareLink();
|
||||
};
|
||||
|
||||
const doShare = () => {
|
||||
navigator.clipboard
|
||||
.writeText(share)
|
||||
.then(() => (toastText = '<b>Lien de partage copié dans le presse-papier.</b>'))
|
||||
.catch(() => (toastText = 'Erreur de copie automatique.'))
|
||||
.finally((isToastOpen = true));
|
||||
};
|
||||
|
||||
const updateShareLink = () => {
|
||||
const loc = document.location;
|
||||
const search = new URLSearchParams();
|
||||
const api = calendar.getAPI();
|
||||
|
@ -26,18 +38,21 @@
|
|||
search.append('d', api.getDate().toISOString());
|
||||
}
|
||||
|
||||
const b64 = window.btoa(search.toString());
|
||||
if (isBinary) {
|
||||
const b64 = window.btoa(search.toString());
|
||||
|
||||
share = `${loc.origin}${loc.pathname}?b64=${b64}`;
|
||||
share = `${loc.origin}${loc.pathname}?b64=${b64}`;
|
||||
} else {
|
||||
share = `${loc.origin}${loc.pathname}${search.toString()}`;
|
||||
}
|
||||
};
|
||||
|
||||
const doShare = () => {
|
||||
navigator.clipboard
|
||||
.writeText(share)
|
||||
.then(() => (toastText = '<b>Lien de partage copié dans le presse-papier.</b>'))
|
||||
.catch(() => (toastText = 'Erreur de copie automatique.'))
|
||||
.finally((isToastOpen = true));
|
||||
const toggleBinary = () => {
|
||||
isBinary = !isBinary;
|
||||
updateShareLink();
|
||||
};
|
||||
|
||||
$: shareDataIcon = isBinary ? 'code-square' : 'code';
|
||||
</script>
|
||||
|
||||
<div class="share-toast">
|
||||
|
@ -63,6 +78,10 @@
|
|||
</ModalBody>
|
||||
|
||||
<ModalFooter>
|
||||
<span on:click={toggleBinary} class="flex-grow-1" title="Partager en base64">
|
||||
<Icon name={shareDataIcon} class="fs-5" />
|
||||
</span>
|
||||
|
||||
<Icon name="balloon-heart" class="text-danger fs-5" />
|
||||
<span class="fs-7">Propulsé par le Club Réseau de l'ENS</span>
|
||||
</ModalFooter>
|
||||
|
|
Loading…
Reference in a new issue