refactor: refs #6555 check if is Empty
gitea/worker-time-control/pipeline/pr-test This commit looks good
Details
gitea/worker-time-control/pipeline/pr-test This commit looks good
Details
This commit is contained in:
parent
496182fa54
commit
5e1a5f313a
|
@ -91,11 +91,11 @@ function printTimetable(timetable) {
|
||||||
const liTotals = createElement("li", {});
|
const liTotals = createElement("li", {});
|
||||||
timetable.forEach((row, index) => {
|
timetable.forEach((row, index) => {
|
||||||
for (let day = weekDays.length - 1; day >= 0; day--) {
|
for (let day = weekDays.length - 1; day >= 0; day--) {
|
||||||
const img = createElement("img", { attrs: { src: ifIsEmptyImage(row[`${day}daysAgoDirection`]) } });
|
const img = createElement("img", { attrs: { src: isEmpty(row[`${day}daysAgoDirection`], "image") } });
|
||||||
const p = createElement("p", { text: ifIsEmptyText(row[`${day}daysAgo`]) });
|
const p = createElement("p", { text: isEmpty(row[`${day}daysAgo`], "text") });
|
||||||
|
|
||||||
const innerDiv = createElement("div", { childs: [img, p] });
|
const innerDiv = createElement("div", { childs: [img, p] });
|
||||||
const outerDiv = createElement("div", { classes: ["time", ifIsEmpty(row[`${day}daysAgo`])], childs: [innerDiv] });
|
const outerDiv = createElement("div", { classes: ["time", isEmpty(row[`${day}daysAgo`])], childs: [innerDiv] });
|
||||||
liContent.append(outerDiv);
|
liContent.append(outerDiv);
|
||||||
|
|
||||||
if (index === 0) {
|
if (index === 0) {
|
||||||
|
@ -112,11 +112,12 @@ function printTimetable(timetable) {
|
||||||
timetableList.append(table);
|
timetableList.append(table);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ifIsEmpty = (value) => (value?.trim() ? "show" : "hide");
|
const isEmpty = (value, type) => {
|
||||||
|
const val = value?.toString()?.trim();
|
||||||
const ifIsEmptyImage = (value) => (value?.trim() ? `img/${value}.svg` : "img/in.svg");
|
if (!type) return val ? "show" : "hide";
|
||||||
|
if (type === "image") return val ? `img/${val}.svg` : "img/in.svg";
|
||||||
const ifIsEmptyText = (value) => (value?.toString()?.trim() ? value : "00:00");
|
if (type === "text") return val ? val : "00:00";
|
||||||
|
};
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
localStorage.removeItem("userData");
|
localStorage.removeItem("userData");
|
||||||
|
|
Loading…
Reference in New Issue