Artificial-superintelligence commited on
Commit
53024fd
·
verified ·
1 Parent(s): 2a6bd1c

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +73 -1
templates/index.html CHANGED
@@ -29,6 +29,7 @@
29
  background-color: #111;
30
  padding: 10px;
31
  overflow-y: auto;
 
32
  }
33
  #output {
34
  margin-bottom: 20px;
@@ -58,6 +59,37 @@
58
  .file-item:hover {
59
  background-color: #222;
60
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  @keyframes glitch {
62
  0% {
63
  text-shadow: 0.05em 0 0 #00fffc, -0.05em -0.025em 0 #fc00ff,
@@ -107,10 +139,20 @@
107
  <div id="file-list"></div>
108
  </div>
109
  </div>
 
 
 
 
110
  <script>
111
  const outputDiv = document.getElementById('output');
112
  const codeInput = document.getElementById('code-input');
113
  const fileList = document.getElementById('file-list');
 
 
 
 
 
 
114
 
115
  function addToOutput(text) {
116
  outputDiv.innerHTML += text + '\n';
@@ -129,7 +171,13 @@
129
  .then(response => response.json())
130
  .then(data => {
131
  addToOutput(data.result);
132
- updateFileList();
 
 
 
 
 
 
133
  })
134
  .catch(error => {
135
  addToOutput(`Error: ${error}`);
@@ -166,6 +214,20 @@
166
  });
167
  }
168
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  codeInput.addEventListener('keydown', function(event) {
170
  if (event.key === 'Enter') {
171
  executeCode();
@@ -177,6 +239,16 @@
177
 
178
  // Initial message
179
  addToOutput("Welcome to the Hacker's Python Terminal. Type your commands below.");
 
 
 
 
 
 
 
 
 
 
180
  </script>
181
  </body>
182
  </html>
 
29
  background-color: #111;
30
  padding: 10px;
31
  overflow-y: auto;
32
+ display: none;
33
  }
34
  #output {
35
  margin-bottom: 20px;
 
59
  .file-item:hover {
60
  background-color: #222;
61
  }
62
+ #file-editor {
63
+ display: none;
64
+ position: fixed;
65
+ top: 50%;
66
+ left: 50%;
67
+ transform: translate(-50%, -50%);
68
+ width: 80%;
69
+ height: 80%;
70
+ background-color: #111;
71
+ border: 1px solid #0f0;
72
+ padding: 20px;
73
+ box-shadow: 0 0 10px rgba(0, 255, 0, 0.5);
74
+ }
75
+ #editor-textarea {
76
+ width: 100%;
77
+ height: calc(100% - 40px);
78
+ background-color: #000;
79
+ color: #0f0;
80
+ border: none;
81
+ resize: none;
82
+ font-family: 'Courier New', monospace;
83
+ font-size: 14px;
84
+ }
85
+ #save-button {
86
+ margin-top: 10px;
87
+ padding: 5px 10px;
88
+ background-color: #0f0;
89
+ color: #000;
90
+ border: none;
91
+ cursor: pointer;
92
+ }
93
  @keyframes glitch {
94
  0% {
95
  text-shadow: 0.05em 0 0 #00fffc, -0.05em -0.025em 0 #fc00ff,
 
139
  <div id="file-list"></div>
140
  </div>
141
  </div>
142
+ <div id="file-editor">
143
+ <textarea id="editor-textarea"></textarea>
144
+ <button id="save-button">Save</button>
145
+ </div>
146
  <script>
147
  const outputDiv = document.getElementById('output');
148
  const codeInput = document.getElementById('code-input');
149
  const fileList = document.getElementById('file-list');
150
+ const fileExplorer = document.querySelector('.file-explorer');
151
+ const fileEditor = document.getElementById('file-editor');
152
+ const editorTextarea = document.getElementById('editor-textarea');
153
+ const saveButton = document.getElementById('save-button');
154
+
155
+ let currentEditingFile = '';
156
 
157
  function addToOutput(text) {
158
  outputDiv.innerHTML += text + '\n';
 
171
  .then(response => response.json())
172
  .then(data => {
173
  addToOutput(data.result);
174
+ if (data.action === "edit") {
175
+ currentEditingFile = data.filename;
176
+ editorTextarea.value = '';
177
+ fileEditor.style.display = 'block';
178
+ } else {
179
+ updateFileList();
180
+ }
181
  })
182
  .catch(error => {
183
  addToOutput(`Error: ${error}`);
 
214
  });
215
  }
216
 
217
+ saveButton.addEventListener('click', function() {
218
+ fetch("/save_file", {
219
+ method: "POST",
220
+ headers: { "Content-Type": "application/json" },
221
+ body: JSON.stringify({ filename: currentEditingFile, content: editorTextarea.value }),
222
+ })
223
+ .then(response => response.json())
224
+ .then(data => {
225
+ addToOutput(data.result);
226
+ fileEditor.style.display = 'none';
227
+ updateFileList();
228
+ });
229
+ });
230
+
231
  codeInput.addEventListener('keydown', function(event) {
232
  if (event.key === 'Enter') {
233
  executeCode();
 
239
 
240
  // Initial message
241
  addToOutput("Welcome to the Hacker's Python Terminal. Type your commands below.");
242
+ addToOutput("Available commands:");
243
+ addToOutput("- show files: Display the file explorer");
244
+ addToOutput("- hide files: Hide the file explorer");
245
+ addToOutput("- new file <filename>: Create a new file");
246
+ addToOutput("- edit <filename>: Edit an existing file");
247
+ addToOutput("- cd <directory>: Change directory");
248
+ addToOutput("- !<shell command>: Execute a shell command");
249
+ addToOutput("- pip install <package>: Install a Python package");
250
+ addToOutput("- git <command>: Execute a git command");
251
+ addToOutput("- <python code>: Execute Python code");
252
  </script>
253
  </body>
254
  </html>