File size: 5,950 Bytes
43195a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>EdgeCoder | Reconfigure</title>
    <script src="https://cdn.jsdelivr.net/gh/Reconfigure-In/Content-Protection-Script@refs/heads/main/script.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/python/python.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/components/prism-python.min.js"></script>
    <style>
        body, html {
            margin: 0;
            padding: 0;
            height: 100vh;
            overflow: hidden;
            font-family: Arial, sans-serif;
        }
        body {
            display: flex;
            flex-direction: column;
            background-color: #f0f0f0;
        }
        .container {
            display: flex;
            flex: 1;
            overflow: hidden;
        }
        .editor, .output {
            flex: 1;
            display: flex;
            flex-direction: column;
            margin: 10px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 0 10px rgba(0,0,0,0.1);
        }
        .CodeMirror {
            flex: 1;
            height: auto;
            font-size: 14px;
        }
        #output-container {
            flex: 1;
            overflow: auto;
            font-family: monospace;
            font-size: 14px;
            line-height: 1.5;
        }
        #output-table {
            border-collapse: collapse;
            width: 100%;
        }
        #line-numbers {
            width: 1%;
            padding-left: 20px;
            text-align: right;
            color: #999;
            user-select: none;
            vertical-align: top;
            border-right: 1px solid #ddd;
            background-color: #f7f7f7;
        }
        #output {
            padding-left: 10px;
            white-space: pre-wrap;
            word-break: break-all;
            vertical-align: top;
        }
        .button-container {
            padding: 10px;
            background-color: #f0f0f0;
            display: flex;
            align-items: baseline;
        }
        button {
            padding: 10px 20px;
            background-color: black;
            color: white;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            transition: 0.3s;
            margin-right: auto;
        }
        button:hover {
            background-color: #333;
        }
        .error {
            color: red;
            font-weight: bold;
        }
        #output .token.comment { color: gray; }
        #output .token.keyword { color: blue; }
        #output .token.string { color: green; }
        #output .token.function { color: red; }
        #output .token.number { color: purple; }

        a {
            color: black;
            text-decoration: none;
            font-size: 16px;
            margin-left: auto;
            font-family: monospace;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="editor">
            <textarea id="code">def div(x, y):
    return x/y</textarea>
        </div>
        <div class="output">
            <div id="output-container">
                <table id="output-table">
                    <tr>
                        <td id="line-numbers"></td>
                        <td id="output"></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <div class="button-container">
        <button onclick="runCode()">Enhance \w EdgeCoder</button>
        <a href="https://reconfigure.in/" target="_blank">Build By Reconfigure.in</a>
    </div>

    <script>
        var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
            lineNumbers: true,
            mode: "python",
            theme: "default"
        });

        function runCode() {
            alert("Thinking! Please wait a moment.");
            var code = editor.getValue();
            fetch('/', {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/x-www-form-urlencoded',
                },
                body: 'code=' + encodeURIComponent(code)
            })
            .then(response => response.json())
            .then(data => {
                var outputElement = document.getElementById('output');
                var lineNumbersElement = document.getElementById('line-numbers');
                if (data.error) {
                    outputElement.innerHTML = '<span class="error">Error: ' + data.error + '</span>\n\nTraceback:\n' + data.traceback;
                } else {
                    outputElement.innerHTML = Prism.highlight(data.result, Prism.languages.python, 'python');
                }
                var lines = outputElement.innerHTML.split('\n');
                lineNumbersElement.innerHTML = lines.map((_, i) => i + 1).join('\n');
                
                var outputContainer = document.getElementById('output-container');
                outputContainer.scrollTop = outputContainer.scrollHeight;
            })
            .catch((error) => {
                console.error('Error:', error);
                document.getElementById('output').innerHTML = '<span class="error">An unexpected error occurred. Please try again.</span>';
            });
        }
    </script>
</body>
</html>