Skip to content

Commit

Permalink
feat: dynamic loading #15
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomrebelo committed Jun 19, 2023
1 parent 9cde7b9 commit 74d0d14
Show file tree
Hide file tree
Showing 6 changed files with 370 additions and 6,456 deletions.
12 changes: 8 additions & 4 deletions src/public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,16 @@ window.onload = () => {
const form = document.getElementById('input-form');
const inputImages = document.getElementById('formControlImages');


form.addEventListener('submit', get);
inputImages.addEventListener('change', _uploadImages);

// ✅ DONE
for (let lang of availableLanguages) {
const option = document.createElement("option");
option.textContent = lang;
option.value = lang;
option.selected = (lang === 'en');
document.getElementById('formControlLang').appendChild(option);
}

// ❌
document.getElementById('lineDivisionCheck').addEventListener('change', (e) => {
if (e.target.checked) {
document.getElementById('textDelimiterField').classList.add('d-none');
Expand All @@ -54,8 +50,12 @@ window.onload = () => {
document.getElementById('imageAnchorField').classList.remove('d-none');
}
});

// ✅ DONE
}


// ✅
const get = async (e) => {
e.preventDefault();
let textArea = encodeURIComponent(document.getElementById('formControlTextarea').value);
Expand Down Expand Up @@ -97,6 +97,7 @@ const handleErr = (res = {success: false}) => {
document.getElementById('error-handle').classList.replace('d-none', 'd-block');
}

// ✅
const _uploadImages = async (e) => {
document.getElementById('imagePlacementField').classList.replace('d-none', 'd-block');
console.log(document.getElementById('imagePlacementField'));
Expand All @@ -113,6 +114,7 @@ const _uploadImages = async (e) => {
_displayImages(app.images.blobs);
}

// ✅
const _displayImages = (files) => {
const imgContainer = document.getElementById('input-images');
imgContainer.innerHTML = ``;
Expand All @@ -128,6 +130,7 @@ const _displayImages = (files) => {
imgContainer.classList.replace('d-none', 'd-block');
}

// ✅
const _readImages = async (files) => {
const res = [];
let err = [];
Expand Down Expand Up @@ -155,6 +158,7 @@ const _readImages = async (files) => {
return await Promise.all(res);
}

// ✅
const displayResults = (res) => {
if (!res.success) { return handleErr(res);}

Expand Down
Loading

0 comments on commit 74d0d14

Please sign in to comment.