File size: 3,691 Bytes
901a21b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Python Data Science IDE</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/theme/dracula.min.css" rel="stylesheet">
    <style>
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        #editor-container {
            display: flex;
            height: 100vh;
            overflow: hidden;
        }
        #code-editor {
            flex: 1;
            height: 100%;
        }
        #output-container {
            flex: 1;
            padding: 15px;
            overflow-y: auto;
            background: #f8f9fa;
        }
        .toolbar {
            background: #343a40;
            padding: 10px;
            display: flex;
            justify-content: space-between;
        }
        .mode-toggle {
            cursor: pointer;
            color: white;
        }
        .data-preview {
            margin-bottom: 20px;
            border: 1px solid #dee2e6;
            border-radius: 4px;
            padding: 10px;
            background: white;
        }
    </style>
</head>
<body>
    <div class="toolbar">
        <div>
            <span class="text-white">Python Data Science IDE</span>
        </div>
        <div class="mode-toggle" id="theme-toggle">
            <i class="fas fa-moon"></i> Dark Mode
        </div>
    </div>
    <div id="editor-container">
        <div id="code-editor"></div>
        <div id="output-container">
            <h4>Output & Data Preview</h4>
            <div id="data-preview"></div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/python/python.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/addon/hint/show-hint.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/addon/hint/python-hint.min.js"></script>
    <script src="https://kit.fontawesome.com/a076d05399.js" crossorigin="anonymous"></script>
    
    <script>
        const editor = CodeMirror(document.getElementById('code-editor'), {
            mode: 'python',
            theme: 'dracula',
            lineNumbers: true,
            indentUnit: 4,
            extraKeys: {
                'Ctrl-Space': 'autocomplete',
            }
        });

        editor.setValue(`# Python Data Science IDE
import numpy as np
import pandas as pd

# Create sample data
data = np.random.rand(5, 3)
df = pd.DataFrame(data, columns=['A', 'B', 'C'])

# Preview your data
print(data)
print(df)`);

        document.getElementById('theme-toggle').addEventListener('click', function() {
            const currentTheme = editor.getOption('theme');
            const newTheme = currentTheme === 'default' ? 'dracula' : 'default';
            editor.setOption('theme', newTheme);
            this.innerHTML = newTheme === 'default' 
                ? '<i class="fas fa-moon"></i> Dark Mode' 
                : '<i class="fas fa-sun"></i> Light Mode';
            document.body.style.backgroundColor = newTheme === 'default' ? '#f8f9fa' : '#282a36';
        });
    </script>
</body>
</html>