From 8e5729caa5e17aeff5428b4a8028ff0cdc1251e9 Mon Sep 17 00:00:00 2001 From: ache Date: Mon, 18 Feb 2019 02:42:14 +0100 Subject: Delete UX --- dir.html | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/dir.html b/dir.html index da8ab1c..a0767ec 100644 --- a/dir.html +++ b/dir.html @@ -73,9 +73,46 @@ const onSelectFile = () => { for( ; i < input.files.length ; i++) { upload(input.files[i]); } +}; + +const deleteMethode = url => { + fetch( url , { + method: 'DELETE', + }).then( + response => { + console.log(response); + } + ).then( + success => { + console.log(success); + } + ).catch( + error => { + console.log(error); + } + ); +}; + +const onPageLoad = () => { + console.log("🦊"); + const as = Array.from(document.getElementsByTagName('a')); + + as.forEach( e => { + const a = document.createElement('a'); + a.appendChild(document.createTextNode('X')); + a.classList.add('delete'); + a.href = "#"; + a.onclick = () => false; + a.addEventListener('click', () => { + deleteMethode('/' + e.href.split('/').slice(3).join('/')) + return false; + }, false); + e.parentNode.insertBefore(a, e.nextSibling); + }); } input.addEventListener('change', onSelectFile, false); +window.addEventListener('load', onPageLoad, false); -- cgit v1.2.3