FILEUP



LOG | FILES | OVERVIEW


F diff --git a/css/style.css b/css/style.css --- a/css/style.css +++ b/css/style.css
.file.dragged {
border: none;
+ pointer-events: none;
}
.file:hover:not(.dragged) {
F diff --git a/loggedin.js b/loggedin.js --- a/loggedin.js +++ b/loggedin.js
var context_menu = null;
var dragging = null;
+ var dragging_fileview;
var dragging_placeholder = null;
var dragging_offset_x = 0, dragging_offset_y = 0;
f.visuals.remove();
files = [];
- var json = JSON.parse(this.responseText);
+ var json = JSON.parse(xhr.responseText);
+ if (!json)
+ return;
+
for (const f of json) {
var view = new FileView(f.name, null, f.mimetype, f.is_directory && f.is_directory != "0");
files.push(view);
}
function delete_file(filename) {
- var file_full_path = get_path() + filename;
+ var file_full_path = get_path() + "/" + filename;
var data = new FormData();
data.append('path', file_full_path);
fileview.visuals.parentNode.insertBefore(dragging_placeholder, fileview.visuals);
dragging = fileview.visuals;
+ dragging_fileview = fileview;
dragging.classList.add("dragged");
var elemRect = dragging.getBoundingClientRect();
dragging = null;
}
+ function drop_handler(dst, src) {
+ alert(`Dropped ${dst.filename} on ${src.filename}`);
+ }
+
function add_file_visuals(fileview) {
var visuals = document.createElement('div');
fileview.visuals = visuals;
if (fileview.is_directory!=0) {
img.src="/mimeicons/directory.png";
visuals.onclick = () => {
- pwd.push(name);
+ pwd.push(fileview.filename);
load_dir();
}
} else {
context(e, [
['Open', () => {
if (is_directory) {
- pwd.push(name);
+ pwd.push(fileview.filename);
load_dir();
} else {
alert('not implemented');
e.preventDefault();
};
+ visuals.onmouseup = (e) => {
+ if (dragging) {
+ drop_handler(dragging_fileview, fileview);
+ end_drag();
+ }
+ e.preventDefault();
+ };
+
visuals.classList.add('file');
filename.classList.add('filename');
filename.innerText = fileview.filename;
var path = "/";
for (const d of pwd)
path += d + "/";
+ if (path.length > 1)
+ path = path.substring(0, path.length - 1);
return path;
}