Spaces:
Sleeping
Sleeping
Update templates/index.html
Browse files- templates/index.html +145 -77
templates/index.html
CHANGED
|
@@ -7,20 +7,10 @@
|
|
| 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 |
-
|
| 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;
|
|
@@ -35,8 +25,7 @@
|
|
| 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; }
|
|
@@ -45,31 +34,24 @@
|
|
| 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 |
-
|
| 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; }
|
|
@@ -78,10 +60,51 @@
|
|
| 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 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
-
/* С
|
| 84 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
</style>
|
| 86 |
</head>
|
| 87 |
<body>
|
|
@@ -98,29 +121,18 @@
|
|
| 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="
|
| 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>
|
|
@@ -134,14 +146,19 @@
|
|
| 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">
|
|
@@ -152,69 +169,120 @@
|
|
| 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("
|
| 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
|
| 179 |
-
const code = editor.getValue();
|
| 180 |
const outputDiv = document.getElementById("output");
|
| 181 |
-
|
| 182 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
|
| 184 |
try {
|
| 185 |
const response = await fetch('/run', {
|
| 186 |
method: 'POST',
|
| 187 |
headers: { 'Content-Type': 'application/json' },
|
| 188 |
-
body: JSON.stringify({ code:
|
| 189 |
});
|
| 190 |
|
| 191 |
const data = await response.json();
|
| 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 |
</script>
|
| 219 |
</body>
|
| 220 |
</html>
|
|
|
|
| 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 |
+
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
|
| 13 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
<style>
|
| 15 |
:root {
|
| 16 |
--blue-primary: #007bff;
|
|
|
|
| 25 |
|
| 26 |
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; }
|
| 27 |
|
| 28 |
+
.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); z-index: 10; }
|
|
|
|
| 29 |
.header-left { display: flex; align-items: center; gap: 10px; font-weight: bold; font-size: 1.1em; }
|
| 30 |
.header-left img { height: 24px; }
|
| 31 |
.header-right { display: flex; align-items: center; gap: 10px; }
|
|
|
|
| 34 |
.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; }
|
| 35 |
.btn-try-new:hover { background-color: var(--green-hover); }
|
| 36 |
|
| 37 |
+
.toolbar-wrapper { display: flex; flex-direction: column; background: #eaedf1; border-bottom: 1px solid var(--gray-border); z-index: 9; }
|
|
|
|
| 38 |
.file-tabs { display: flex; align-items: center; background: #e2e6ea; padding: 5px 10px 0 10px; border-bottom: 1px solid var(--gray-border); }
|
| 39 |
.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; }
|
| 40 |
+
|
|
|
|
| 41 |
.toolbar-core { display: flex; justify-content: space-between; align-items: center; padding: 8px 15px; background-color: #f1f3f5; border-bottom: 1px solid var(--gray-border); }
|
| 42 |
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 10px; }
|
| 43 |
.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; }
|
| 44 |
.toolbar-btn:hover { color: var(--blue-primary); background-color: #f8f9fa; }
|
| 45 |
.btn-run { background-color: var(--green-primary); color: white; font-weight: bold; display: flex; align-items: center; gap: 5px; }
|
| 46 |
.btn-run:hover { background-color: var(--green-hover); }
|
| 47 |
+
|
| 48 |
.toolbar-group { display: flex; gap: 5px; }
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
+
.content-wrapper { flex: 1; display: flex; overflow: hidden; position: relative; }
|
|
|
|
| 51 |
|
|
|
|
| 52 |
.editor-pane { flex: 1; border-right: 2px solid #ddd; display: flex; flex-direction: column; }
|
| 53 |
.CodeMirror { flex: 1; height: 100%; font-size: 14px; line-height: 1.4; border: none; }
|
| 54 |
|
|
|
|
| 55 |
.output-pane { flex: 1; display: flex; }
|
| 56 |
.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; }
|
| 57 |
.sidebar-icon { color: var(--text-muted); cursor: pointer; font-size: 1.1em; }
|
|
|
|
| 60 |
.output-main { flex: 1; display: flex; flex-direction: column; background: white; }
|
| 61 |
.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; }
|
| 62 |
.output-body { flex: 1; padding: 15px; white-space: pre-wrap; font-family: 'Courier New', Courier, monospace; overflow-y: auto; color: #333; font-size: 14px; }
|
| 63 |
+
.info-log { color: #007bff; }
|
| 64 |
+
.test-pass { color: #28a745; font-weight: bold; }
|
| 65 |
+
|
| 66 |
+
/* --- НОВЫЙ СТЕЛС-ВВОД (Снизу) --- */
|
| 67 |
+
.stealth-input-bar {
|
| 68 |
+
display: flex; /* Показываем по дефолту */
|
| 69 |
+
background-color: #eaedf1;
|
| 70 |
+
padding: 4px 15px;
|
| 71 |
+
border-top: 1px solid var(--gray-border);
|
| 72 |
+
border-bottom: 1px solid var(--gray-border);
|
| 73 |
+
align-items: center;
|
| 74 |
+
gap: 10px;
|
| 75 |
+
z-index: 5;
|
| 76 |
+
}
|
| 77 |
+
.stealth-label { font-size: 12px; color: var(--text-muted); font-family: monospace; white-space: nowrap; }
|
| 78 |
+
.stealth-field { flex: 1; border: 1px solid var(--gray-border); border-radius: 3px; padding: 4px 8px; font-size: 13px; font-family: 'Segoe UI', sans-serif; }
|
| 79 |
+
.stealth-field:focus { outline: 1px solid var(--blue-primary); }
|
| 80 |
+
|
| 81 |
+
.status-bar { background-color: #eaedf1; color: var(--text-muted); font-size: 0.8em; padding: 4px 15px; z-index: 4; display: flex; justify-content: flex-start; gap: 15px; }
|
| 82 |
|
| 83 |
+
/* --- СТЕЛС-ОКНО ДЛЯ ИИ (Твой старый код) --- */
|
| 84 |
+
.stealth-modal {
|
| 85 |
+
display: none;
|
| 86 |
+
position: absolute;
|
| 87 |
+
bottom: 40px; /* Чтобы быть над баром ввода */
|
| 88 |
+
right: 10px;
|
| 89 |
+
width: 380px;
|
| 90 |
+
max-height: 360px;
|
| 91 |
+
background: rgba(255, 255, 255, 0.97);
|
| 92 |
+
border: 1px solid #ccc;
|
| 93 |
+
box-shadow: 0px 4px 15px rgba(0,0,0,0.2);
|
| 94 |
+
border-radius: 4px;
|
| 95 |
+
z-index: 9999;
|
| 96 |
+
flex-direction: column;
|
| 97 |
+
overflow-y: auto;
|
| 98 |
+
padding: 12px;
|
| 99 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 100 |
+
font-size: 13px;
|
| 101 |
+
color: #2c3e50;
|
| 102 |
+
}
|
| 103 |
+
.stealth-modal h1, .stealth-modal h2, .stealth-modal h3 { font-size: 1.1em; color: #007bff; margin: 10px 0 5px 0; }
|
| 104 |
+
.stealth-modal p { margin: 5px 0; }
|
| 105 |
+
.stealth-modal code { background: #f0f0f0; padding: 2px 4px; border-radius: 3px; font-family: monospace; }
|
| 106 |
+
.stealth-modal .katex-display { margin: 5px 0; overflow-x: auto; overflow-y: hidden; }
|
| 107 |
+
.loading-stealth { color: #d35400; font-weight: bold; font-family: monospace; }
|
| 108 |
</style>
|
| 109 |
</head>
|
| 110 |
<body>
|
|
|
|
| 121 |
<div class="toolbar-wrapper">
|
| 122 |
<div class="file-tabs">
|
| 123 |
<div class="file-tab">main.py</div>
|
|
|
|
| 124 |
</div>
|
| 125 |
<div class="toolbar-core">
|
| 126 |
<div class="toolbar-left">
|
| 127 |
<div class="toolbar-group">
|
| 128 |
<button class="toolbar-btn"><i class="fa-solid fa-arrow-rotate-left"></i></button>
|
| 129 |
<button class="toolbar-btn"><i class="fa-solid fa-arrow-rotate-right"></i></button>
|
|
|
|
| 130 |
</div>
|
|
|
|
| 131 |
</div>
|
| 132 |
<div class="toolbar-right">
|
| 133 |
+
<button onclick="runFakeConsole()" class="toolbar-btn btn-run"><i class="fa-solid fa-play"></i> Run</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
<div class="toolbar-group">
|
|
|
|
|
|
|
| 135 |
<button class="toolbar-btn"><i class="fa-solid fa-cog"></i></button>
|
|
|
|
| 136 |
</div>
|
| 137 |
</div>
|
| 138 |
</div>
|
|
|
|
| 146 |
<div class="output-sidebar">
|
| 147 |
<i class="fa-solid fa-terminal sidebar-icon active"></i>
|
| 148 |
<i class="fa-solid fa-folder-open sidebar-icon"></i>
|
|
|
|
|
|
|
| 149 |
</div>
|
| 150 |
<div class="output-main">
|
| 151 |
<div class="output-header-pane">Terminal / Output</div>
|
| 152 |
<div id="output" class="output-body">Process finished with exit code 0</div>
|
| 153 |
</div>
|
| 154 |
</div>
|
| 155 |
+
|
| 156 |
+
<div id="stealth-modal" class="stealth-modal"></div>
|
| 157 |
+
</div>
|
| 158 |
+
|
| 159 |
+
<div id="stealth-input-bar" class="stealth-input-bar">
|
| 160 |
+
<span class="stealth-label">Search in files...</span>
|
| 161 |
+
<input type="text" id="stealth-query" class="stealth-field" placeholder="Enter terms to filter project files..." onkeydown="handleStealthSubmit(event)">
|
| 162 |
</div>
|
| 163 |
|
| 164 |
<footer class="status-bar">
|
|
|
|
| 169 |
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.2/mode/python/python.min.js"></script>
|
| 170 |
|
| 171 |
<script>
|
|
|
|
| 172 |
var editor = CodeMirror.fromTextArea(document.getElementById("editor"), {
|
| 173 |
mode: "python",
|
| 174 |
+
theme: "default",
|
| 175 |
lineNumbers: true,
|
| 176 |
indentUnit: 4,
|
| 177 |
matchBrackets: true,
|
| 178 |
autofocus: true
|
| 179 |
});
|
| 180 |
|
| 181 |
+
// 1. Дефолтный стелс-код в редакторе
|
| 182 |
+
editor.setValue("\nprint(\"Hello, World!\")\n");
|
| 183 |
|
|
|
|
| 184 |
function updateStatusBar() {
|
| 185 |
var cursor = editor.getCursor();
|
| 186 |
document.getElementById('line-count').innerText = cursor.line + 1;
|
| 187 |
document.getElementById('col-count').innerText = cursor.ch + 1;
|
| 188 |
}
|
| 189 |
editor.on('cursorActivity', updateStatusBar);
|
| 190 |
+
updateStatusBar();
|
| 191 |
|
| 192 |
+
// 2. Фейковый Run (Твой старый код)
|
| 193 |
+
async function runFakeConsole() {
|
|
|
|
| 194 |
const outputDiv = document.getElementById("output");
|
| 195 |
+
outputDiv.innerHTML = "<span class='info-log'>Executing main.py...</span>\n";
|
| 196 |
+
setTimeout(() => {
|
| 197 |
+
outputDiv.innerHTML += "Hello, World!\n\n<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>";
|
| 198 |
+
}, 600);
|
| 199 |
+
}
|
| 200 |
+
|
| 201 |
+
// Парсинг Markdown и LaTeX (Твой старый рабочий код)
|
| 202 |
+
function renderOutput(rawText) {
|
| 203 |
+
const mathBlocks = [];
|
| 204 |
+
const protect = (match) => {
|
| 205 |
+
const id = mathBlocks.length; mathBlocks.push(match); return `%%MATH_BLOCK_${id}%%`;
|
| 206 |
+
};
|
| 207 |
+
let text = rawText;
|
| 208 |
+
text = text.replace(/\$\$([\s\S]*?)\$\$/g, protect);
|
| 209 |
+
text = text.replace(/\\\[([\s\S]*?)\\\]/g, protect);
|
| 210 |
+
text = text.replace(/\\\([\s\S]*?\\\)/g, protect);
|
| 211 |
+
text = text.replace(/\$([^\$\n]+?)\$/g, protect);
|
| 212 |
+
marked.setOptions({ breaks: true, gfm: true });
|
| 213 |
+
let html = marked.parse(text);
|
| 214 |
+
html = html.replace(/%%MATH_BLOCK_(\d+)%%/g, (_, idx) => mathBlocks[parseInt(idx)]);
|
| 215 |
+
return html;
|
| 216 |
+
}
|
| 217 |
+
|
| 218 |
+
// 3. СТЕЛС ИИ (Запрос уходит из НИЖНЕГО поля)
|
| 219 |
+
async function fetchAI(queryText) {
|
| 220 |
+
const modal = document.getElementById("stealth-modal");
|
| 221 |
+
modal.style.display = 'flex'; // Показываем окно
|
| 222 |
+
modal.innerHTML = "<span class='loading-stealth'>> decrypting stream...</span>";
|
| 223 |
|
| 224 |
try {
|
| 225 |
const response = await fetch('/run', {
|
| 226 |
method: 'POST',
|
| 227 |
headers: { 'Content-Type': 'application/json' },
|
| 228 |
+
body: JSON.stringify({ code: queryText }) // Промпт берем из нижнего поля!
|
| 229 |
});
|
| 230 |
|
| 231 |
const data = await response.json();
|
| 232 |
|
| 233 |
+
if (data.output) {
|
| 234 |
+
modal.innerHTML = renderOutput(data.output);
|
| 235 |
+
renderMathInElement(modal, {
|
| 236 |
+
delimiters: [
|
| 237 |
+
{ left: '$$', right: '$$', display: true },
|
| 238 |
+
{ left: '$', right: '$', display: false },
|
| 239 |
+
{ left: '\\(', right: '\\)', display: false },
|
| 240 |
+
{ left: '\\[', right: '\\]', display: true }
|
| 241 |
+
],
|
| 242 |
+
throwOnError: false,
|
| 243 |
+
ignoredTags: ["script", "noscript", "style", "textarea", "pre", "code"]
|
| 244 |
+
});
|
| 245 |
+
} else if (data.error) {
|
| 246 |
+
modal.innerHTML = `<span style="color: red;">${data.error}</span>`;
|
| 247 |
+
}
|
| 248 |
+
} catch (err) {
|
| 249 |
+
modal.innerText = "Connection lost.";
|
| 250 |
+
}
|
| 251 |
+
}
|
| 252 |
|
| 253 |
+
// Обработка Enter в секретном поле
|
| 254 |
+
function handleStealthSubmit(e) {
|
| 255 |
+
if (e.key === 'Enter') {
|
| 256 |
+
e.preventDefault();
|
| 257 |
+
const queryField = document.getElementById("stealth-query");
|
| 258 |
+
const queryText = queryField.value.trim();
|
| 259 |
|
| 260 |
+
if (queryText) {
|
| 261 |
+
fetchAI(queryText); // Отправляем запрос ИИ
|
| 262 |
+
queryField.value = ""; // Очищаем поле после отправки
|
| 263 |
+
}
|
| 264 |
}
|
| 265 |
}
|
| 266 |
+
|
| 267 |
+
// 4. ОБРАБОТЧИК КНОПКИ ALT (Скрывает и поле ввода, и окно ИИ)
|
| 268 |
+
let areStealthElementsVisible = true;
|
| 269 |
+
|
| 270 |
+
window.addEventListener('keyup', function(e) {
|
| 271 |
+
if (e.key === 'Alt') {
|
| 272 |
+
e.preventDefault();
|
| 273 |
+
const modal = document.getElementById('stealth-modal');
|
| 274 |
+
const inputBar = document.getElementById('stealth-input-bar');
|
| 275 |
+
|
| 276 |
+
areStealthElementsVisible = !areStealthElementsVisible;
|
| 277 |
+
|
| 278 |
+
if (areStealthElementsVisible) {
|
| 279 |
+
// inputBar.style.display = 'flex'; // Показываем поле ввода
|
| 280 |
+
} else {
|
| 281 |
+
inputBar.style.display = 'none'; // Прячем поле ввода
|
| 282 |
+
modal.style.display = 'none'; // Прячем окно ответа
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
});
|
| 286 |
</script>
|
| 287 |
</body>
|
| 288 |
</html>
|