FILEUP



LOG | FILES | OVERVIEW


F diff --git a/css/style.css b/css/style.css --- a/css/style.css +++ b/css/style.css
border-color: #ddd;
}
+ .file > img {
+ flex: 1 0 0;
+ }
+
.file:hover > img {
- filter: brightness(150%);
+ filter: brightness(120%);
}
.path {
F diff --git a/loggedin.js b/loggedin.js --- a/loggedin.js +++ b/loggedin.js
the_file.onchange = on_file_added;
- var files = [];
const pwd = "/";
const pending_uploads = [];
+ class FileView {
+ constructor(filename, visuals, mimetype, is_directory) {
+ this.filename = filename;
+ this.visuals = visuals;
+ this.mimetype = mimetype;
+ this.is_directory = is_directory;
+ }
+ }
+
+ var files = [];
+
function on_file_added(_e) {
if (the_file.files.length >= 1) {
filename_input.value = the_file.files[0].name;
xhr.open('POST', '/php/readdir.php', true);
xhr.onload = function () {
for (const f of files)
- f[1].remove();
+ f.visuals.remove();
files = [];
var json = JSON.parse(this.responseText);
for (const f of json) {
- add_file_visuals(f.name, f.mimetype);
+ add_file_visuals(f.name, f.is_directory, f.mimetype);
}
};
xhr.send(data);
}
- function add_file_visuals(name, mimetype) {
+ function add_file_visuals(name, is_directory, mimetype) {
var fileDiv = document.createElement('div');
var img = document.createElement('img');
var filename = document.createElement('div');
- img.src="/mimeicons/application-pdf.png";
+ if (is_directory) {
+ img.src="/mimeicons/directory.png";
+ }
+ else {
+ img.src=`/mimeicons/${mimetype.replace("/", "-")}.png`;
+ }
+
fileDiv.classList.add('file');
filename.classList.add('filename');
filename.innerText = name;
current_directory.appendChild(fileDiv);
- files.push([name, fileDiv]);
-
- return fileDiv;
+ var file = new FileView(name, fileDiv, mimetype, is_directory);
+ files.push(file);
+ return file;
}
function begin_upload() {
F diff --git a/mimeicons/directory.png b/mimeicons/directory.png new file mode 100644
B Binary files /dev/null and b/mimeicons/directory.png differ
F diff --git a/mimeicons/text-plain.png b/mimeicons/text-plain.png new file mode 100644
B Binary files /dev/null and b/mimeicons/text-plain.png differ
F diff --git a/php/node.php b/php/node.php --- a/php/node.php +++ b/php/node.php
$this->node_id=$node_id;
}
}
- class Directory_Node extends Node
+
+ class Current_Directory extends Node
{
- public $node_list;
- /*the path in terms of the simulated filesystem*/
- function __construct(string $abstract_path)
+ /*an array of the dir_ids taken to reach here*/
+ public $path;
+
+ function __construct($user_id)
+ {
+ $this->dir_id=get_home_id($user_id);
+ $this->path=[$dir_id];
+ }
+ function change_directory($directory_id):bool
{
+ global $database;
+ if(!$database->is_directory($directory_id))
+ {
+ return false;
+ }
+
}
}