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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="ru">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Online Python - IDE, Editor, Compiler, Interpreter</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.css">
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
| 9 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.css">
|
| 10 |
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/katex.min.js"></script>
|
| 11 |
+
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.0/dist/contrib/auto-render.min.js"></script>
|
| 12 |
+
|
| 13 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 14 |
+
|
| 15 |
+
<style>
|
| 16 |
+
/* Немного подправим стили вывода, чтобы формулы и списки не разъезжались */
|
| 17 |
+
.output-body {
|
| 18 |
+
line-height: 1.6;
|
| 19 |
+
}
|
| 20 |
+
.output-body p { margin: 8px 0; }
|
| 21 |
+
.output-body h3 { font-size: 1.1em; margin: 15px 0 5px 0; color: #007bff; }
|
| 22 |
+
.katex-display { margin: 10px 0; overflow-x: auto; overflow-y: hidden; }
|
| 23 |
+
</style>
|
| 24 |
+
<style>
|
| 25 |
+
:root {
|
| 26 |
+
--blue-primary: #007bff;
|
| 27 |
+
--blue-hover: #0056b3;
|
| 28 |
+
--green-primary: #28a745;
|
| 29 |
+
--green-hover: #218838;
|
| 30 |
+
--gray-bg: #f8f9fa;
|
| 31 |
+
--gray-border: #dee2e6;
|
| 32 |
+
--text-dark: #343a40;
|
| 33 |
+
--text-muted: #6c757d;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; margin: 0; background-color: var(--gray-bg); color: var(--text-dark); display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
|
| 37 |
+
|
| 38 |
+
/* Синяя панель заголовка */
|
| 39 |
+
.header { background-color: var(--blue-primary); color: white; display: flex; justify-content: space-between; align-items: center; padding: 10px 15px; border-bottom: 1px solid rgba(0,0,0,.1); }
|
| 40 |
+
.header-left { display: flex; align-items: center; gap: 10px; font-weight: bold; font-size: 1.1em; }
|
| 41 |
+
.header-left img { height: 24px; }
|
| 42 |
+
.header-right { display: flex; align-items: center; gap: 10px; }
|
| 43 |
+
.btn-learn { background-color: white; color: var(--blue-primary); border: 1px solid white; padding: 6px 12px; font-size: 0.9em; font-weight: bold; border-radius: 4px; cursor: pointer; text-decoration: none; }
|
| 44 |
+
.btn-learn:hover { background-color: #f1f1f1; }
|
| 45 |
+
.btn-try-new { background-color: var(--green-primary); color: white; border: none; padding: 6px 12px; font-size: 0.9em; font-weight: bold; border-radius: 4px; cursor: pointer; text-decoration: none; display: flex; align-items: center; gap: 5px; }
|
| 46 |
+
.btn-try-new:hover { background-color: var(--green-hover); }
|
| 47 |
+
|
| 48 |
+
/* Панель инструментов и вкладок */
|
| 49 |
+
.toolbar-wrapper { display: flex; flex-direction: column; background: #eaedf1; border-bottom: 1px solid var(--gray-border); }
|
| 50 |
+
.file-tabs { display: flex; align-items: center; background: #e2e6ea; padding: 5px 10px 0 10px; border-bottom: 1px solid var(--gray-border); }
|
| 51 |
+
.file-tab { padding: 8px 15px; background: white; border: 1px solid var(--gray-border); border-bottom: 1px solid white; border-radius: 4px 4px 0 0; font-family: monospace; font-size: 0.9em; cursor: pointer; margin-right: 5px; position: relative; bottom: -1px; }
|
| 52 |
+
.btn-add-file { color: var(--text-muted); padding: 5px; cursor: pointer; }
|
| 53 |
+
|
| 54 |
+
.toolbar-core { display: flex; justify-content: space-between; align-items: center; padding: 8px 15px; background-color: #f1f3f5; border-bottom: 1px solid var(--gray-border); }
|
| 55 |
+
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; }
|
| 56 |
+
.toolbar-btn { background: white; color: var(--text-muted); border: 1px solid var(--gray-border); border-radius: 4px; padding: 6px 12px; cursor: pointer; font-size: 0.9em; }
|
| 57 |
+
.toolbar-btn:hover { color: var(--blue-primary); background-color: #f8f9fa; }
|
| 58 |
+
.btn-run { background-color: var(--green-primary); color: white; font-weight: bold; display: flex; align-items: center; gap: 5px; }
|
| 59 |
+
.btn-run:hover { background-color: var(--green-hover); }
|
| 60 |
+
.toolbar-group { display: flex; gap: 5px; }
|
| 61 |
+
.input-group { position: relative; }
|
| 62 |
+
.input-group input { border: 1px solid var(--gray-border); border-radius: 4px; padding: 6px 10px; font-size: 0.9em; width: 200px; }
|
| 63 |
+
.input-group i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); cursor: pointer; }
|
| 64 |
+
|
| 65 |
+
/* Основная область контента */
|
| 66 |
+
.content-wrapper { flex: 1; display: flex; overflow: hidden; }
|
| 67 |
+
|
| 68 |
+
/* Редактор (слева) */
|
| 69 |
+
.editor-pane { flex: 1; border-right: 2px solid #ddd; display: flex; flex-direction: column; }
|
| 70 |
+
.CodeMirror { flex: 1; height: 100%; font-size: 14px; line-height: 1.4; border: none; }
|
| 71 |
+
|
| 72 |
+
/* Консоль (справа) */
|
| 73 |
+
.output-pane { flex: 1; display: flex; }
|
| 74 |
+
.output-sidebar { width: 40px; background-color: #f1f3f5; border-right: 1px solid var(--gray-border); display: flex; flex-direction: column; align-items: center; padding-top: 10px; gap: 15px; }
|
| 75 |
+
.sidebar-icon { color: var(--text-muted); cursor: pointer; font-size: 1.1em; }
|
| 76 |
+
.sidebar-icon:hover, .sidebar-icon.active { color: var(--blue-primary); }
|
| 77 |
+
|
| 78 |
+
.output-main { flex: 1; display: flex; flex-direction: column; background: white; }
|
| 79 |
+
.output-header-pane { border-bottom: 1px solid var(--gray-border); padding: 5px 15px; color: var(--text-muted); font-size: 0.85em; text-transform: uppercase; font-weight: bold; background: #f8f9fa; }
|
| 80 |
+
.output-body { flex: 1; padding: 15px; white-space: pre-wrap; font-family: 'Courier New', Courier, monospace; overflow-y: auto; color: #333; font-size: 14px; }
|
| 81 |
+
.loading-text { color: var(--text-muted); }
|
| 82 |
+
|
| 83 |
+
/* Статус-бар (внизу) */
|
| 84 |
+
.status-bar { background-color: #eaedf1; color: var(--text-muted); font-size: 0.8em; padding: 4px 15px; border-top: 1px solid var(--gray-border); display: flex; justify-content: flex-start; gap: 15px; }
|
| 85 |
+
</style>
|
| 86 |
+
</head>
|
| 87 |
+
<body>
|
| 88 |
+
<header class="header">
|
| 89 |
+
<div class="header-left">
|
| 90 |
+
<i class="fa-brands fa-python"></i> <span>ONLINE PYTHON</span>
|
| 91 |
+
</div>
|
| 92 |
+
<div class="header-right">
|
| 93 |
+
<a href="#" class="btn-learn">Learn Python</a>
|
| 94 |
+
<a href="#" class="btn-try-new">Try New IDE <i class="fa-solid fa-arrow-right-long"></i></a>
|
| 95 |
+
</div>
|
| 96 |
+
</header>
|
| 97 |
+
|
| 98 |
+
<div class="toolbar-wrapper">
|
| 99 |
+
<div class="file-tabs">
|
| 100 |
+
<div class="file-tab">main.py</div>
|
| 101 |
+
<i class="fa-solid fa-plus btn-add-file"></i>
|
| 102 |
+
</div>
|
| 103 |
+
<div class="toolbar-core">
|
| 104 |
+
<div class="toolbar-left">
|
| 105 |
+
<div class="toolbar-group">
|
| 106 |
+
<button class="toolbar-btn"><i class="fa-solid fa-arrow-rotate-left"></i></button>
|
| 107 |
+
<button class="toolbar-btn"><i class="fa-solid fa-arrow-rotate-right"></i></button>
|
| 108 |
+
<button class="toolbar-btn"><i class="fa-solid fa-arrow-right-from-bracket"></i></button>
|
| 109 |
+
</div>
|
| 110 |
+
<button class="toolbar-btn" style="color: black;"><i class="fa-solid fa-plus-circle"></i> Install Module</button>
|
| 111 |
+
</div>
|
| 112 |
+
<div class="toolbar-right">
|
| 113 |
+
<button onclick="runCode()" class="toolbar-btn btn-run"><i class="fa-solid fa-play"></i> Run</button>
|
| 114 |
+
<button class="toolbar-btn"><i class="fa-solid fa-share-nodes"></i> Share</button>
|
| 115 |
+
<div class="input-group">
|
| 116 |
+
<input type="text" placeholder="Command Line Arguments">
|
| 117 |
+
<i class="fa-solid fa-paperclip"></i>
|
| 118 |
+
</div>
|
| 119 |
+
<div class="toolbar-group">
|
| 120 |
+
<button class="toolbar-btn"><i class="fa-solid fa-user-circle"></i></button>
|
| 121 |
+
<button class="toolbar-btn"><i class="fa-solid fa-moon"></i></button>
|
| 122 |
+
<button class="toolbar-btn"><i class="fa-solid fa-cog"></i></button>
|
| 123 |
+
<button class="toolbar-btn"><i class="fa-solid fa-life-ring"></i></button>
|
| 124 |
+
</div>
|
| 125 |
+
</div>
|
| 126 |
+
</div>
|
| 127 |
+
</div>
|
| 128 |
+
|
| 129 |
+
<div class="content-wrapper">
|
| 130 |
+
<div class="editor-pane">
|
| 131 |
+
<textarea id="editor"></textarea>
|
| 132 |
+
</div>
|
| 133 |
+
<div class="output-pane">
|
| 134 |
+
<div class="output-sidebar">
|
| 135 |
+
<i class="fa-solid fa-terminal sidebar-icon active"></i>
|
| 136 |
+
<i class="fa-solid fa-folder-open sidebar-icon"></i>
|
| 137 |
+
<i class="fa-solid fa-search sidebar-icon"></i>
|
| 138 |
+
<i class="fa-solid fa-code-merge sidebar-icon"></i>
|
| 139 |
+
</div>
|
| 140 |
+
<div class="output-main">
|
| 141 |
+
<div class="output-header-pane">Terminal / Output</div>
|
| 142 |
+
<div id="output" class="output-body">Process finished with exit code 0</div>
|
| 143 |
+
</div>
|
| 144 |
+
</div>
|
| 145 |
+
</div>
|
| 146 |
+
|
| 147 |
+
<footer class="status-bar">
|
| 148 |
+
<span>Ln: <span id="line-count">1</span>, Col: <span id="col-count">1</span></span>
|
| 149 |
+
</footer>
|
| 150 |
+
|
| 151 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/codemirror.min.js"></script>
|
| 152 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/python/python.min.js"></script>
|
| 153 |
+
|
| 154 |
+
<script>
|
| 155 |
+
// Инициализация редактора со светлой темой
|
| 156 |
+
var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
|
| 157 |
+
mode: "python",
|
| 158 |
+
theme: "default", // Светлая тема
|
| 159 |
+
lineNumbers: true,
|
| 160 |
+
indentUnit: 4,
|
| 161 |
+
matchBrackets: true,
|
| 162 |
+
autofocus: true
|
| 163 |
+
});
|
| 164 |
+
|
| 165 |
+
// Установка начального кода, как на скриншоте
|
| 166 |
+
editor.setValue("# Online Python - IDE, Editor, Compiler, Interpreter\n\ndef sum(a, b):\n return (a + b)\n\na = int(input('Enter 1st number: '))\nb = int(input('Enter 2nd number: '))\n\nprint(f'Sum of {a} and {b} is {sum(a, b)}')\n");
|
| 167 |
+
|
| 168 |
+
// Обновление статус-бара
|
| 169 |
+
function updateStatusBar() {
|
| 170 |
+
var cursor = editor.getCursor();
|
| 171 |
+
document.getElementById('line-count').innerText = cursor.line + 1;
|
| 172 |
+
document.getElementById('col-count').innerText = cursor.ch + 1;
|
| 173 |
+
}
|
| 174 |
+
editor.on('cursorActivity', updateStatusBar);
|
| 175 |
+
updateStatusBar(); // Инициализация при загрузке
|
| 176 |
+
|
| 177 |
+
// Функция «запуска кода» (отправка запроса к ИИ)
|
| 178 |
+
async function runCode() {
|
| 179 |
+
const code = editor.getValue();
|
| 180 |
+
const outputDiv = document.getElementById("output");
|
| 181 |
+
|
| 182 |
+
outputDiv.innerHTML = "<span class='loading-text'>Executing main.py...</span>";
|
| 183 |
+
|
| 184 |
+
try {
|
| 185 |
+
const response = await fetch('/run', {
|
| 186 |
+
method: 'POST',
|
| 187 |
+
headers: { 'Content-Type': 'application/json' },
|
| 188 |
+
body: JSON.stringify({ code: code })
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
const data = await response.json();
|
| 192 |
+
|
| 193 |
+
// 1. Превращаем Markdown в HTML
|
| 194 |
+
let formattedHTML = marked.parse(data.output);
|
| 195 |
+
|
| 196 |
+
// 2. Вставляем в блок вывода
|
| 197 |
+
outputDiv.innerHTML = formattedHTML;
|
| 198 |
+
|
| 199 |
+
// 3. Запускаем рендер формул KaTeX
|
| 200 |
+
renderMathInElement(outputDiv, {
|
| 201 |
+
delimiters: [
|
| 202 |
+
{left: '$$', right: '$$', display: true},
|
| 203 |
+
{left: '$', right: '$', display: false},
|
| 204 |
+
{left: '\\(', right: '\\)', display: false},
|
| 205 |
+
{left: '\\[', right: '\\]', display: true}
|
| 206 |
+
],
|
| 207 |
+
throwOnError : false
|
| 208 |
+
});
|
| 209 |
+
|
| 210 |
+
// Добавляем финальную строчку
|
| 211 |
+
outputDiv.innerHTML += "<hr style='border:0; border-top:1px solid #eee; margin: 10px 0;'><span style='color: #6c757d; font-size: 0.9em;'>Process finished with exit code 0</span>";
|
| 212 |
+
|
| 213 |
+
} catch (err) {
|
| 214 |
+
outputDiv.innerText = "Error: Could not connect to the compilation server.";
|
| 215 |
+
console.error(err);
|
| 216 |
+
}
|
| 217 |
+
}
|
| 218 |
+
</script>
|
| 219 |
+
</body>
|
| 220 |
+
</html>
|