
| Current Path : /home/cgabriel/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : //home/cgabriel/satellite.html |
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8">
<title>Satellite</title>
<style>
body { font-family: monospace; margin:20px; }
#viewer { margin-top:10px; border:1px solid #ccc; height:500px; overflow:auto; }
#controls { margin-top:10px; display:flex; gap:10px; }
#dirControls { display:none; }
</style>
</head>
<body>
<h3 id="title"></h3>
<!-- FILE VIEWER -->
<div id="controls">
<input id="renameInput" placeholder="Neuer Name">
<button id="renameBtn" onclick="renameFile()">Rename</button>
<button onclick="download()">Download</button>
<button id="deleteBtn" onclick="del()">Delete</button>
<button onclick="window.opener.reloadContextInstance(); window.close()">Close</button>
</div>
<iframe id="viewer" style="width:100%;height:70vh;border:0"></iframe>
<!-- DIRECTORY CONTROLS -->
<div id="dirControls">
<hr>
<h3 id="dirname"></h3>
<input id="renameDirInput" placeholder="Neuer Verzeichnisname">
<button onclick="renameDir()">Rename</button>
<hr>
<input id="newSubdirInput" placeholder="Neues Unterverzeichnis">
<button onclick="createSubdir()">Create</button>
<hr>
<button onclick="deleteDir()">Delete Directory</button>
<hr>
<button onclick="window.opener.reloadContextInstance(); window.close()">Close</button>
</div>
<script>
const params = new URLSearchParams(location.search);
const mode = params.get("mode"); // "dir" oder null
const rw = params.get("rw");
const mandant = params.get("mandant");
const subdir = params.get("subdir") || "";
let file = params.get("file");
document.getElementById("renameBtn").disabled = (rw == "0");
document.getElementById("deleteBtn").disabled = (rw == "0");
/*const viewer = document.getElementById("viewer");
if(file.endsWith(".pdf")){
viewer.innerHTML = `<embed src="/api/file?file=${encodeURIComponent(file)}" width="100%" height="100%">`;
}
else if(file.endsWith(".txt") || file.endsWith(".html") || file.endsWith(".log")){
fetch(`/api/file?file=${encodeURIComponent(file)}`)
.then(r=>r.text())
.then(t=>{
const ta = document.createElement("textarea");
ta.style.width="100%";
ta.style.height="100%";
ta.value = t;
viewer.appendChild(ta);
});
}
else{
viewer.innerHTML = "Binary file - no preview";
}
*/
if(mode === "dir"){
// DIRECTORY MODE
document.getElementById("viewer").style.display = "none";
document.getElementById("controls").style.display = "none";
document.getElementById("dirControls").style.display = "block";
document.getElementById("dirname").textContent = subdir || ".";
document.getElementById("renameDirInput").value = subdir || "";
}else{
// FILE MODE
document.getElementById("title").textContent = file || "";
document.getElementById("viewer").src =
`/api/file?mandant=${encodeURIComponent(mandant)}&subdir=${encodeURIComponent(subdir)}&file=${encodeURIComponent(file)}`;
document.getElementById("renameInput").value = file || "";
document.getElementById("renameInput").placeholder = file || "";
}
// ---------------- FILE ACTIONS ----------------
function download(){
window.location =
`/api/file?action=download&mandant=${encodeURIComponent(mandant)}&subdir=${encodeURIComponent(subdir)}&file=${encodeURIComponent(file)}`;
}
function del(){
if(!confirm("Delete?")) return;
fetch("/api/file",{
method:"POST",
headers:{"Content-Type":"application/json"},
body:JSON.stringify({
action:"delete",
mandant, subdir, file
})
}).then(()=>{
window.opener.reloadContextInstance();
window.close();
});
}
function renameFile(){
const newname = document.getElementById("renameInput").value;
if(!newname) return;
fetch("/api/file",{
method:"POST",
headers:{"Content-Type":"application/json"},
body:JSON.stringify({
action:"rename",
mandant, subdir, file, newname
})
}).then(()=>{
file = newname;
document.getElementById("title").textContent = file;
document.getElementById("renameInput").value = file;
document.getElementById("viewer").src =
`/api/file?mandant=${encodeURIComponent(mandant)}&subdir=${encodeURIComponent(subdir)}&file=${encodeURIComponent(file)}`;
window.opener.reloadContextInstance();
});
}
// ---------------- DIRECTORY ACTIONS ----------------
function renameDir(){
const newname = document.getElementById("renameDirInput").value;
if(!newname) return;
fetch("/api/dir",{
method:"POST",
headers:{"Content-Type":"application/json"},
body:JSON.stringify({
action:"rename",
mandant, subdir, newname
})
}).then(()=>{
window.opener.reloadContextInstance();
window.close();
});
}
function createSubdir(){
const newname = document.getElementById("newSubdirInput").value;
if(!newname) return;
fetch("/api/dir",{
method:"POST",
headers:{"Content-Type":"application/json"},
body:JSON.stringify({
action:"create",
mandant, subdir, newname
})
}).then(()=>{
window.opener.reloadContextInstance();
window.close();
});
}
function deleteDir(){
if(!confirm("Delete directory?")) return;
fetch("/api/dir",{
method:"POST",
headers:{"Content-Type":"application/json"},
body:JSON.stringify({
action:"delete",
mandant, subdir
})
}).then(()=>{
window.opener.reloadContextInstance();
window.close();
});
}
</script>
</body>
</html>