let re = /(?:\.([^.]+))?$/;
const setFileIconType = (fileName) => {
let icoPath = "static/imgs/icons/bin.png";
let ftype = "file";
if (fileName.match(/\.(doc|docx|xls|xlsx|rtf)\b/) != null)
icoPath = "static/imgs/icons/doc.png";
if (fileName.match(/\.(7z|7zip|zip|tar.gz|tar.xz|gz|rar|jar)\b/) != null)
icoPath = "resources/images/icons/arc.png";
if (fileName.match(/\.(pdf)\b/) != null)
icoPath = "static/imgs/icons/pdf.png";
if (fileName.match(/\.(html)\b/) != null)
icoPath = "static/imgs/icons/html.png";
if (fileName.match(/\.(txt|conf)\b/) != null)
icoPath = "static/imgs/icons/text.png";
if (fileName.match(/\.(iso|img)\b/) != null)
icoPath = "static/imgs/icons/img.png";
if (fileName.match(/\.(sh|batch|exe)\b/) != null)
icoPath = "static/imgs/icons/scrip.png";
if (fileName.match(/\.(png|jpg|jpeg|gif|ico)\b/) != null)
ftype = "image";
if (fileName.match(/\.(avi|mkv|wmv|flv|f4v|mov|m4v|mpg|mpeg|mp4|webm|mp3|flac|ogg)\b/) != null)
ftype = "video";
if (fileName.match(/\.(dir)\b/) != null) {
icoPath = "static/imgs/icons/folder.png";
ftype = "dir"
}
return [icoPath, ftype]
}
class FilesList extends React.Component {
constructor(props) {
super(props);
this.openThis = this.openThis.bind(this);
this.openThisLocally = this.openThisLocally.bind(this);
}
openThis(e) {
e.preventDefault();
openFile(e);
}
openThisLocally(e) {
e.preventDefault();
openFileLocally(e);
}
render() {
let final = [];
let files = this.props.files[0];
for (let file of files) {
const name = file[0];
const hash = file[1];
const fsize = file[2];
let extension = re.exec( name.toLowerCase() )[1] ? name : "file.dir";
let data = setFileIconType(extension);
let icon = data[0];
let filetype = data[1];
let card_header = null;
let card_body = null;
if (filetype === "video") {
card_header = name;
card_body =