site: multi-page structure with shared nav; rework services, keys, contact
This commit is contained in:
parent
03f38ab908
commit
82fc1c6e17
12 changed files with 143 additions and 151 deletions
21
public/copy.js
Normal file
21
public/copy.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// One copy button per [data-copy] element. Copies the data-copy value when
|
||||
// set, otherwise the element's original text. Clipboard API needs a secure
|
||||
// context — https in prod, localhost in dev; both hold.
|
||||
document.querySelectorAll('[data-copy]').forEach(function (el) {
|
||||
var text = el.getAttribute('data-copy') || el.textContent.trim();
|
||||
|
||||
var btn = document.createElement('span');
|
||||
btn.innerText = 'Copy';
|
||||
btn.classList.add('copy-button');
|
||||
el.appendChild(btn);
|
||||
|
||||
btn.addEventListener('click', function () {
|
||||
navigator.clipboard.writeText(text).then(function () {
|
||||
btn.innerText = 'Copied!';
|
||||
setTimeout(function () { btn.innerText = 'Copy'; }, 2000);
|
||||
}, function () {
|
||||
btn.innerText = 'Failed';
|
||||
setTimeout(function () { btn.innerText = 'Copy'; }, 2000);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
// Get the <pre> element
|
||||
const PGP = document.getElementById("myPGP");
|
||||
|
||||
//Create a copy button element
|
||||
const copyButton = document.createElement("span");
|
||||
copyButton.innerText = "Copy";
|
||||
copyButton.classList.add("copy-button");
|
||||
|
||||
// Append the copy button to the <pre> tag
|
||||
PGP.appendChild(copyButton);
|
||||
|
||||
// Add click event listener to the copy button
|
||||
copyButton.addEventListener("click", () => {
|
||||
// Hide the copy button temporarily
|
||||
copyButton.style.display = "none";
|
||||
|
||||
// Create a range and select the text inside the <pre> tag
|
||||
const range = document.createRange();
|
||||
range.selectNode(PGP);
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
|
||||
try {
|
||||
// Copy the selected text to the clipboard
|
||||
document.execCommand("copy");
|
||||
|
||||
// Alert the user that the text has been copied
|
||||
copyButton.innerText = "Copied!";
|
||||
setTimeout(function(){
|
||||
copyButton.innerText = "Copy";
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
console.error("Unable to copy text:", err);
|
||||
} finally {
|
||||
// Show the copy button again
|
||||
copyButton.style.display = "inline";
|
||||
|
||||
// Deselect the text
|
||||
window.getSelection().removeAllRanges();
|
||||
}
|
||||
});
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
// Get the <pre> element
|
||||
const SSH = document.getElementById("mySSH");
|
||||
|
||||
//Create a copy button element
|
||||
const copyButtonSSH = document.createElement("span");
|
||||
copyButtonSSH.innerText = "Copy";
|
||||
copyButtonSSH.classList.add("copy-button");
|
||||
|
||||
// Append the copy button to the <pre> tag
|
||||
SSH.appendChild(copyButtonSSH);
|
||||
|
||||
// Add click event listener to the copy button
|
||||
copyButtonSSH.addEventListener("click", () => {
|
||||
// Hide the copy button temporarily
|
||||
copyButtonSSH.style.display = "none";
|
||||
|
||||
// Create a range and select the text inside the <pre> tag
|
||||
const range = document.createRange();
|
||||
range.selectNode(SSH);
|
||||
window.getSelection().removeAllRanges();
|
||||
window.getSelection().addRange(range);
|
||||
|
||||
try {
|
||||
// Copy the selected text to the clipboard
|
||||
document.execCommand("copy");
|
||||
|
||||
// Alert the user that the text has been copied
|
||||
copyButtonSSH.innerText = "Copied!";
|
||||
setTimeout(function(){
|
||||
copyButtonSSH.innerText = "Copy";
|
||||
}, 2000);
|
||||
} catch (err) {
|
||||
console.error("Unable to copy text:", err);
|
||||
} finally {
|
||||
// Show the copy button again
|
||||
copyButtonSSH.style.display = "inline";
|
||||
|
||||
// Deselect the text
|
||||
window.getSelection().removeAllRanges();
|
||||
}
|
||||
});
|
||||
|
|
@ -5,4 +5,14 @@
|
|||
<changefreq>monthly</changefreq>
|
||||
<priority>1.0</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://asxp.io/contact</loc>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
<url>
|
||||
<loc>https://asxp.io/keys</loc>
|
||||
<changefreq>yearly</changefreq>
|
||||
<priority>0.5</priority>
|
||||
</url>
|
||||
</urlset>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue