Function bodies 62 total
renderDetail function · javascript · L43-L97 (55 LOC)src/frontend/js/ui.js
function renderDetail() {
const recipe = getSelectedRecipe();
editRecipeButtonEl.disabled = !recipe;
deleteRecipeToolbarButtonEl.disabled = !recipe;
printRecipeButtonEl.disabled = !recipe;
if (!recipe) {
detailContentEl.innerHTML = `
<div class="empty-state">
Vyber recept zo zoznamu alebo pridaj novy.<br />
Nova verzia uz uklada data do databazy a podporuje obrazky.
</div>
`;
return;
}
const ingredients = textToList(recipe.ingredients);
const instructions = textToList(recipe.instructions);
const ingredientCount = countLines(recipe.ingredients);
const prepTime = formatPrepTime(recipe.prep_time_minutes);
detailContentEl.innerHTML = `
<article class="detail-hero">
<div class="cover-card">
<img src="${escapeHtml(getRecipeImage(recipe))}" alt="${escapeHtml(recipe.title)}" onerror="this.onerror=null;this.src='${FALLBACK_IMAGE}'" />
<div class="cover-chip">Upraveny ${escapeHtml(formatDate(recipe.updatedescapeHtml function · javascript · L3-L10 (8 LOC)src/frontend/js/utils.js
function escapeHtml(value) {
return String(value || "")
.replace(/&/g, "&")
.replace(/</g, "<")
.replace(/>/g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
}textToList function · javascript · L12-L17 (6 LOC)src/frontend/js/utils.js
function textToList(value) {
return String(value || "")
.split(/\n+/)
.map((line) => line.trim())
.filter(Boolean);
}countLines function · javascript · L19-L21 (3 LOC)src/frontend/js/utils.js
function countLines(value) {
return Math.max(textToList(value).length, 0);
}firstNonEmptyLine function · javascript · L23-L25 (3 LOC)src/frontend/js/utils.js
function firstNonEmptyLine(value) {
return textToList(value)[0] || "";
}formatDate function · javascript · L27-L36 (10 LOC)src/frontend/js/utils.js
function formatDate(value) {
if (!value) return "nedavno";
const date = new Date(value);
if (Number.isNaN(date.getTime())) return "nedavno";
return new Intl.DateTimeFormat("sk-SK", {
day: "2-digit",
month: "2-digit",
year: "numeric"
}).format(date);
}formatPrepTime function · javascript · L38-L43 (6 LOC)src/frontend/js/utils.js
function formatPrepTime(value) {
if (value === null || value === undefined || value === "") return "- min";
const minutes = Number(value);
if (!Number.isFinite(minutes) || minutes < 0) return "- min";
return `${Math.round(minutes)} min`;
}About: code-quality intelligence by Repobility · https://repobility.com
normalizePrepTimeInput function · javascript · L45-L51 (7 LOC)src/frontend/js/utils.js
function normalizePrepTimeInput(value) {
const trimmed = String(value || "").trim();
if (!trimmed) return null;
const parsed = Number.parseInt(trimmed, 10);
if (!Number.isFinite(parsed) || parsed < 0) return null;
return parsed;
}fileToDataUrl function · javascript · L53-L60 (8 LOC)src/frontend/js/utils.js
function fileToDataUrl(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => resolve(String(reader.result || ""));
reader.onerror = () => reject(new Error("Subor sa nepodarilo nacitat."));
reader.readAsDataURL(file);
});
}getRecipeImage function · javascript · L62-L65 (4 LOC)src/frontend/js/utils.js
function getRecipeImage(recipe) {
if (!recipe) return FALLBACK_IMAGE;
return recipe.image_data || recipe.image_url || FALLBACK_IMAGE;
}parseIngredientGroups function · javascript · L67-L83 (17 LOC)src/frontend/js/utils.js
function parseIngredientGroups(value) {
const lines = textToList(value);
const groups = [];
let current = { title: "", items: [] };
for (const line of lines) {
if (line.endsWith(":")) {
if (current.title || current.items.length) groups.push(current);
current = { title: line, items: [] };
continue;
}
current.items.push(line);
}
if (current.title || current.items.length) groups.push(current);
return groups;
}renderIngredientContent function · javascript · L85-L100 (16 LOC)src/frontend/js/utils.js
function renderIngredientContent(value) {
const groups = parseIngredientGroups(value);
if (!groups.length) return '<p class="section-intro">Suroviny este nie su doplnene.</p>';
const hasSections = groups.some((group) => group.title);
if (!hasSections) {
return `<ul class="ingredient-list">${groups[0].items.map((line) => `<li>${escapeHtml(line)}</li>`).join("")}</ul>`;
}
return `<div class="ingredient-groups">${groups.map((group) => `
<section>
${group.title ? `<p class="ingredient-group-title">${escapeHtml(group.title)}</p>` : ""}
${group.items.length ? `<ul class="ingredient-list">${group.items.map((line) => `<li>${escapeHtml(line)}</li>`).join("")}</ul>` : ""}
</section>
`).join("")}</div>`;
}‹ prevpage 2 / 2