Add the metadata file path for easy copy+paste
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user