Move file dialog - Testing

Former-commit-id: 64520a75c5
pull/726/head
fabioswartz 2017-01-03 23:12:18 +00:00
parent 0cb09738c9
commit 8cfef6fa93
1 changed files with 25 additions and 2 deletions

View File

@ -317,7 +317,7 @@ listing.addDoubleTapEvent = function () {
setTimeout(() => { setTimeout(() => {
touches.count = 0; touches.count = 0;
}, 500) }, 300)
return; return;
} }
@ -377,7 +377,7 @@ function loadNextFolder(event) {
prompt = document.querySelector("form.prompt.active"); prompt = document.querySelector("form.prompt.active");
prompt.addEventListener("submit", moveSelected); prompt.addEventListener("submit", moveSelected);
console.log(event);
request.open("GET", event.target.dataset.url); request.open("GET", event.target.dataset.url);
request.setRequestHeader("Accept", "application/json"); request.setRequestHeader("Accept", "application/json");
request.send(); request.send();
@ -388,11 +388,23 @@ function loadNextFolder(event) {
prompt.querySelector("ul").innerHTML = ""; prompt.querySelector("ul").innerHTML = "";
prompt.querySelector('code').innerHTML = event.target.dataset.url; prompt.querySelector('code').innerHTML = event.target.dataset.url;
if(prompt.querySelector('code').innerHTML != baseURL + "/") {
let newNode = document.createElement("li");
newNode.dataset.url = removeLastDirectoryPartOf(event.target.dataset.url) + "/";
newNode.innerHTML = "..";
newNode.setAttribute("aria-selected", false);
newNode.addEventListener("dblclick", loadNextFolder);
newNode.addEventListener("click", selectMoveFolder);
prompt.querySelector("div.file-list ul").appendChild(newNode);
}
if(JSON.parse(request.response) == null) { if(JSON.parse(request.response) == null) {
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`; prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
return; return;
} }
for(let f of JSON.parse(request.response)) { for(let f of JSON.parse(request.response)) {
if(f.IsDir === true) { if(f.IsDir === true) {
dirs++; dirs++;
@ -457,6 +469,17 @@ function moveEvent(event) {
prompt.querySelector("form").addEventListener("submit", moveSelected); prompt.querySelector("form").addEventListener("submit", moveSelected);
prompt.querySelector('code').innerHTML = window.location.pathname; prompt.querySelector('code').innerHTML = window.location.pathname;
if(window.location.pathname !== baseURL + "/") {
let newNode = document.createElement("li");
newNode.dataset.url = removeLastDirectoryPartOf(window.location.pathname) + "/";
newNode.innerHTML = "..";
newNode.setAttribute("aria-selected", false);
newNode.addEventListener("dblclick", loadNextFolder);
newNode.addEventListener("click", selectMoveFolder);
prompt.querySelector("div.file-list ul").appendChild(newNode);
}
for(let f of JSON.parse(request.response)) { for(let f of JSON.parse(request.response)) {
if(f.IsDir === true) { if(f.IsDir === true) {
dirs++; dirs++;