Spaces:
Running

File size: 2,889 Bytes
29303b3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copy to clipboard functionality
function copyToClipboard(elementId, button) {
    const element = document.getElementById(elementId);
    const text = element.textContent.trim();
    
    // Remove spaces from IBAN if it's the IBAN field
    const textToCopy = elementId === 'iban' ? text.replace(/\s/g, '') : text;
    
    // Use the Clipboard API
    if (navigator.clipboard && window.isSecureContext) {
        navigator.clipboard.writeText(textToCopy).then(() => {
            showCopyFeedback(button);
        }).catch(err => {
            console.error('Failed to copy:', err);
            fallbackCopyTextToClipboard(textToCopy, button);
        });
    } else {
        // Fallback for older browsers
        fallbackCopyTextToClipboard(textToCopy, button);
    }
}

// Fallback copy method for older browsers
function fallbackCopyTextToClipboard(text, button) {
    const textArea = document.createElement("textarea");
    textArea.value = text;
    textArea.style.position = "fixed";
    textArea.style.left = "-999999px";
    textArea.style.top = "-999999px";
    document.body.appendChild(textArea);
    textArea.focus();
    textArea.select();
    
    try {
        const successful = document.execCommand('copy');
        if (successful) {
            showCopyFeedback(button);
        } else {
            showToast('Copy failed');
        }
    } catch (err) {
        console.error('Fallback copy failed:', err);
        showToast('Copy failed');
    }
    
    document.body.removeChild(textArea);
}

// Show visual feedback when copied
function showCopyFeedback(button) {
    button.classList.add('copied');
    showToast('Copied to clipboard!');
    
    setTimeout(() => {
        button.classList.remove('copied');
    }, 2000);
}

// Show toast notification
function showToast(message) {
    const toast = document.getElementById('toast');
    const toastMessage = document.getElementById('toast-message');
    
    toastMessage.textContent = message;
    toast.classList.add('show');
    
    setTimeout(() => {
        toast.classList.remove('show');
    }, 3000);
}

// Add click to select functionality for info values
document.addEventListener('DOMContentLoaded', function() {
    const infoValues = document.querySelectorAll('.info-value');
    
    infoValues.forEach(value => {
        value.addEventListener('click', function() {
            // Select all text when clicked
            if (document.selection) {
                const range = document.body.createTextRange();
                range.moveToElementText(this);
                range.select();
            } else if (window.getSelection) {
                const range = document.createRange();
                range.selectNodeContents(this);
                window.getSelection().removeAllRanges();
                window.getSelection().addRange(range);
            }
        });
    });
});