Commit 2c5ae521 authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

Merge branch 'emscripten' of git.purrdata.net:jwilkes/purr-data into emscripten

parents 5da851fd ed37e407
Pipeline #3679 canceled with stage
...@@ -68,6 +68,23 @@ ...@@ -68,6 +68,23 @@
color: #007BFF; color: #007BFF;
} }
#file-icons {
display: none;
}
#list-item:hover > div {
display: flex;
display: inline-block;
}
#list-item > li {
max-width: 150px;
}
#list-item:hover > li {
max-width: 75px;
}
#content { #content {
position: relative; position: relative;
} }
...@@ -335,3 +352,4 @@ li .hr{ ...@@ -335,3 +352,4 @@ li .hr{
cursor: pointer; cursor: pointer;
transition: transform 1s linear; transition: transform 1s linear;
} }
...@@ -2103,6 +2103,23 @@ function download_patch(file_name) { ...@@ -2103,6 +2103,23 @@ function download_patch(file_name) {
exports.download_patch = download_patch; exports.download_patch = download_patch;
function delete_file(file_name) {
FS.unlink(workspace+file_name, function(err) {
console.log(err);
});
update_file_ls();
}
function edit_file_name(file_name) {
var new_name = prompt("Enter new file name", file_name);
if (new_name != null) {
FS.rename(workspace+file_name, workspace+new_name, function(err) {
console.log(err);
});
update_file_ls();
}
}
function update_file_ls(){ function update_file_ls(){
var file_ls = window.document.getElementById("file_ls"); var file_ls = window.document.getElementById("file_ls");
file_ls.innerHTML = ""; file_ls.innerHTML = "";
...@@ -2111,18 +2128,33 @@ function update_file_ls(){ ...@@ -2111,18 +2128,33 @@ function update_file_ls(){
for (const file of FS.readdir(workspace)){ for (const file of FS.readdir(workspace)){
var mode = FS.stat(workspace+file).mode; var mode = FS.stat(workspace+file).mode;
if(FS.isFile(mode)){ if(FS.isFile(mode)){
var list_item = window.document.createElement("div");
var icons = window.document.createElement("div");
var li = window.document.createElement("li"); var li = window.document.createElement("li");
var a = window.document.createElement("a"); var a = window.document.createElement("a");
var edit_icon = window.document.createElement("i");
edit_icon.classList.add("fa", "fa-pencil", "text-primary", "edit");
var trash_icon = window.document.createElement("i");
trash_icon.classList.add("fa", "fa-trash", "text-primary", "delete");
icons.setAttribute("id", "file-icons");
list_item.classList.add("d-flex", "justify-content-between");
list_item.setAttribute("id", "list-item");
// Add name of file // Add name of file
a.append("./"+file); a.append(file);
// Add open button // Add open button
a.onclick = function(){open_patch(file)}; a.onclick = function(){open_patch(file)};
trash_icon.onclick = function(){delete_file(file)};
edit_icon.onclick = function(){edit_file_name(file)};
li.append(a); li.append(a);
li.classList.add("d-block"); li.classList.add("d-inline-block", "text-truncate");
li.classList.add("text-truncate");
li.style.maxWidth = "150px"; //append elements
file_ls.append(li); list_item.append(li);
icons.append(edit_icon);
icons.append(trash_icon);
list_item.append(icons);
file_ls.append(list_item);
files_added = files_added + 1; files_added = files_added + 1;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment