Skip to content

Commit

Permalink
Share enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoerdvanderhoorn committed Nov 19, 2022
1 parent 4e13601 commit 62a54b8
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions js/site/script.js
Expand Up @@ -275,22 +275,27 @@ var app = new Vue(
}).join("\n");
this.saveShoppinglist();
},
share: function()
share: async function()
{
window.location.hash = this.shoppinglist.replace(/\n/g, "%0A");
var shared = false;
// Share the shoppinglist using the device's share functionality
if (navigator.share)
{
navigator.share({
title: "Checkjebon.nl",
text: "Je boodschappenlijst van Checkjebon.nl",
url: window.location.href
}).then(() => {
try
{
await navigator.share(
{
title: "Checkjebon.nl",
text: "Je boodschappenlijst van Checkjebon.nl",
url: window.location.href
});
shared = true;
}).catch((e) => {
}
catch(e)
{
console.log('Error sharing link', e);
});
}
}
// Share the shoppinglist via email
if (!shared)
Expand All @@ -306,7 +311,7 @@ var app = new Vue(
body += `%0A%0A`;
body += `Ga verder met deze boodschappenlijst via de link hieronder.%0A%0A`;
body += encodeURIComponent(window.location.href);
window.open(`mailto:?subject=Checkjebon.nl - boodschappenlijst&body=${body}`);
window.location = `mailto:?subject=Checkjebon.nl - boodschappenlijst&body=${body}`;
}
window.location.hash = "";
},
Expand Down

0 comments on commit 62a54b8

Please sign in to comment.