Update index.html
Browse files- index.html +99 -50
index.html
CHANGED
|
@@ -149,75 +149,124 @@
|
|
| 149 |
</div>
|
| 150 |
|
| 151 |
<script>
|
| 152 |
-
function showTab(tab) {
|
| 153 |
-
document.querySelectorAll(".tab").forEach(el => el.classList.remove("active"));
|
| 154 |
-
document.querySelectorAll("nav button").forEach(el => el.classList.remove("active"));
|
| 155 |
-
document.getElementById(tab).classList.add("active");
|
| 156 |
-
document.getElementById("tab-" + tab).classList.add("active");
|
| 157 |
-
}
|
| 158 |
-
|
| 159 |
function saveSetup() {
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
}
|
| 166 |
-
|
| 167 |
-
function stopConsole() {
|
| 168 |
-
alert("Script stopped (dummy)!");
|
| 169 |
-
}
|
| 170 |
-
|
| 171 |
-
function sendInput() {
|
| 172 |
-
const val = document.getElementById("consoleInput").value;
|
| 173 |
-
const outputBox = document.getElementById("output");
|
| 174 |
-
outputBox.textContent += "\n> " + val;
|
| 175 |
-
document.getElementById("consoleInput").value = "";
|
| 176 |
-
}
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
function uploadFile() {
|
| 180 |
-
const fileInput = document.getElementById("uploadFile");
|
| 181 |
-
const file = fileInput.files[0];
|
| 182 |
-
const formData = new FormData();
|
| 183 |
-
formData.append("file", file);
|
| 184 |
|
| 185 |
-
fetch("/
|
| 186 |
method: "POST",
|
| 187 |
-
|
|
|
|
| 188 |
}).then(res => res.json())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
.then(data => {
|
| 190 |
-
|
| 191 |
-
|
| 192 |
});
|
| 193 |
}
|
| 194 |
|
| 195 |
-
function
|
| 196 |
fetch("/files")
|
| 197 |
.then(res => res.json())
|
| 198 |
.then(files => {
|
| 199 |
const list = document.getElementById("fileList");
|
| 200 |
list.innerHTML = "";
|
| 201 |
-
files.forEach(
|
| 202 |
-
|
|
|
|
|
|
|
| 203 |
});
|
| 204 |
});
|
| 205 |
}
|
| 206 |
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
|
| 217 |
-
|
| 218 |
-
const name = document.getElementById("newName").value;
|
| 219 |
-
document.getElementById("fileList").innerHTML += `<div class="file-entry"><b>${name}/</b> <span>[📁 ✏️ ❌]</span></div>`;
|
| 220 |
-
}
|
| 221 |
</script>
|
| 222 |
|
| 223 |
</body>
|
|
|
|
| 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>
|