diff --git a/assets/css/style.css b/assets/css/style.css index 6e04428..642ae17 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -4,7 +4,7 @@ display: none; } .varient { - width: 30px; + width: 50px; margin: 5px; } @@ -78,11 +78,19 @@ table { border-collapse: collapse; border: 1px solid black; } + +td input { + display: block; + width: 90px; +} + th, td { text-align: left; border: 1px solid white; padding: 8px; + color: white; + background-color: black; } #SevereThinness, diff --git a/assets/js/ExScript.js b/assets/js/ExScript.js index f8aa0f9..47388e9 100644 --- a/assets/js/ExScript.js +++ b/assets/js/ExScript.js @@ -47,6 +47,80 @@ const showSuggestionsEx = (i) => { } }; +const addInput = (e) => { + + for(const Selecteday of Exdays) { + if (ExDb[Selecteday][`${e.target.id.substring(0, e.target.id.length - 3)}`].length > + Number( + e.target.value + ) +) { + toastBody.textContent = "The existing number of exercises is greater than the variance set, Please delete some exercises"; + toastBootstrap.show(); + return; +} + document.querySelector( + `#${Selecteday}Tbl #${e.target.id.substring(0, e.target.id.length - 3)}Tr` + ).innerHTML = ""; + + }; + + Exdays.forEach((Selecteday) => { + + const newTd = document.createElement("td"); + const newTdTime = document.createElement("td"); + newTdTime.innerHTML = `${e.target.id.substring(0, e.target.id.length - 3)}` + let htm = ""; + htm = ``; + console.log(`id="${e.target.id.substring(0, e.target.id.length - 3)}TblR"`); + /* + for(let g = 0; ;g++) { + + htm += "" + + }*/ + + htm += "
Cell
"; + newTd.innerHTML = htm; + document + .querySelector( + `#${Selecteday}Tbl #${e.target.id.substring(0, e.target.id.length - 3)}Tr` + ) + .appendChild(newTdTime); + document + .querySelector( + `#${Selecteday}Tbl #${e.target.id.substring(0, e.target.id.length - 3)}Tr` + ) + .appendChild(newTd); + ExDb[Selecteday][`${e.target.id.substring(0, e.target.id.length - 3)}`].forEach((fo) => { + const newTr = document.createElement("tr"); + newTr.innerHTML = `${fo}`; + + document + .querySelector( + `#${Selecteday}Tbl #${e.target.id.substring(0, e.target.id.length - 3)}TblR` + ).appendChild(newTr); + }); + for (let lea = 0; lea < 3; lea++) { + let htm1 = ""; + htm1 = ``; + for (let j = 0; j < e.target.value; j++) { + htm1 += ``; + } + + htm1 += "
"; + const newTd1 = document.createElement("td"); + newTd1.innerHTML = htm1; + document + .querySelector( + `#${Selecteday}Tbl #${e.target.id.substring(0, e.target.id.length - 3)}Tr` + ) + .appendChild(newTd1); + } + + }); +}; + const addSelectedEx = (e) => { e.preventDefault(); if (`${e.target.id.substring(0, e.target.id.length - 3)}` === "HIIT") { @@ -59,9 +133,6 @@ const addSelectedEx = (e) => { `${e.target.id.substring(0, e.target.id.length - 3)}` ).value = ""; for (const da of setDays) { - console.log( - ExDb[da][`${e.target.id.substring(0, e.target.id.length - 3)}`].length - ); if ( document.getElementById( `${e.target.id.substring(0, e.target.id.length - 3)}Var` diff --git a/assets/js/domGet.js b/assets/js/domGet.js index 3d8a792..7a22100 100644 --- a/assets/js/domGet.js +++ b/assets/js/domGet.js @@ -41,7 +41,7 @@ const calorieRow = document.querySelectorAll("#calorieRow td"); const days = document.querySelectorAll("input[name='day']"); const userInput = document.querySelectorAll("[list='itemList']"); const userInputEx = document.querySelectorAll("[list='itemListEx']"); - +let order = document.getElementsByClassName("selected"); const detailedInfo = document.querySelectorAll("input[name='detailedInfo']"); const detailedForm = document.getElementById("detailedForm"); let dataList = document.getElementById("itemList"); diff --git a/assets/js/eventListeners.js b/assets/js/eventListeners.js index 8108014..66029ae 100644 --- a/assets/js/eventListeners.js +++ b/assets/js/eventListeners.js @@ -38,7 +38,7 @@ orderLi.forEach((i) => { orderLi.forEach((j) => { j.classList.remove("selected"); }); - e.target.classList.push("selected"); + e.target.classList.add("selected"); WorkOfTheDay = []; WorkOfTheDay.push(e.target.textContent); } @@ -211,13 +211,14 @@ setOrderBtn.addEventListener("click", (e) => { const newDiv = document.createElement("div"); newDiv.innerHTML = `
+ .join("")}" onchange='addInput(e)'>${order[i].textContent}

{ .addEventListener("click", addSelectedEx); const userInputEx = document.querySelectorAll("[list='itemListEx']"); console.log(userInputEx); + document.getElementById(`${order[i].textContent.split(" ").join("")}Var`).addEventListener("change", addInput); userInputEx.forEach((j) => { j.addEventListener("keyup", (k) => { showSuggestionsEx(k.target); @@ -256,13 +258,6 @@ setOrderBtn.addEventListener("click", (e) => { .split(" ") .join("")}TblR" width='100%'>`; console.log(`id="${order[i].textContent.split(" ").join("")}TblR"`); - /* - for(let g = 0; ;g++) { - - htm += "Cell" - - }*/ - htm += ""; newTd.innerHTML = htm; document @@ -270,19 +265,7 @@ setOrderBtn.addEventListener("click", (e) => { `#${Selecteday}Tbl #${order[i].textContent.split(" ").join("")}Tr` ) .appendChild(newTd); - for (let lea = 0; lea < 3; lea++) { - const newTd1 = document.createElement("td"); - let htm1 = ""; - htm1 = ``; - htm1 += "
"; - newTd1.innerHTML = htm1; - document - .querySelector( - `#${Selecteday}Tbl #${order[i].textContent.split(" ").join("")}Tr` - ) - .appendChild(newTd1); - newTd1.setAttribute("contenteditable", "true"); - } + }); Exdays.forEach((da) => { diff --git a/assets/js/printPdf.js b/assets/js/printPdf.js index 469b4c4..c7f7407 100644 --- a/assets/js/printPdf.js +++ b/assets/js/printPdf.js @@ -223,206 +223,232 @@ getPDFBtn.addEventListener("click", (e) => { */ let foodTable = [ - { - margin: [20, 20, 0, 0], - text: "Based on your Response, we have designed your recommended food chart for you...", - }, - { - margin: [0, 20, 0, 0], - text: "", - }, - { - margin: 0, - table: { - headerRows: 1, - widths: [55, 55, 55, 55, 55, 55, 55, 55], + { + margin: [20, 20, 0, 0], + text: "Based on your Response, we have designed your recommended food chart for you...", + }, + { + margin: [0, 20, 0, 0], + text: "", + }, + { + margin: 0, + table: { + headerRows: 1, + widths: [55, 55, 55, 55, 55, 55, 55, 55], - body: [ - [ - "", - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - ], - [ - { - text: `${trTh[8].textContent}`, - bold: true, - }, - `${tdtrObj[trItems[1].id][0].textContent}`, - `${tdtrObj[trItems[1].id][1].textContent}`, - `${tdtrObj[trItems[1].id][2].textContent}`, - `${tdtrObj[trItems[1].id][3].textContent}`, - `${tdtrObj[trItems[1].id][4].textContent}`, - `${tdtrObj[trItems[1].id][5].textContent}`, - `${tdtrObj[trItems[1].id][6].textContent}`, - ], - [ - { - text: `${trTh[9].textContent}`, - bold: true, - }, - `${tdtrObj[trItems[2].id][0].textContent}`, - `${tdtrObj[trItems[2].id][1].textContent}`, - `${tdtrObj[trItems[2].id][2].textContent}`, - `${tdtrObj[trItems[2].id][3].textContent}`, - `${tdtrObj[trItems[2].id][4].textContent}`, - `${tdtrObj[trItems[2].id][5].textContent}`, - `${tdtrObj[trItems[2].id][6].textContent}`, - ], - [ - { - text: `${trTh[10].textContent}`, - bold: true, - }, - `${tdtrObj[trItems[3].id][0].textContent}`, - `${tdtrObj[trItems[3].id][1].textContent}`, - `${tdtrObj[trItems[3].id][2].textContent}`, - `${tdtrObj[trItems[3].id][3].textContent}`, - `${tdtrObj[trItems[3].id][4].textContent}`, - `${tdtrObj[trItems[3].id][5].textContent}`, - `${tdtrObj[trItems[3].id][6].textContent}`, - ], - [ - { - text: `${trTh[11].textContent}`, - bold: true, - }, - `${tdtrObj[trItems[4].id][0].textContent}`, - `${tdtrObj[trItems[4].id][1].textContent}`, - `${tdtrObj[trItems[4].id][2].textContent}`, - `${tdtrObj[trItems[4].id][3].textContent}`, - `${tdtrObj[trItems[4].id][4].textContent}`, - `${tdtrObj[trItems[4].id][5].textContent}`, - `${tdtrObj[trItems[4].id][6].textContent}`, - ], - [ - { - text: `${trTh[12].textContent}`, - bold: true, - }, - `${tdtrObj[trItems[5].id][0].textContent}`, - `${tdtrObj[trItems[5].id][1].textContent}`, - `${tdtrObj[trItems[5].id][2].textContent}`, - `${tdtrObj[trItems[5].id][3].textContent}`, - `${tdtrObj[trItems[5].id][4].textContent}`, - `${tdtrObj[trItems[5].id][5].textContent}`, - `${tdtrObj[trItems[5].id][6].textContent}`, - ], - [ - { - text: `${trTh[13].textContent}`, - bold: true, - }, - `${tdtrObj[trItems[6].id][0].textContent}`, - `${tdtrObj[trItems[6].id][1].textContent}`, - `${tdtrObj[trItems[6].id][2].textContent}`, - `${tdtrObj[trItems[6].id][3].textContent}`, - `${tdtrObj[trItems[6].id][4].textContent}`, - `${tdtrObj[trItems[6].id][5].textContent}`, - `${tdtrObj[trItems[6].id][6].textContent}`, - ], - [ - { - text: `${trTh[14].textContent}`, - bold: true, - }, - `${tdtrObj[trItems[7].id][0].textContent}`, - `${tdtrObj[trItems[7].id][1].textContent}`, - `${tdtrObj[trItems[7].id][2].textContent}`, - `${tdtrObj[trItems[7].id][3].textContent}`, - `${tdtrObj[trItems[7].id][4].textContent}`, - `${tdtrObj[trItems[7].id][5].textContent}`, - `${tdtrObj[trItems[7].id][6].textContent}`, - ], - [ - { - text: `Total Calorie`, - bold: true, - }, - `${calorieCount[0]}g`, - `${calorieCount[1]}g`, - `${calorieCount[2]}g`, - `${calorieCount[3]}g`, `${calorieCount[4]}g`, `${calorieCount[5]}g`, `${calorieCount[6]}g`, - ], - [ - { - text: `Total Protein`, - bold: true, - }, - `${proteinCount[0]}g`, - `${proteinCount[1]}g`, - `${proteinCount[2]}g`, - `${proteinCount[3]}g`, - `${proteinCount[4]}g`, - `${proteinCount[5]}g`, - `${proteinCount[6]}g`, - ], - [ - { - text: `Total fat`, - bold: true, - }, - `${fatCount[0]}g`, - `${fatCount[1]}g`, - `${fatCount[2]}g`, - `${fatCount[3]}g`, - `${fatCount[4]}g`, - `${fatCount[5]}g`, - `${fatCount[6]}g`, - ], - [ - { - text: `Total Carbohydrates`, - bold: true, - }, - `${carbsCount[0]}g`, - `${carbsCount[1]}g`, - `${carbsCount[2]}g`, - `${carbsCount[3]}g`, - `${carbsCount[4]}g`, - `${carbsCount[5]}g`, - `${carbsCount[6]}g`, - ], + body: [ + [ + "", + "Sunday", + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + ], + [ + { + text: `${trTh[8].textContent}`, + bold: true, + }, + `${tdtrObj[trItems[1].id][0].textContent}`, + `${tdtrObj[trItems[1].id][1].textContent}`, + `${tdtrObj[trItems[1].id][2].textContent}`, + `${tdtrObj[trItems[1].id][3].textContent}`, + `${tdtrObj[trItems[1].id][4].textContent}`, + `${tdtrObj[trItems[1].id][5].textContent}`, + `${tdtrObj[trItems[1].id][6].textContent}`, + ], + [ + { + text: `${trTh[9].textContent}`, + bold: true, + }, + `${tdtrObj[trItems[2].id][0].textContent}`, + `${tdtrObj[trItems[2].id][1].textContent}`, + `${tdtrObj[trItems[2].id][2].textContent}`, + `${tdtrObj[trItems[2].id][3].textContent}`, + `${tdtrObj[trItems[2].id][4].textContent}`, + `${tdtrObj[trItems[2].id][5].textContent}`, + `${tdtrObj[trItems[2].id][6].textContent}`, + ], + [ + { + text: `${trTh[10].textContent}`, + bold: true, + }, + `${tdtrObj[trItems[3].id][0].textContent}`, + `${tdtrObj[trItems[3].id][1].textContent}`, + `${tdtrObj[trItems[3].id][2].textContent}`, + `${tdtrObj[trItems[3].id][3].textContent}`, + `${tdtrObj[trItems[3].id][4].textContent}`, + `${tdtrObj[trItems[3].id][5].textContent}`, + `${tdtrObj[trItems[3].id][6].textContent}`, + ], + [ + { + text: `${trTh[11].textContent}`, + bold: true, + }, + `${tdtrObj[trItems[4].id][0].textContent}`, + `${tdtrObj[trItems[4].id][1].textContent}`, + `${tdtrObj[trItems[4].id][2].textContent}`, + `${tdtrObj[trItems[4].id][3].textContent}`, + `${tdtrObj[trItems[4].id][4].textContent}`, + `${tdtrObj[trItems[4].id][5].textContent}`, + `${tdtrObj[trItems[4].id][6].textContent}`, + ], + [ + { + text: `${trTh[12].textContent}`, + bold: true, + }, + `${tdtrObj[trItems[5].id][0].textContent}`, + `${tdtrObj[trItems[5].id][1].textContent}`, + `${tdtrObj[trItems[5].id][2].textContent}`, + `${tdtrObj[trItems[5].id][3].textContent}`, + `${tdtrObj[trItems[5].id][4].textContent}`, + `${tdtrObj[trItems[5].id][5].textContent}`, + `${tdtrObj[trItems[5].id][6].textContent}`, + ], + [ + { + text: `${trTh[13].textContent}`, + bold: true, + }, + `${tdtrObj[trItems[6].id][0].textContent}`, + `${tdtrObj[trItems[6].id][1].textContent}`, + `${tdtrObj[trItems[6].id][2].textContent}`, + `${tdtrObj[trItems[6].id][3].textContent}`, + `${tdtrObj[trItems[6].id][4].textContent}`, + `${tdtrObj[trItems[6].id][5].textContent}`, + `${tdtrObj[trItems[6].id][6].textContent}`, + ], + [ + { + text: `${trTh[14].textContent}`, + bold: true, + }, + `${tdtrObj[trItems[7].id][0].textContent}`, + `${tdtrObj[trItems[7].id][1].textContent}`, + `${tdtrObj[trItems[7].id][2].textContent}`, + `${tdtrObj[trItems[7].id][3].textContent}`, + `${tdtrObj[trItems[7].id][4].textContent}`, + `${tdtrObj[trItems[7].id][5].textContent}`, + `${tdtrObj[trItems[7].id][6].textContent}`, + ], + [ + { + text: `Total Calorie`, + bold: true, + }, + `${calorieCount[0]}g`, + `${calorieCount[1]}g`, + `${calorieCount[2]}g`, + `${calorieCount[3]}g`, `${calorieCount[4]}g`, `${calorieCount[5]}g`, `${calorieCount[6]}g`, ], - - } + [ + { + text: `Total Protein`, + bold: true, + }, + `${proteinCount[0]}g`, + `${proteinCount[1]}g`, + `${proteinCount[2]}g`, + `${proteinCount[3]}g`, + `${proteinCount[4]}g`, + `${proteinCount[5]}g`, + `${proteinCount[6]}g`, + ], + [ + { + text: `Total fat`, + bold: true, + }, + `${fatCount[0]}g`, + `${fatCount[1]}g`, + `${fatCount[2]}g`, + `${fatCount[3]}g`, + `${fatCount[4]}g`, + `${fatCount[5]}g`, + `${fatCount[6]}g`, + ], + [ + { + text: `Total Carbohydrates`, + bold: true, + }, + `${carbsCount[0]}g`, + `${carbsCount[1]}g`, + `${carbsCount[2]}g`, + `${carbsCount[3]}g`, + `${carbsCount[4]}g`, + `${carbsCount[5]}g`, + `${carbsCount[6]}g`, + ], + ], + } - ]; + } + ]; -let remarks = [ - { - margin: [0, 20, 0, 0], - text: "Remarks:", + let exerciseTable = [ + { + margin: [0, 20, 0, 0], + text: "Exercise Plan", + style: 'header', + }, + { + margin: [0, 10, 0, 0], + table: { + headerRows: 1, + widths: [55, 55, 55, 55, 55], + body: [ + [ + { text: "Day", bold: true }, + { text: "Exercise", bold: true }, + { text: "Rep", bold: true }, + { text: "Sets", bold: true }, + { text: "Rest", bold: true }, + ], + ], + }, + }, + ]; + + + let remarks = [ + { + margin: [0, 20, 0, 0], + text: "Remarks:", - style: 'header', - }, + style: 'header', + }, { - margin: [0, 10, 0, 0], - text: `${remarksTextArea.value}`, - }, - , -]; + margin: [0, 10, 0, 0], + text: `${remarksTextArea.value}`, + }, + , + ]; -let style = { + let style = { defaultStyle: { fontSize: 8, bold: true, }, header: { - fontSize: 18, - bold: true, - }, + fontSize: 18, + bold: true, + }, }; DataDef.content.push(foodTable); + DataDef.content.push(exerciseTable); DataDef.content.push(remarks); DataDef.styles = style;