FILEUP



LOG | FILES | OVERVIEW


F diff --git a/css/style.css b/css/style.css --- a/css/style.css +++ b/css/style.css
.filesystem > h2 button {
border: none;
- padding: 0.3rem 0.7rem;
+ padding: 0.3rem 1.1rem;
background: inherit;
border-radius: 0;
}
F diff --git a/loggedin.js b/loggedin.js --- a/loggedin.js +++ b/loggedin.js
const the_file = document.getElementById("the_file");
const filename_input = document.getElementById("filename");
const upload_btn = document.getElementById("upload_btn");
+ const the_path = document.getElementById("the_path");
const current_directory = document.getElementById("current_directory");
the_file.onchange = on_file_added;
-
- const pwd = "/";
-
+ var pwd = [];
const pending_uploads = [];
class FileView {
}).then((resp) => {
if (resp.status == 200) {
done_upload(fileview);
- }
- else {
+ } else {
alert("Upload failed");
}
}, () => {
var index = pending_uploads.indexOf(fileview);
if (index >= 0)
pending_uploads.splice(index, 1);
- load_dir(pwd);
+
+ load_dir();
}
- function load_dir(pwd) {
+ function load_dir() {
var data = new FormData();
- data.append('path', '/');
+
+ var path = "/";
+ for (const d of pwd)
+ path += d + "/";
+
+ while (the_path.children.length > 1)
+ the_path.removeChild(the_path.lastChild);
+
+ for (let i = 0; i < pwd.length; i++) {
+ var d = pwd[i];
+
+ var separator_div = document.createElement('div');
+ separator_div.classList.add('separator');
+ the_path.appendChild(separator_div);
+ separator_div.innerText = "»";
+
+ var entry = document.createElement('button');
+ entry.classList.add('pathentry');
+ entry.innerText = d;
+ the_path.appendChild(entry);
+
+ entry.onclick = () => {
+ pwd.length = i + 1;
+ load_dir();
+ }
+ }
+
+ data.append('path', path);
var xhr = new XMLHttpRequest();
xhr.open('POST', '/php/readdir.php', true);
if (is_directory) {
img.src="/mimeicons/directory.png";
+ fileDiv.onclick = () => {
+ pwd.push(name);
+ load_dir();
+ }
}
else {
img.src=`/mimeicons/${mimetype.replace("/", "-")}.png`;
the_file.click();
}
- load_dir("/");
+ load_dir();
F diff --git a/loggedin.php b/loggedin.php --- a/loggedin.php +++ b/loggedin.php
<h2 style="display: flex; gap: 0rem;">
<button id="upload_btn" onclick="begin_upload()">Upload</button>
<div class="separator"></div>
- <div class="path">
- <!-- <a class="pathentry" href="#"> <?php echo $_SESSION['username'] ?>'s files/</a><a class="pathentry" href="#">foo/</a><a class="pathentry" href="#">bar</a> -->
- <button class="pathentry">Haha's files</button>
- <div class="separator">»</div>
- <button class="pathentry">Haha's files</button>
+ <button id="upload_btn" onclick="begin_upload()">New Folder</button>
+ <div class="separator"></div>
+ <div class="path" id="the_path">
+ <!-- <a class="pathentry" href="#"> /</a><a class="pathentry" href="#">foo/</a><a class="pathentry" href="#">bar</a> -->
+ <button class="pathentry" onclick="pwd.length = 0; load_dir();"><?php echo $_SESSION['username'] ?>'s files</button>
</div>
</h2>