File size: 10,561 Bytes
ffed4ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3ae8b9
ffed4ea
 
 
 
c3ae8b9
ffed4ea
c3ae8b9
 
ffed4ea
 
 
c3ae8b9
ffed4ea
 
 
 
 
c3ae8b9
ffed4ea
 
 
 
c3ae8b9
ffed4ea
c3ae8b9
 
ffed4ea
 
 
 
 
 
 
 
c3ae8b9
ffed4ea
 
 
 
 
 
 
 
 
 
 
 
c3ae8b9
 
ffed4ea
c3ae8b9
ffed4ea
 
 
 
 
 
 
 
 
 
 
 
 
c3ae8b9
ffed4ea
 
c3ae8b9
ffed4ea
 
 
 
c3ae8b9
ffed4ea
 
 
c3ae8b9
ffed4ea
 
 
 
 
 
 
 
 
381bf2b
0f0f876
 
 
 
 
 
 
ffed4ea
381bf2b
ffed4ea
381bf2b
ffed4ea
 
c3ae8b9
 
 
 
 
ffed4ea
 
 
c3ae8b9
ffed4ea
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c3ae8b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ffed4ea
 
c3ae8b9
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Editor - Replit Clone</title>
    <link rel="stylesheet" href="style.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <script src="https://unpkg.com/feather-icons"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.1/min/vs/loader.min.js"></script>
    <script>
        tailwind.config = {
            theme: {
                extend: {
                    colors: {
                        primary: '#0088CC',
                        secondary: '#1F2937'
                    }
                }
            }
        }
    </script>
</head>
<body class="bg-gray-900 text-gray-100">
    <custom-navbar></custom-navbar>
    
    <div class="flex h-screen">
        <!-- Sidebar -->
        <div class="w-64 bg-gray-800 flex flex-col">
            <div class="p-4 border-b border-gray-700">
                <h2 class="font-bold text-lg truncate" id="projectName">Project Name</h2>
                <p class="text-gray-400 text-sm">JavaScript</p>
            </div>
            
            <div class="flex-1 overflow-y-auto">
                <div class="p-2">
                    <div class="flex items-center justify-between p-2 hover:bg-gray-700 rounded cursor-pointer" onclick="toggleFolder('src')">
                        <div class="flex items-center gap-2">
                            <i data-feather="folder" class="w-4 h-4 text-blue-400"></i>
                            <span>src</span>
                        </div>
                        <i data-feather="chevron-down" class="w-4 h-4" id="src-chevron"></i>
                    </div>
                    <div class="ml-6" id="src-folder">
                        <div class="flex items-center gap-2 p-2 hover:bg-gray-700 rounded cursor-pointer" onclick="openFile('index.js')">
                            <i data-feather="file" class="w-4 h-4 text-yellow-400"></i>
                            <span>index.js</span>
                        </div>
                        <div class="flex items-center gap-2 p-2 hover:bg-gray-700 rounded cursor-pointer" onclick="openFile('styles.css')">
                            <i data-feather="file" class="w-4 h-4 text-blue-400"></i>
                            <span>styles.css</span>
                        </div>
                    </div>
                    
                    <div class="flex items-center justify-between p-2 hover:bg-gray-700 rounded cursor-pointer" onclick="toggleFolder('public')">
                        <div class="flex items-center gap-2">
                            <i data-feather="folder" class="w-4 h-4 text-blue-400"></i>
                            <span>public</span>
                        </div>
                        <i data-feather="chevron-down" class="w-4 h-4" id="public-chevron"></i>
                    </div>
                    <div class="ml-6" id="public-folder">
                        <div class="flex items-center gap-2 p-2 hover:bg-gray-700 rounded cursor-pointer" onclick="openFile('index.html')">
                            <i data-feather="file" class="w-4 h-4 text-green-400"></i>
                            <span>index.html</span>
                        </div>
                    </div>
                </div>
            </div>
            
            <div class="p-4 border-t border-gray-700">
                <button class="w-full bg-primary hover:bg-blue-600 text-white py-2 rounded-lg flex items-center justify-center gap-2" onclick="runCode()">
                    <i data-feather="play"></i>
                    Run
                </button>
            </div>
        </div>
        
        <!-- Main Editor Area -->
        <div class="flex-1 flex flex-col">
            <!-- Editor Tabs -->
            <div class="flex bg-gray-800 border-b border-gray-700">
                <div class="px-4 py-2 bg-gray-700 border-r border-gray-600 flex items-center gap-2">
                    <i data-feather="file" class="w-4 h-4"></i>
                    <span id="current-file">index.js</span>
                    <i data-feather="x" class="w-4 h-4 cursor-pointer hover:bg-gray-600 rounded" onclick="closeTab()"></i>
                </div>
                <div class="px-4 py-2 flex items-center gap-2 text-gray-400 hover:bg-gray-700 cursor-pointer" onclick="newFile()">
                    <i data-feather="plus" class="w-4 h-4"></i>
                </div>
            </div>
            
            <!-- Monaco Editor Container -->
            <div id="editor" class="flex-1"></div>
            
            <!-- Console Output -->
            <div class="h-48 bg-black border-t border-gray-700 flex flex-col">
                <div class="flex items-center justify-between p-2 bg-gray-800">
                    <div class="flex items-center gap-4">
                        <span class="font-medium">Console</span>
                        <div class="flex gap-2">
                            <button class="text-gray-400 hover:text-white" onclick="clearConsole()">
                                <i data-feather="terminal" class="w-4 h-4"></i>
                            </button>
                            <button class="text-gray-400 hover:text-white" onclick="toggleConsoleView()">
                                <i data-feather="layers" class="w-4 h-4"></i>
                            </button>
                        </div>
                    </div>
                    <button class="text-gray-400 hover:text-white" onclick="clearConsole()">
                        <i data-feather="trash-2" class="w-4 h-4"></i>
                    </button>
                </div>
                <div class="flex-1 p-2 font-mono text-sm overflow-y-auto" id="console-output">
                    <div class="text-green-400">$ npm start</div>
                    <div>> Starting development server...</div>
                    <div>> Compiled successfully!</div>
                    <div>> Server running on http://localhost:3000</div>
                </div>
            </div>
        </div>
    </div>
    <custom-footer></custom-footer>
    <ai-agent></ai-agent>
    <div class="fixed bottom-4 right-20 z-50">
        <button class="bg-primary hover:bg-blue-600 text-white p-3 rounded-full shadow-lg flex items-center justify-center" 
                onclick="window.dispatchEvent(new CustomEvent('toggleAIChat'))">
            <i data-feather="message-square"></i>
        </button>
    </div>
<script src="components/navbar.js"></script>
    <script src="components/footer.js"></script>
    <script src="components/ai-agent.js"></script>
    <script src="script.js"></script>
<script>
        feather.replace();
        
        // Global variables
        let editor;
        let currentFile = 'index.js';
        let consoleOutput = document.getElementById('console-output');
        
        // Initialize Monaco Editor
        require.config({ paths: { 'vs': 'https://cdnjs.cloudflare.com/ajax/libs/monaco-editor/0.34.1/min/vs' }});
        require(['vs/editor/editor.main'], function() {
            editor = monaco.editor.create(document.getElementById('editor'), {
                value: [
                    '// Welcome to Replit Clone!',
                    '// Start coding your amazing project here.',
                    '',
                    'console.log("Hello, World!");',
                    '',
                    'function greet(name) {',
                    '    return `Hello, ${name}!`;',
                    '}',
                    '',
                    'greet("Developer");'
                ].join('\n'),
                language: 'javascript',
                theme: 'vs-dark',
                automaticLayout: true,
                minimap: {
                    enabled: false
                }
            });
        });
        
        // Update project name from URL params
        const urlParams = new URLSearchParams(window.location.search);
        const projectName = urlParams.get('project') || urlParams.get('template') || 'New Project';
        document.getElementById('projectName').textContent = projectName.charAt(0).toUpperCase() + projectName.slice(1);
        
        // Interactive functions
        function toggleFolder(folderName) {
            const folder = document.getElementById(`${folderName}-folder`);
            const chevron = document.getElementById(`${folderName}-chevron`);
            
            if (folder.style.display === 'none') {
                folder.style.display = 'block';
                chevron.setAttribute('data-feather', 'chevron-down');
            } else {
                folder.style.display = 'none';
                chevron.setAttribute('data-feather', 'chevron-right');
            }
            
            feather.replace();
        }
        
        function openFile(filename) {
            currentFile = filename;
            document.getElementById('current-file').textContent = filename;
            
            // In a real app, this would load the file content
            if (editor) {
                if (filename.endsWith('.js')) {
                    editor.setModelLanguage(editor.getModel(), 'javascript');
                } else if (filename.endsWith('.css')) {
                    editor.setModelLanguage(editor.getModel(), 'css');
                } else if (filename.endsWith('.html')) {
                    editor.setModelLanguage(editor.getModel(), 'html');
                }
            }
        }
        
        function closeTab() {
            alert('Closing tab...');
        }
        
        function newFile() {
            const filename = prompt('Enter new file name:');
            if (filename) {
                alert(`Creating new file: ${filename}`);
                // In a real app, this would create a new file
            }
        }
        
        function runCode() {
            // Simulate code execution
            const output = document.createElement('div');
            output.textContent = '> Code executed successfully!';
            output.className = 'text-green-400';
            consoleOutput.appendChild(output);
            consoleOutput.scrollTop = consoleOutput.scrollHeight;
        }
        
        function clearConsole() {
            consoleOutput.innerHTML = '';
        }
        
        function toggleConsoleView() {
            alert('Toggling console view...');
        }
    </script>
</body>
</html>