File size: 5,405 Bytes
a992e01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6d09658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a992e01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85a4f93
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a992e01
 
 
6d09658
 
a992e01
 
85a4f93
 
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// Initialize dark mode preference
function initDarkMode() {
    const darkMode = localStorage.getItem('darkMode') === 'true' || 
                    (!localStorage.getItem('darkMode') && window.matchMedia('(prefers-color-scheme: dark)').matches);
    
    if (darkMode) {
        document.documentElement.classList.add('dark');
    }
    
    // Dispatch event for components to listen to
    document.dispatchEvent(new CustomEvent('darkModeChange', { detail: darkMode }));
}

// Toggle dark mode
function toggleDarkMode() {
    const isDark = document.documentElement.classList.toggle('dark');
    localStorage.setItem('darkMode', isDark);
    document.dispatchEvent(new CustomEvent('darkModeChange', { detail: isDark }));
}
// Collapsible Menu Functionality
function setupCollapsibleMenu() {
    const menuSections = document.querySelectorAll('.menu-section');
    
    menuSections.forEach(section => {
        const header = section.querySelector('.menu-header');
        const content = section.querySelector('.menu-content');
        const chevron = header.querySelector('i[data-feather="chevron-down"]');
        
        header.addEventListener('click', () => {
            // Close all other sections
            menuSections.forEach(s => {
                if (s !== section) {
                    s.querySelector('.menu-content').classList.remove('active');
                    s.querySelector('.menu-header').classList.remove('active');
                }
            });
            
            // Toggle current section
            content.classList.toggle('active');
            header.classList.toggle('active');
            
            // Update chevron icon
            if (content.classList.contains('active')) {
                chevron.setAttribute('data-feather', 'chevron-up');
            } else {
                chevron.setAttribute('data-feather', 'chevron-down');
            }
            feather.replace();
        });
    });
}

// Connection Tabs Functionality
function setupConnectionTabs() {
    const tabsContainer = document.querySelector('.connection-tabs');
    if (!tabsContainer) return;
    
    const tabs = tabsContainer.querySelectorAll('.connection-tab');
    
    tabs.forEach(tab => {
        tab.addEventListener('click', () => {
            tabs.forEach(t => t.classList.remove('active'));
            tab.classList.add('active');
            // Here you would switch the terminal view to the selected connection
        });
    });
}

// Terminal simulation (simple demo)
function simulateTerminal() {
    const terminal = document.querySelector('.terminal-container');
    if (terminal) {
        terminal.scrollTop = terminal.scrollHeight;
    }
}
// Drag and drop file handling
function initFileDrop() {
    const dropArea = document.querySelector('.border-dashed');
    if (!dropArea) return;

    ['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
        dropArea.addEventListener(eventName, preventDefaults, false);
    });

    function preventDefaults(e) {
        e.preventDefault();
        e.stopPropagation();
    }

    ['dragenter', 'dragover'].forEach(eventName => {
        dropArea.addEventListener(eventName, highlight, false);
    });

    ['dragleave', 'drop'].forEach(eventName => {
        dropArea.addEventListener(eventName, unhighlight, false);
    });

    function highlight() {
        dropArea.classList.add('border-primary-500', 'bg-primary-50', 'dark:bg-gray-700');
    }

    function unhighlight() {
        dropArea.classList.remove('border-primary-500', 'bg-primary-50', 'dark:bg-gray-700');
    }

    dropArea.addEventListener('drop', handleDrop, false);

    function handleDrop(e) {
        const dt = e.dataTransfer;
        const files = dt.files;
        handleFiles(files);
    }

    function handleFiles(files) {
        console.log('Files dropped:', files);
        // Here you would handle the file upload
    }
}
// Window controls functionality
function setupWindowControls() {
    const minimizeBtn = document.querySelector('.window-control:nth-child(1)');
    const maximizeBtn = document.querySelector('.window-control:nth-child(2)');
    const closeBtn = document.querySelector('.window-control:nth-child(3)');
    
    if (minimizeBtn) {
        minimizeBtn.addEventListener('click', () => {
            document.querySelector('.app-window').classList.add('minimized');
        });
    }
    
    if (maximizeBtn) {
        maximizeBtn.addEventListener('click', () => {
            const window = document.querySelector('.app-window');
            window.classList.toggle('maximized');
            
            const icon = maximizeBtn.querySelector('i');
            if (window.classList.contains('maximized')) {
                icon.setAttribute('data-feather', 'minimize-2');
            } else {
                icon.setAttribute('data-feather', 'maximize-2');
            }
            feather.replace();
        });
    }
    
    if (closeBtn) {
        closeBtn.addEventListener('click', () => {
            // In a real app, this would close the window
            console.log('Window close requested');
        });
    }
}
// Initialize everything when DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
    initDarkMode();
    setupCollapsibleMenu();
    setupConnectionTabs();
    simulateTerminal();
    initFileDrop();
    setupWindowControls();
});