aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 09:22:23 +0200
committerAlex Vitkov <alexvitkov98@gmail.com>2021-02-13 09:22:23 +0200
commit2229da3596c9f6e25b1d30a30df35bf21b2bc219 (patch)
treea80f4a20377d61d251df0e3e4287d6e04a8f3420
parentb17c9ee6046735433e4ba037c9b60c5f592bd15e (diff)
downloadfileup-2229da3596c9f6e25b1d30a30df35bf21b2bc219.tar.gz
Move file to parent directories by dragging onto the path entries
-rw-r--r--loggedin.js40
-rw-r--r--loggedin.php2
-rw-r--r--php/move.php2
3 files changed, 33 insertions, 11 deletions
diff --git a/loggedin.js b/loggedin.js
index 0f48746..324a18a 100644
--- a/loggedin.js
+++ b/loggedin.js
@@ -81,10 +81,7 @@ function load_dir() {
entry.innerText = d;
the_path.appendChild(entry);
- entry.onclick = () => {
- pwd.length = i + 1;
- load_dir();
- }
+ add_link_functionality(entry, i + 1);
}
var data = new FormData();
@@ -231,6 +228,26 @@ function drop_handler(dst, src) {
}
}
+function add_link_functionality(link, length) {
+ link.onclick = () => {
+ pwd.length = length,
+ load_dir();
+ }
+
+ link.onmouseup = (e) => {
+ if (dragging) {
+ var new_folder = get_path(length);
+ move_file(new_folder, dragging_fileview.filename);
+ end_drag();
+
+ e.preventDefault();
+ e.stopPropagation();
+ }
+ }
+}
+
+add_link_functionality(document.getElementById("home_path_entry"), 0);
+
function add_file_visuals(fileview) {
var visuals = document.createElement('div');
fileview.visuals = visuals;
@@ -317,12 +334,17 @@ function context(e, entries) {
document.body.appendChild(context_menu);
}
-function get_path() {
+function get_path(max_length) {
+ if (max_length == undefined) {
+ max_length = pwd.length;
+ }
+
var path = "/";
- for (const d of pwd)
- path += d + "/";
- if (path.length > 1)
- path = path.substring(0, path.length - 1);
+ for (let i = 0; i < max_length; i++) {
+ path += pwd[i];
+ if (i != max_length - 1)
+ path + "/";
+ }
return path;
}
diff --git a/loggedin.php b/loggedin.php
index 8d54d65..b655819 100644
--- a/loggedin.php
+++ b/loggedin.php
@@ -6,7 +6,7 @@
<button id="upload_btn" onclick="new_folder()">New Folder</button>
<div class="separator"></div>
<div class="path" id="the_path">
- <button class="pathentry" onclick="pwd.length = 0; load_dir();"><?php echo $_SESSION['username'] ?>'s files</button>
+ <button class="pathentry" id="home_path_entry"><?php echo $_SESSION['username'] ?>'s files</button>
</div>
</h2>
diff --git a/php/move.php b/php/move.php
index a79ce83..3b1bf05 100644
--- a/php/move.php
+++ b/php/move.php
@@ -8,7 +8,7 @@ require_once "misc.php";
session_start();
if (!isset($_POST['old_folder']) || !isset($_POST['new_folder']) || !isset($_POST['filename'])) {
- error_log("bad /php/move.php call $_POST of:$_POST[old_folder] nf:$_POST[new_folder] fn:$_POST[filename]");
+ error_log("bad /php/move.php call");
http_response_code(400);
exit(1);
}