Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make drag & drop to work as input file in step 3 #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 34 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,37 @@
if (oFiles.length == 0) {
$(".btn_check_file").addClass('disabled');
} else {
const blobs = [];
for (let oFile of oFiles) {
blobs.push(oFile);
}
// Keep blobs in the input element
document.getElementById("uploadInput").blobs = blobs;
$(".btn_check_file").removeClass('disabled');
}
}

function onClickLetsCheckButton() {
let oFiles = document.getElementById("uploadInput").files;
if (oFiles.length === 0) return;
// Get the elements blobs
let filesBulbs = document.getElementById("uploadInput").blobs;
let dropZoneBulbs = document.getElementById("drop_zone").blobs;

// Case drag&drop are empty
if(!dropZoneBulbs){
dropZoneBulbs = [];
}

// Case files input are empty
if(!filesBulbs){
filesBulbs = [];
}

if (filesBulbs.length === 0 && dropZoneBulbs.length === 0) return;

// Empty the current selections
document.getElementById("uploadInput").blobs = [];
document.getElementById("drop_zone").blobs = [];
$(".btn_check_file").addClass('disabled');

// Prompt user this could take longer than they think.
M.toast({html: i18n("HTML_CHECKING"),
Expand All @@ -384,12 +408,7 @@

// Give the mobile phone UI a chance to show the checking message above.
setTimeout(function() {
const blobs = [];
for (let oFile of oFiles) {
blobs.push(oFile);
}

processBlobs(blobs);
processBlobs([...filesBulbs, ... dropZoneBulbs]);
}, 200);
}

Expand All @@ -406,7 +425,13 @@
}
}

processBlobs(blobs);
if (blobs.length == 0) {
$(".btn_check_file").addClass('disabled');
} else {
// Keep the selected blobs
document.getElementById("drop_zone").blobs = blobs;
$(".btn_check_file").removeClass('disabled');
}
}

function dragOverHandler(ev) {
Expand Down