An electron-based WIP aesthetic file explorer ^^
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
FileKade/scripts/fileview/hierarchy.js

32 lines
1.1 KiB

const path = require('path');
module.exports = () => {
const refresh = require('./refresh');
let tpath = window.kade.cpath;
let npath = tpath;
let hierarchy = [];
let fhierarchy = [];
while (true) {
hierarchy.push(path.basename(npath));
fhierarchy.push(npath);
npath = path.resolve(tpath, '..');
if (npath === tpath) {break;}
tpath = npath;
}
hierarchy.reverse().shift();
fhierarchy.reverse().shift();
for (let i = 0; i < hierarchy.length; i++) {
let dir = hierarchy[i];
let btn = document.createElement('p');
btn.onclick = () => {refresh(fhierarchy[i]);};
btn.innerHTML = dir;
document.getElementById('header-nav').appendChild(btn);
if ((i + 1) < hierarchy.length) {
let arrow = document.createElement('img');
arrow.src = './assets/icons/base/nav-arrow.svg';
arrow.className = 'header-nav-arrow';
document.getElementById('header-nav').appendChild(arrow);
}
}
};