Picture-Puzzle-website/static/js/main.js

29 lines
912 B
JavaScript

document.addEventListener("DOMContentLoaded", function() {
var gif = document.querySelector(".clickable");
var notification = document.getElementById("copyNotification");
gif.addEventListener("mouseenter", function() {
notification.textContent = "Get link to game";
notification.style.visibility = "visible";
});
gif.addEventListener("click", function() {
var gameUrl = "https://gitea.rkg.lv/elukjanovica/Picture_Puzzle.git";
navigator.clipboard.writeText(gameUrl).then(function() {
notification.textContent = "Link copied!";
setTimeout(function() {
notification.textContent = "Get link to game";
}, 2000);
}, function() {
console.error("Failed to copy link.");
});
});
gif.addEventListener("mouseleave", function() {
notification.style.visibility = "hidden";
});
});