Skip to content

Commit

Permalink
Merge pull request #7 from shibadogcap/test
Browse files Browse the repository at this point in the history
add share
  • Loading branch information
shibadogcap authored Jul 2, 2024
2 parents b640b96 + c2c8547 commit 23791df
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ <h1>NDOT Wallpaper Maker</h1>
<p>
<center>
<button id="download">ダウンロード</button>
<button id="share">シェア</button>
</center>
</p>
<script>
Expand All @@ -215,6 +216,22 @@ <h1>NDOT Wallpaper Maker</h1>
link.download = "wallpaper.png";
link.click();
}

document.getElementById("share").onclick = (event) => {
let canvas = document.getElementById("preview_canvas");
let dataUrl = canvas.toDataURL("image/png");
if (navigator.share) {
navigator.share({
title: "My Wallpaper",
text: "Created with NDOT Wallpaper Maker",
url: dataUrl
})
.then(() => console.log("Share successful"))
.catch((error) => console.log("Share failed:", error));
} else {
alert("Sharing is not supported on this device.");
}
}
</script>
</body>
</html>

0 comments on commit 23791df

Please sign in to comment.