Skip to content

Commit

Permalink
feat: minor fixes on interface #15
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiomrebelo committed Jun 19, 2023
1 parent 39c5deb commit 9cde7b9
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 27 deletions.
2 changes: 2 additions & 0 deletions src/public/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const app = {
window.onload = () => {
const form = document.getElementById('input-form');
const inputImages = document.getElementById('formControlImages');


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

Expand Down
60 changes: 55 additions & 5 deletions src/rollup-project/build/bundle.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6404,7 +6404,7 @@ const resultsContainer = () => {
const resultingSentences = paragraphContainer("","Sentences:", ["d-inline"], "temp-res-sentences");
mainSection.appendChild(resultingSentences);

const classificationResults = paragraphContainer("","Classification results::", ["d-inline"], "temp-res-classification");
const classificationResults = paragraphContainer("","Classification results:", ["d-inline"], "temp-res-classification");
mainSection.appendChild(classificationResults);

const lexiconResultsContainer = container("div", ["mt-4"]);
Expand All @@ -6429,7 +6429,11 @@ const resultsContainer = () => {
const inputForm = () => {
const containerOuter = container("aside", ["container-fluid"]);
const containerInner = container("div", ["row"]);
const mainSection = container("section", ["input-form-outer", "col-10","offset-1", "mt-5"]);
const section = container("section", ["input-form-outer", "col-10","offset-1", "mt-5"]);
const form = document.createElement("form");
form.id = "input-form";
form.classList.add("input-form-inner");
const mainSection = document.createElement("fieldset");

const inputTextAreaContainer = container("div", ["form-group", "row", "mb-2"]);
const inputTextArea = document.createElement("textarea");
Expand All @@ -6444,7 +6448,6 @@ const inputForm = () => {
inputTextAreaContainer.appendChild(inputTextArea);
mainSection.appendChild(inputTextAreaContainer);


const inputSelectContainer = container("div", ["form-group", "row", "mb-2"]);
const inputSelect = document.createElement("select");
inputSelect.id = `formControlLang`;
Expand All @@ -6461,7 +6464,6 @@ const inputForm = () => {

inputSelectContainer.appendChild(inputSelectLabel);
inputSelectContainer.appendChild(inputSelect);

mainSection.appendChild(inputSelectContainer);

mainSection.appendChild(divider());
Expand Down Expand Up @@ -6521,12 +6523,59 @@ const inputForm = () => {

mainSection.appendChild(submitContainer);

containerOuter.appendChild(mainSection);
form.appendChild(mainSection);
section.appendChild(form);

containerOuter.appendChild(section);
containerOuter.appendChild(containerInner);

containerOuter.addEventListener("submit", get);

return containerOuter;
};


const get = async (e) => {
e.preventDefault();
console.log(e, "inside");
/*let textArea = encodeURIComponent(document.getElementById('formControlTextarea').value);
const shouldDivide = document.getElementById('lineDivisionCheck').checked;
const lang = encodeURIComponent(document.getElementById('formControlLang').value);
app.images.randomPlacement = document.getElementById('imagePlacementCheck').checked;
let handler = `text`;
let delimiter;
if (!shouldDivide) {
delimiter = encodeURIComponent(document.getElementById('formControlTextDelimiter').value);
handler = `lines/${delimiter}`;
}
if (app.images.hasImages && !app.images.randomPlacement && !shouldDivide) {
let imageDelimiter = encodeURIComponent(document.getElementById('formControlImagePlaceholderDelimiter').value);
app.images.nAnchorPoints = [...textArea.matchAll(new RegExp(imageDelimiter,'g'))].length;
textArea = textArea.replaceAll(imageDelimiter, `${delimiter}${imageDelimiter}${delimiter}`);
if (app.images.nAnchorPoints !== app.images.amount) {
const relation = app.images.nAnchorPoints > app.images.amount ? 'higher' : 'smaller';
handleErr({ message: `the amount of image anchor points is ${relation} than the amount of upload images. (anchors:${app.images.nAnchorPoints} / images:${app.images.amount})`});
}
}
const url = `/${handler}/${lang}/${textArea}`;
fetch(url).then((response) => response.json()).then((result) => {
displayResults(result);
}).catch((error) => {
console.error('Error:', error);
handleErr({ message: `error on fetch. ${error}`});
});*/
};







const createLabel = (id, textContent, classes = []) => {
const label = document.createElement("label");
label.setAttribute("for", id);
Expand Down Expand Up @@ -6560,6 +6609,7 @@ class App {
init = () => {
const resultsScreen = resultsContainer();
const formInput = inputForm();

// screen.style(style);
document.body.appendChild(resultsScreen);
document.body.appendChild(formInput);
Expand Down
14 changes: 7 additions & 7 deletions src/rollup-project/build/bundle.css

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions src/rollup-project/build/bundle.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/rollup-project/build/bundle.min.js

Large diffs are not rendered by default.

61 changes: 54 additions & 7 deletions src/rollup-project/input.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


import {container, input, headline, paragraphContainer, button} from './components/textContainer.js'

const availableLanguages = [
Expand All @@ -25,7 +23,7 @@ export const resultsContainer = () => {
const resultingSentences = paragraphContainer("","Sentences:", ["d-inline"], "temp-res-sentences");
mainSection.appendChild(resultingSentences);

const classificationResults = paragraphContainer("","Classification results::", ["d-inline"], "temp-res-classification");
const classificationResults = paragraphContainer("","Classification results:", ["d-inline"], "temp-res-classification");
mainSection.appendChild(classificationResults);

const lexiconResultsContainer = container("div", ["mt-4"]);
Expand All @@ -50,7 +48,11 @@ export const resultsContainer = () => {
export const inputForm = () => {
const containerOuter = container("aside", ["container-fluid"]);
const containerInner = container("div", ["row"]);
const mainSection = container("section", ["input-form-outer", "col-10","offset-1", "mt-5"]);
const section = container("section", ["input-form-outer", "col-10","offset-1", "mt-5"]);
const form = document.createElement("form");
form.id = "input-form";
form.classList.add("input-form-inner");
const mainSection = document.createElement("fieldset");

const inputTextAreaContainer = container("div", ["form-group", "row", "mb-2"]);
const inputTextArea = document.createElement("textarea");
Expand All @@ -65,7 +67,6 @@ export const inputForm = () => {
inputTextAreaContainer.appendChild(inputTextArea);
mainSection.appendChild(inputTextAreaContainer);


const inputSelectContainer = container("div", ["form-group", "row", "mb-2"]);
const inputSelect = document.createElement("select");
inputSelect.id = `formControlLang`;
Expand All @@ -82,7 +83,6 @@ export const inputForm = () => {

inputSelectContainer.appendChild(inputSelectLabel);
inputSelectContainer.appendChild(inputSelect);

mainSection.appendChild(inputSelectContainer);

mainSection.appendChild(divider());
Expand Down Expand Up @@ -142,12 +142,59 @@ export const inputForm = () => {

mainSection.appendChild(submitContainer);

containerOuter.appendChild(mainSection);
form.appendChild(mainSection);
section.appendChild(form);

containerOuter.appendChild(section);
containerOuter.appendChild(containerInner);

containerOuter.addEventListener("submit", get);

return containerOuter;
}


const get = async (e) => {
e.preventDefault();
console.log(e, "inside");
/*let textArea = encodeURIComponent(document.getElementById('formControlTextarea').value);
const shouldDivide = document.getElementById('lineDivisionCheck').checked;
const lang = encodeURIComponent(document.getElementById('formControlLang').value);
app.images.randomPlacement = document.getElementById('imagePlacementCheck').checked;
let handler = `text`;
let delimiter;
if (!shouldDivide) {
delimiter = encodeURIComponent(document.getElementById('formControlTextDelimiter').value);
handler = `lines/${delimiter}`;
}
if (app.images.hasImages && !app.images.randomPlacement && !shouldDivide) {
let imageDelimiter = encodeURIComponent(document.getElementById('formControlImagePlaceholderDelimiter').value);
app.images.nAnchorPoints = [...textArea.matchAll(new RegExp(imageDelimiter,'g'))].length;
textArea = textArea.replaceAll(imageDelimiter, `${delimiter}${imageDelimiter}${delimiter}`);
if (app.images.nAnchorPoints !== app.images.amount) {
const relation = app.images.nAnchorPoints > app.images.amount ? 'higher' : 'smaller';
handleErr({ message: `the amount of image anchor points is ${relation} than the amount of upload images. (anchors:${app.images.nAnchorPoints} / images:${app.images.amount})`});
}
}
const url = `/${handler}/${lang}/${textArea}`;
fetch(url).then((response) => response.json()).then((result) => {
displayResults(result);
}).catch((error) => {
console.error('Error:', error);
handleErr({ message: `error on fetch. ${error}`});
});*/
}







export const createLabel = (id, textContent, classes = []) => {
const label = document.createElement("label");
label.setAttribute("for", id);
Expand Down
1 change: 1 addition & 0 deletions src/rollup-project/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class App {
init = () => {
const resultsScreen = resultsContainer();
const formInput = inputForm();

// screen.style(style);
document.body.appendChild(resultsScreen);
document.body.appendChild(formInput);
Expand Down

0 comments on commit 9cde7b9

Please sign in to comment.