From 8cfef6fa93a9cf0b4092c55e8e7f47f0b5c2f439 Mon Sep 17 00:00:00 2001 From: fabioswartz Date: Tue, 3 Jan 2017 23:12:18 +0000 Subject: [PATCH] Move file dialog - Testing Former-commit-id: 64520a75c56bf86cc3db4abe7bcc3f612767ca7d --- _embed/public/js/listing.js | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/_embed/public/js/listing.js b/_embed/public/js/listing.js index 32e155fc..a5a3f8bb 100644 --- a/_embed/public/js/listing.js +++ b/_embed/public/js/listing.js @@ -317,7 +317,7 @@ listing.addDoubleTapEvent = function () { setTimeout(() => { touches.count = 0; - }, 500) + }, 300) return; } @@ -377,7 +377,7 @@ function loadNextFolder(event) { prompt = document.querySelector("form.prompt.active"); prompt.addEventListener("submit", moveSelected); - + console.log(event); request.open("GET", event.target.dataset.url); request.setRequestHeader("Accept", "application/json"); request.send(); @@ -388,11 +388,23 @@ function loadNextFolder(event) { prompt.querySelector("ul").innerHTML = ""; 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) { prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`; return; } + for(let f of JSON.parse(request.response)) { if(f.IsDir === true) { dirs++; @@ -457,6 +469,17 @@ function moveEvent(event) { prompt.querySelector("form").addEventListener("submit", moveSelected); 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)) { if(f.IsDir === true) { dirs++;