Add the metadata file path for easy copy+paste

This commit is contained in:
Kylian Schmidt
2025-07-29 11:18:03 +02:00
parent bcb083bbb9
commit fc4928fef1
5 changed files with 243 additions and 8 deletions
+61
View File
@@ -50,6 +50,67 @@ function expandText(button) {
}
}
// Copy metadata file path to clipboard
async function copyMetadataPath() {
const pathElement = document.getElementById('metadata-file-path');
const copyBtn = document.querySelector('.copy-path-btn');
if (!pathElement || !copyBtn) {
console.log('Path element or copy button not found');
return;
}
const path = pathElement.textContent;
console.log('Attempting to copy path:', path);
try {
// Try using the modern clipboard API
if (navigator.clipboard && window.isSecureContext) {
await navigator.clipboard.writeText(path);
} else {
// Fallback for older browsers
const textArea = document.createElement('textarea');
textArea.value = path;
textArea.style.position = 'fixed';
textArea.style.left = '-999999px';
textArea.style.top = '-999999px';
document.body.appendChild(textArea);
textArea.focus();
textArea.select();
document.execCommand('copy');
textArea.remove();
}
// Visual feedback
const originalText = copyBtn.innerHTML;
copyBtn.innerHTML = '✅ Copied!';
copyBtn.classList.add('copied');
setTimeout(() => {
copyBtn.innerHTML = originalText;
copyBtn.classList.remove('copied');
}, 2000);
console.log('Path copied successfully');
} catch (err) {
console.error('Failed to copy path: ', err);
// Show error feedback
const originalText = copyBtn.innerHTML;
copyBtn.innerHTML = '❌ Failed';
setTimeout(() => {
copyBtn.innerHTML = originalText;
}, 2000);
}
}
// Make functions globally available
window.toggleMetadataSection = toggleMetadataSection;
window.expandText = expandText;
window.copyMetadataPath = copyMetadataPath;
// Initialize on page load
document.addEventListener('DOMContentLoaded', function() {
console.log('Metadata section script loaded');