diff options
author | adam <adam@> | 2021-02-12 14:22:24 +0200 |
---|---|---|
committer | adam <adam@> | 2021-02-12 14:22:24 +0200 |
commit | 75640897d7ae44f10b9dde091d4b8dcba8e23776 (patch) | |
tree | a12ddea0e17f80ec9a1e4b12128cef0e0a12e257 /loggedin.js | |
parent | bbd462f80f0b491caf15f0cc7fd8c7ed88e33ba6 (diff) | |
parent | 1de4d8dea14a9641206cd91613388ee5f228bae5 (diff) | |
download | fileup-75640897d7ae44f10b9dde091d4b8dcba8e23776.tar.gz |
Merge branch 'master' of https://github.com/alexvitkov/india
Diffstat (limited to 'loggedin.js')
-rw-r--r-- | loggedin.js | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/loggedin.js b/loggedin.js index 436719f..d774e16 100644 --- a/loggedin.js +++ b/loggedin.js @@ -8,7 +8,9 @@ const current_directory = document.getElementById("current_directory"); the_file.onchange = on_file_added; -const files = []; +var files = []; + +const pwd = "/"; const pending_uploads = []; @@ -44,7 +46,26 @@ function on_file_added(_e) { } -function add_file_visuals(name, pending) { +function load_dir(pwd) { + var data = new FormData(); + data.append('path', '/'); + + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/php/readdir.php', true); + xhr.onload = function () { + for (const f of files) + f[1].remove(); + files = []; + + var json = JSON.parse(this.responseText); + for (const f of json) { + add_file_visuals(f.name, f.mimetype); + } + }; + xhr.send(data); +} + +function add_file_visuals(name, mimetype) { var fileDiv = document.createElement('div'); var img = document.createElement('img'); @@ -68,3 +89,5 @@ function add_file_visuals(name, pending) { function begin_upload() { the_file.click(); } + +load_dir("/"); |