File size: 1,524 Bytes
492a0fe
 
 
 
 
618b6ac
492a0fe
 
 
 
 
 
 
 
618b6ac
492a0fe
 
 
 
ff7205b
 
 
 
 
 
 
 
492a0fe
 
 
 
ff7205b
 
 
 
 
 
 
 
492a0fe
ff7205b
 
492a0fe
 
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
document.addEventListener('DOMContentLoaded', function() {
    const form = document.getElementById('dataForm');
    const jsonOutput = document.getElementById('jsonOutput');
    const jsonContent = document.getElementById('jsonContent');
    const copyButton = document.getElementById('copyJson');
form.addEventListener('submit', function(e) {
        e.preventDefault();
        
        const formData = new FormData(form);
        const data = {
            name: formData.get('name'),
address: formData.get('address'),
            phone: formData.get('phone'),
            logoUrl: formData.get('logoUrl'),
};

        // Display formatted JSON
        jsonContent.textContent = JSON.stringify(data, null, 2);
        jsonOutput.classList.remove('hidden');
        // Scroll to output with offset
        setTimeout(() => {
            window.scrollTo({
                top: jsonOutput.offsetTop - 20,
                behavior: 'smooth'
            });
        }, 100);
});

    copyButton.addEventListener('click', function() {
        const textToCopy = jsonContent.textContent;
        navigator.clipboard.writeText(textToCopy).then(() => {
        // Show copied feedback
        const icon = copyButton.querySelector('i');
        const originalIcon = icon.dataset.feather;
        icon.setAttribute('data-feather', 'check');
        feather.replace();
        
        setTimeout(() => {
            icon.setAttribute('data-feather', originalIcon);
            feather.replace();
        }, 2000);
});
    });
});