Skip to content
Snippets Groups Projects
Commit 41841a9e authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

fix drop and post

parent 0d3151cb
No related branches found
No related tags found
No related merge requests found
......@@ -85,3 +85,9 @@ declare %private function max-db:max-collections() as xs:string*{
return if($path='')then() else $path)
return $collections
};
declare function max-db:post-render($html as element(html)) as element(html){
<html><body>TESTTTTTTTTTTTTTTTTTT{
$html//*:body/*
}</body></html>
};
......@@ -40,18 +40,22 @@ async function dropHandler(ev) {
ev.preventDefault();
const droppedFiles = await DirectoryDropReader.getFilesFromDropEvent(ev)
const files = droppedFiles[0]
console.debug(droppedFiles)
const files = [...droppedFiles][0]
files.forEach((f)=> console.debug(f))
console.debug(files)
for(let i = 0; i < files.length; i++){
console.debug(files[i])
const f = files[i]
var data = new FormData()
data.append('file', f)
data.append('path', f.webkitRelativePath)
data.append('path', f.webkitRelativePath === '' ? f.name : f.webkitRelativePath )
await fetch('/bundles/max-db/post', {
method: 'POST',
body: data,
})
}
window.location.reload();
window.location.reload(true);
}
function dragOverHandler(ev) {
......@@ -69,18 +73,24 @@ class DirectoryDropReader {
}
static async getFilesFromDropEvent(e) {
let items = e.dataTransfer.items;
static async getFilesFromDropEvent(ev) {
let result = [];
for (let i = 0; i < items.length; i += 1) {
if (ev.dataTransfer.items) {
for (const item of ev.dataTransfer.items) {
let ddr = new DirectoryDropReader();
let entry = items[i].webkitGetAsEntry();
let entry = item.webkitGetAsEntry();
if (entry) {
let r = await ddr.traverse(items[i].webkitGetAsEntry());
let r = await ddr.traverse(item.webkitGetAsEntry());
result.push(ddr.getFiles());
}
}
} else {
for (const item of ev.dataTransfer.files) {
result.push(file);
};
}
return result;
return result
}
traverse(item) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment