Update index.html
Browse files- index.html +117 -105
index.html
CHANGED
|
@@ -149,125 +149,137 @@
|
|
| 149 |
</div>
|
| 150 |
|
| 151 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
function saveSetup() {
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
}
|
| 167 |
|
| 168 |
-
function startConsole() {
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
}
|
| 175 |
|
| 176 |
-
function stopConsole() {
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
}
|
| 183 |
|
| 184 |
-
function sendInput() {
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
}
|
| 197 |
|
| 198 |
-
function refreshFileList() {
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
|
|
|
|
|
|
| 208 |
});
|
| 209 |
-
|
| 210 |
-
}
|
| 211 |
|
| 212 |
-
function createFile() {
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
}
|
| 221 |
|
| 222 |
-
function createFolder() {
|
| 223 |
-
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
-
|
| 228 |
-
|
| 229 |
-
|
| 230 |
-
}
|
| 231 |
|
| 232 |
-
function deleteItem() {
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
}
|
| 241 |
|
| 242 |
-
function renameItem() {
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
}
|
| 252 |
|
| 253 |
-
function uploadFile() {
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
|
|
|
| 258 |
|
| 259 |
-
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
}
|
| 268 |
|
| 269 |
-
window.onload =
|
|
|
|
|
|
|
| 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>
|