#6555 refactor to js #28

Merged
jorgep merged 13 commits from 6555-refactorToJs into test 2024-10-10 13:51:47 +00:00
4 changed files with 19 additions and 21 deletions
Showing only changes of commit 5e413cc352 - Show all commits

View File

@ -35,12 +35,12 @@ and open the template in the editor.
</div> </div>
<div class="footer"> <footer>
<div class="in">Inicio jornada</div> <div class="in">Inicio jornada</div>
<div class="inMiddle">Inicio descanso</div> <div class="inMiddle">Inicio descanso</div>
<div class="outMiddle">Fin descanso</div> <div class="outMiddle">Fin descanso</div>
<div class="out">Fin jornada</div> <div class="out">Fin jornada</div>
</div> </footer>
<div class="confirm"> <div class="confirm">
<div class="contConfirm"> <div class="contConfirm">

View File

@ -193,17 +193,15 @@ h3 {
background-size: cover; background-size: cover;
background-repeat: no-repeat; background-repeat: no-repeat;
} }
.footer { footer {
display: none;
position: absolute; position: absolute;
bottom: 0; bottom: 0;
width: 100%; width: 100%;
height: 100px; height: 100px;
text-align: center; text-align: center;
}
.footer {
animation: fadeIn 0.2s ease-in-out; animation: fadeIn 0.2s ease-in-out;
} }
.in, .inMiddle { .in, .inMiddle {
display: inline; display: inline;
position: static; position: static;
@ -342,7 +340,7 @@ header {
opacity: 1; opacity: 1;
} }
.confirm { .confirm {
display: none; visibility: hidden;
position: fixed; position: fixed;
top: 0; top: 0;
left: 0; left: 0;
@ -373,11 +371,12 @@ header {
} }
.fade-in { .fade-in {
display: block; visibility: visible;
animation: fadeIn 0.2s ease-in-out forwards; animation: fadeIn 0.2s ease-in-out forwards;
} }
.fade-out { .fade-out {
visibility: hidden;
animation: fadeOut 0.2s ease-in-out forwards; animation: fadeOut 0.2s ease-in-out forwards;
} }
@ -407,7 +406,6 @@ header {
} }
100% { 100% {
opacity: 0; opacity: 0;
display: none;
} }
} }

View File

@ -1,5 +1,5 @@
let userData = ""; let userData = "";
const footer = document.querySelector(".footer"); const footer = document.querySelector("footer");
const txtName = document.querySelector("#txtNombre"); const txtName = document.querySelector("#txtNombre");
const inBtn = document.querySelector(".in"); const inBtn = document.querySelector(".in");
const inMiddleBtn = document.querySelector(".inMiddle"); const inMiddleBtn = document.querySelector(".inMiddle");
@ -22,7 +22,7 @@ function setEvents() {
outMiddleBtn.addEventListener("click", () => clockIn("middle")); outMiddleBtn.addEventListener("click", () => clockIn("middle"));
outBtn.addEventListener("click", () => clockIn("out")); outBtn.addEventListener("click", () => clockIn("out"));
// setTimeout(close, 5000); setTimeout(close, 5000);
} }
async function clockIn(direction) { async function clockIn(direction) {
@ -50,7 +50,7 @@ async function clockIn(direction) {
} }
function setView() { function setView() {
footer.style.display = "none"; footer.style.hidden = true;
inBtn.style.display = "none"; inBtn.style.display = "none";
inMiddleBtn.style.display = "none"; inMiddleBtn.style.display = "none";
outMiddleBtn.style.display = "none"; outMiddleBtn.style.display = "none";
@ -67,7 +67,7 @@ function setView() {
async function getInfo() { async function getInfo() {
const data = await call("WorkerTimeControls/getClockIn", { params: { workerFk: userData["userFk"] } }); const data = await call("WorkerTimeControls/getClockIn", { params: { workerFk: userData["userFk"] } });
footer.style.display = "block"; footer.style.hidden = false;
printTimetable(data); printTimetable(data);
} }
@ -75,17 +75,17 @@ function printTimetable(timetable) {
const dated = new Date(); const dated = new Date();
dated.setDate(dated.getDate() - 6); dated.setDate(dated.getDate() - 6);
const fragment = document.createDocumentFragment(); const table = document.createDocumentFragment();
const totalEl = document.querySelector(".total"); const totalEl = document.querySelector(".total");
let totalHr = 0; let totalHr = 0;
for (let day = 0; day < weekDays.length - 1; day++) { for (let day = 0; day < weekDays.length - 1; day++) {
const label = createElement("label", { text: weekDays[dated.getDay()] }); const label = createElement("label", { text: weekDays[dated.getDay()] });
fragment.append(label); table.append(label);
dated.setDate(dated.getDate() + 1); dated.setDate(dated.getDate() + 1);
} }
fragment.append(createElement("label", { text: "HOY", classes: ["hoy"] }), createElement("li", { classes: ["hrTop"] })); table.append(createElement("label", { text: "HOY", classes: ["hoy"] }), createElement("li", { classes: ["hrTop"] }));
const liContent = createElement("li", {}); const liContent = createElement("li", {});
const liTotals = createElement("li", {}); const liTotals = createElement("li", {});
@ -104,12 +104,12 @@ function printTimetable(timetable) {
totalHr += timetable[0][`${day}daysAgoTotal`] || 0; totalHr += timetable[0][`${day}daysAgoTotal`] || 0;
} }
} }
fragment.append(liContent); table.append(liContent);
if (index === timetable.length - 1) fragment.append(createElement("hr", {}), liTotals); if (index === timetable.length - 1) table.append(createElement("hr", {}), liTotals);
}); });
totalEl.innerText = `Total: ${totalHr ? secondsToHm(totalHr) : 0} h`; totalEl.innerText = `Total: ${totalHr ? secondsToHm(totalHr) : 0} h`;
timetableList.append(fragment); timetableList.append(table);
} }
const ifIsEmpty = (value) => (value?.trim() ? "show" : "hide"); const ifIsEmpty = (value) => (value?.trim() ? "show" : "hide");

View File

@ -5,7 +5,7 @@ const confirmBtn = document.querySelector(".confirm");
function confirmReset() { function confirmReset() {
confirmBtn.classList.remove("confirmKO", "fade-in", "fade-out"); confirmBtn.classList.remove("confirmKO", "fade-in", "fade-out");
confirmBtn.style.display = "none"; confirmBtn.style.hidden = true;
txtConfirm.textContent = ""; txtConfirm.textContent = "";
} }
@ -14,7 +14,7 @@ function printError(msg) {
const txtConfirm = document.querySelector(".txtConfirm"); const txtConfirm = document.querySelector(".txtConfirm");
txtConfirm.textContent = msg; txtConfirm.textContent = msg;
confirmBtn.classList.add("confirmKO"); confirmBtn.classList.add("confirmKO");
confirmBtn.style.display = "block"; confirmBtn.style.hidden = false;
confirmBtn.classList.add("fade-in"); confirmBtn.classList.add("fade-in");
setTimeout(() => (confirmBtn.classList.add("fade-out"), confirmReset()), 2300); setTimeout(() => (confirmBtn.classList.add("fade-out"), confirmReset()), 2300);