1 Star 0 Fork 0

yelanting/lorikeet-electron

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
userInterface.js 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
sunliuping 提交于 2018-11-18 16:14 . [commit person]sunliuping
"use strict";
const fileSystem = require("./fileSystem.js")
let document;
function displayFolderPath(folderPath){
document.getElementById("current-folder").innerText=folderPath;
}
function clearView(){
const mainArea = document.getElementById("main-area");
let firstChild = mainArea.firstChild;
while(firstChild){
mainArea.removeChild(firstChild);
firstChild = mainArea.firstChild;
}
}
function loadDirectory(folderPath){
return function(window){
if(!document){
document = window.document;
}
displayFolderPath(folderPath);
fileSystem.getFilesInFolder(folderPath,(err,files)=>{
clearView();
if(err){
return alret("Sorry,you could not load your folder!!!");
}
fileSystem.inspectAndDescribeFiles(folderPath,files,displayFiles);
});
};
}
function displayFile(file){
const mainArea = document.getElementById("main-area");
const template = document.querySelector("#item-template");
let clone = document.importNode(template.content, true);
clone.querySelector("img").src = `images/${file.type}.svg`;
if(file.type ==="directory"){
clone.querySelector('img').addEventListener('dblclick',()=>{
loadDirectory(file.path)();
},false);
}
clone.querySelector(".filename").innerText = file.file;
mainArea.appendChild(clone);
}
function displayFiles(err,files){
if(err){
return alert("Sorry ,we could not display your files!!!");
}
files.forEach(displayFile);
}
function bindDocument(window){
if(!document){
document = window.document;
}
}
module.exports={
bindDocument,
displayFiles,
loadDirectory,
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/sam_yelanting/lorikeet-electron.git
git@gitee.com:sam_yelanting/lorikeet-electron.git
sam_yelanting
lorikeet-electron
lorikeet-electron
master

搜索帮助