First commit
This commit is contained in:
33
application/elements/fileChooser/fileChooser.file.icon.js
Normal file
33
application/elements/fileChooser/fileChooser.file.icon.js
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
import icon from "../icon.js";
|
||||
|
||||
export default class fileChooserFileIcon extends icon{
|
||||
|
||||
width = 50;
|
||||
|
||||
height = 50;
|
||||
|
||||
layers = 1;
|
||||
|
||||
backgroundSize = "contain!important"
|
||||
|
||||
create() {
|
||||
|
||||
console.log("icon type", this.parent.fileType);
|
||||
|
||||
|
||||
if( this.parent.fileType == "file" ) {
|
||||
|
||||
this.setImage( "assets/images/icons/file.png" );
|
||||
|
||||
}
|
||||
|
||||
if( this.parent.fileType == "directory" ) {
|
||||
|
||||
this.setImage( "assets/images/icons/folder.png" )
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
34
application/elements/fileChooser/fileChooser.file.js
Normal file
34
application/elements/fileChooser/fileChooser.file.js
Normal file
@@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
import icon from "./fileChooser.file.icon.js";
|
||||
|
||||
import label from "../label.js";
|
||||
|
||||
import checkbox from "/elements/checkbox.js";
|
||||
|
||||
export default class file{
|
||||
|
||||
margin = 10;
|
||||
|
||||
|
||||
filename;
|
||||
|
||||
path;
|
||||
|
||||
create() {
|
||||
|
||||
var filename = this.filename;
|
||||
|
||||
this.label.text = filename;
|
||||
|
||||
}
|
||||
|
||||
checkbox = new checkbox();
|
||||
|
||||
icon = new icon();
|
||||
|
||||
label = new label();
|
||||
|
||||
|
||||
|
||||
}
|
||||
76
application/elements/fileChooser/fileChooser.files.js
Normal file
76
application/elements/fileChooser/fileChooser.files.js
Normal file
@@ -0,0 +1,76 @@
|
||||
|
||||
#ifdef SERVER
|
||||
|
||||
import fs from "fs";
|
||||
|
||||
import path from "path";
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
import file from "./fileChooser.file.js";
|
||||
|
||||
export default class fileChooserFiles{
|
||||
|
||||
async open() {
|
||||
|
||||
var relativePath = "./";
|
||||
|
||||
var systemPath = await this.getSystemPath( relativePath )
|
||||
|
||||
var files = await this.getDirectory( systemPath );
|
||||
|
||||
}
|
||||
|
||||
node async getSystemPath( relativePath ) {
|
||||
|
||||
var absolutePath = path.resolve( relativePath );
|
||||
|
||||
console.log("getSystemPath", absolutePath);
|
||||
|
||||
return absolutePath;
|
||||
|
||||
}
|
||||
|
||||
node async getDirectory( absolutePath ) {
|
||||
|
||||
var files = fs.readdirSync( absolutePath );
|
||||
|
||||
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
|
||||
var filename = files[i];
|
||||
|
||||
var fileStat = fs.lstatSync( absolutePath + "/" + filename );
|
||||
|
||||
|
||||
var currentFile = new file();
|
||||
|
||||
|
||||
currentFile.filename = filename;
|
||||
|
||||
currentFile.path = absolutePath;
|
||||
|
||||
if( fileStat.isDirectory() ) {
|
||||
|
||||
currentFile.fileType = "directory";
|
||||
|
||||
} else {
|
||||
|
||||
currentFile.fileType = "file";
|
||||
|
||||
}
|
||||
|
||||
console.log("add file", currentFile);
|
||||
|
||||
this.add( currentFile );
|
||||
|
||||
}
|
||||
|
||||
console.log("readdirSync", files);
|
||||
|
||||
return files;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
51
application/elements/fileChooser/fileChooser.js
Normal file
51
application/elements/fileChooser/fileChooser.js
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
import files from "./fileChooser.files.js";
|
||||
|
||||
import selectButton from "./fileChooser.select.button.js";
|
||||
|
||||
export default class fileChooser{
|
||||
|
||||
//selector = "#application";
|
||||
|
||||
zIndex = 1000;
|
||||
|
||||
left = 0;
|
||||
|
||||
top = 0;
|
||||
|
||||
width = "100vw"
|
||||
|
||||
height = "100vh"
|
||||
|
||||
flexDirection = "column"
|
||||
|
||||
display = "none"
|
||||
|
||||
|
||||
|
||||
#ifdef LIGHT
|
||||
|
||||
background = "white"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
files = new files();
|
||||
|
||||
selectButton = new selectButton();
|
||||
|
||||
open() {
|
||||
|
||||
this.files.open();
|
||||
|
||||
}
|
||||
|
||||
async create() {
|
||||
|
||||
this.hide();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
import button from "/elements/button.js";
|
||||
|
||||
|
||||
export default class fileChooserSelectButton extends button {
|
||||
|
||||
layers = 2;
|
||||
|
||||
|
||||
click() {
|
||||
alert("asd")
|
||||
console.log("click", this);
|
||||
/*
|
||||
var files = this.parent.files.getChildren();
|
||||
//console.log(files);
|
||||
for (var i = 0; i < files.length; i++) {
|
||||
console.log(files[i].checkbox.value, files[i].path, files[i].filename);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user