vortexa64 commited on
Commit
e5a1652
·
verified ·
1 Parent(s): 7b82efc

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +117 -105
index.html CHANGED
@@ -149,125 +149,137 @@
149
  </div>
150
 
151
  <script>
 
 
 
 
 
 
 
 
 
152
  function saveSetup() {
153
- const data = {
154
- username: document.getElementById("username").value,
155
- password: document.getElementById("password").value,
156
- startcmd: document.getElementById("startcmd").value
157
- };
158
 
159
- fetch("/setup", {
160
- method: "POST",
161
- headers: { "Content-Type": "application/json" },
162
- body: JSON.stringify(data)
163
- }).then(res => res.json())
164
- .then(res => alert("Saved!"))
165
- .catch(err => alert("Error saving setup."));
166
- }
167
 
168
- function startConsole() {
169
- fetch("/console/start", { method: "POST" })
170
- .then(res => res.json())
171
- .then(data => {
172
- document.getElementById("consoleOutput").value += ">>> Console started\n";
173
- });
174
- }
175
 
176
- function stopConsole() {
177
- fetch("/console/stop", { method: "POST" })
178
- .then(res => res.json())
179
- .then(data => {
180
- document.getElementById("consoleOutput").value += ">>> Console stopped\n";
181
- });
182
- }
183
 
184
- function sendInput() {
185
- const input = document.getElementById("consoleInput").value;
186
- fetch("/console/input", {
187
- method: "POST",
188
- headers: { "Content-Type": "application/json" },
189
- body: JSON.stringify({ input })
190
- })
191
- .then(res => res.json())
192
- .then(data => {
193
- document.getElementById("consoleOutput").value += data.output + "\n";
194
- document.getElementById("consoleInput").value = "";
195
- });
196
- }
197
 
198
- function refreshFileList() {
199
- fetch("/files")
200
- .then(res => res.json())
201
- .then(files => {
202
- const list = document.getElementById("fileList");
203
- list.innerHTML = "";
204
- files.forEach(name => {
205
- const li = document.createElement("li");
206
- li.textContent = name;
207
- list.appendChild(li);
 
 
208
  });
209
- });
210
- }
211
 
212
- function createFile() {
213
- const name = prompt("File name:");
214
- if (!name) return;
215
- fetch("/file/create", {
216
- method: "POST",
217
- headers: { "Content-Type": "application/json" },
218
- body: JSON.stringify({ name })
219
- }).then(() => refreshFileList());
220
- }
221
 
222
- function createFolder() {
223
- const name = prompt("Folder name:");
224
- if (!name) return;
225
- fetch("/folder/create", {
226
- method: "POST",
227
- headers: { "Content-Type": "application/json" },
228
- body: JSON.stringify({ name })
229
- }).then(() => refreshFileList());
230
- }
231
 
232
- function deleteItem() {
233
- const name = prompt("File/Folder name to delete:");
234
- if (!name) return;
235
- fetch("/delete", {
236
- method: "POST",
237
- headers: { "Content-Type": "application/json" },
238
- body: JSON.stringify({ name })
239
- }).then(() => refreshFileList());
240
- }
241
 
242
- function renameItem() {
243
- const oldName = prompt("Old name:");
244
- const newName = prompt("New name:");
245
- if (!oldName || !newName) return;
246
- fetch("/rename", {
247
- method: "POST",
248
- headers: { "Content-Type": "application/json" },
249
- body: JSON.stringify({ old_name: oldName, new_name: newName })
250
- }).then(() => refreshFileList());
251
- }
252
 
253
- function uploadFile() {
254
- const fileInput = document.getElementById("uploadFile");
255
- const file = fileInput.files[0];
256
- const formData = new FormData();
257
- formData.append("file", file);
 
258
 
259
- fetch("/upload", {
260
- method: "POST",
261
- body: formData
262
- }).then(() => {
263
- alert("Uploaded!");
264
- refreshFileList();
265
- fileInput.value = "";
266
- });
267
- }
268
 
269
- window.onload = refreshFileList;
 
 
270
  </script>
271
-
272
  </body>
273
  </html>
 
149
  </div>
150
 
151
  <script>
152
+ function showTab(id) {
153
+ document.querySelectorAll(".tab").forEach(tab => tab.classList.remove("active"));
154
+ document.querySelectorAll("nav button").forEach(btn => btn.classList.remove("active"));
155
+ document.getElementById(id).classList.add("active");
156
+ document.getElementById("tab-" + id).classList.add("active");
157
+
158
+ if (id === "filemanager") refreshFileList();
159
+ }
160
+
161
  function saveSetup() {
162
+ const data = {
163
+ username: document.getElementById("username").value,
164
+ password: document.getElementById("password").value,
165
+ startcmd: document.getElementById("startcmd").value
166
+ };
167
 
168
+ fetch("/setup", {
169
+ method: "POST",
170
+ headers: { "Content-Type": "application/json" },
171
+ body: JSON.stringify(data)
172
+ }).then(res => res.json())
173
+ .then(res => alert("Saved!"))
174
+ .catch(err => alert("Error saving setup."));
175
+ }
176
 
177
+ function startConsole() {
178
+ fetch("/console/start", { method: "POST" })
179
+ .then(res => res.json())
180
+ .then(data => {
181
+ document.getElementById("output").textContent += ">>> Console started\n";
182
+ });
183
+ }
184
 
185
+ function stopConsole() {
186
+ fetch("/console/stop", { method: "POST" })
187
+ .then(res => res.json())
188
+ .then(data => {
189
+ document.getElementById("output").textContent += ">>> Console stopped\n";
190
+ });
191
+ }
192
 
193
+ function sendInput() {
194
+ const input = document.getElementById("consoleInput").value;
195
+ fetch("/console/input", {
196
+ method: "POST",
197
+ headers: { "Content-Type": "application/json" },
198
+ body: JSON.stringify({ input })
199
+ })
200
+ .then(res => res.json())
201
+ .then(data => {
202
+ document.getElementById("output").textContent += data.output + "\n";
203
+ document.getElementById("consoleInput").value = "";
204
+ });
205
+ }
206
 
207
+ function refreshFileList() {
208
+ fetch("/files")
209
+ .then(res => res.json())
210
+ .then(files => {
211
+ const list = document.getElementById("fileList");
212
+ list.innerHTML = "";
213
+ files.forEach(name => {
214
+ const entry = document.createElement("div");
215
+ entry.className = "file-entry";
216
+ entry.textContent = name;
217
+ list.appendChild(entry);
218
+ });
219
  });
220
+ }
 
221
 
222
+ function createFile() {
223
+ const name = prompt("File name:");
224
+ if (!name) return;
225
+ fetch("/file/create", {
226
+ method: "POST",
227
+ headers: { "Content-Type": "application/json" },
228
+ body: JSON.stringify({ name })
229
+ }).then(() => refreshFileList());
230
+ }
231
 
232
+ function createFolder() {
233
+ const name = prompt("Folder name:");
234
+ if (!name) return;
235
+ fetch("/folder/create", {
236
+ method: "POST",
237
+ headers: { "Content-Type": "application/json" },
238
+ body: JSON.stringify({ name })
239
+ }).then(() => refreshFileList());
240
+ }
241
 
242
+ function deleteItem() {
243
+ const name = prompt("File/Folder name to delete:");
244
+ if (!name) return;
245
+ fetch("/delete", {
246
+ method: "POST",
247
+ headers: { "Content-Type": "application/json" },
248
+ body: JSON.stringify({ name })
249
+ }).then(() => refreshFileList());
250
+ }
251
 
252
+ function renameItem() {
253
+ const oldName = prompt("Old name:");
254
+ const newName = prompt("New name:");
255
+ if (!oldName || !newName) return;
256
+ fetch("/rename", {
257
+ method: "POST",
258
+ headers: { "Content-Type": "application/json" },
259
+ body: JSON.stringify({ old_name: oldName, new_name: newName })
260
+ }).then(() => refreshFileList());
261
+ }
262
 
263
+ function uploadFile() {
264
+ const fileInput = document.getElementById("uploadFile");
265
+ const file = fileInput.files[0];
266
+ if (!file) return;
267
+ const formData = new FormData();
268
+ formData.append("file", file);
269
 
270
+ fetch("/upload", {
271
+ method: "POST",
272
+ body: formData
273
+ }).then(() => {
274
+ alert("Uploaded!");
275
+ refreshFileList();
276
+ fileInput.value = "";
277
+ });
278
+ }
279
 
280
+ window.onload = () => {
281
+ refreshFileList();
282
+ };
283
  </script>
 
284
  </body>
285
  </html>