<div class="option">
<div id="result">TextContent</div>
<button id="copy">Copy</button>
</div>
let result = document.getElementById("result");
let copy = document.getElementById("copy");
copy.addEventListener("click", function () {
copyToClipboard(result.innerText);
});
function copyToClipboard(text, onComplete) {
if (navigator.clipboard) {
navigator.clipboard
.writeText(text)
.then(() => {
if (typeof onComplete === "function") onComplete();
})
.catch((err) => {
console.error("Copy fail", err);
});
} else {
let area = document.createElement("textarea");
document.body.appendChild(area);
area.value = text;
area.select();
document.execCommand("copy");
document.body.removeChild(area);
if (typeof onComplete === "function") onComplete();
}
}
(function () {
const square = document.querySelector('.skill__skills');
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
const entrySquares = entry.target.querySelectorAll('.loading');
if (typeof getCurrentAnimationPreference === 'function' && !getCurrentAnimationPreference()) {
return;
}
entrySquares.forEach(entrySquare => {
if (entry.isIntersecting) {
entrySquare.classList.add('square-animation');
return;
}
entrySquare.classList.remove('square-animation');
})
});
});
observer.observe(square);
})();
if ($src) {
echo '<img src="'.$src.'">';
}
img[src=""] {
display: none;
}
img:not([src]) {
display: none;
}