mirror of
https://framagit.org/JonathanMM/sutom.git
synced 2024-04-30 13:12:56 +02:00
Fix #45 . Utilisation de l'api share si clipboard n'est pas disponible
This commit is contained in:
parent
115f28c45f
commit
d5509a5bef
|
@ -58,12 +58,21 @@ export default class FinDePartiePanel {
|
||||||
let resumeBouton = document.getElementById("fin-de-partie-panel-resume-bouton") as HTMLElement;
|
let resumeBouton = document.getElementById("fin-de-partie-panel-resume-bouton") as HTMLElement;
|
||||||
resumeBouton.addEventListener("click", (event) => {
|
resumeBouton.addEventListener("click", (event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
if (!navigator.clipboard) {
|
new Promise((resolve, reject) => {
|
||||||
NotificationMessage.ajouterNotificationPanel("Votre navigateur n'est pas compatible");
|
if (window.navigator.clipboard !== undefined) {
|
||||||
}
|
return resolve(window.navigator.clipboard.writeText(this._resumeTexte + "\n\nhttps://sutom.nocle.fr"));
|
||||||
|
}
|
||||||
|
|
||||||
navigator.clipboard
|
return reject();
|
||||||
.writeText(this._resumeTexte + "\n\nhttps://sutom.nocle.fr")
|
})
|
||||||
|
.catch(
|
||||||
|
() =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
if (window.navigator.share !== undefined) return resolve(navigator.share({ text: this._resumeTexte + "\n\nhttps://sutom.nocle.fr" }));
|
||||||
|
|
||||||
|
return reject();
|
||||||
|
})
|
||||||
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
NotificationMessage.ajouterNotificationPanel("Résumé copié dans le presse papier");
|
NotificationMessage.ajouterNotificationPanel("Résumé copié dans le presse papier");
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue