nreu
This commit is contained in:
139
recipes.html
139
recipes.html
@ -1,11 +1,57 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="de">
|
<html lang="de">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||||
<meta name="description" content="Tauche ein in die wunderbare Welt der Kulinarik und entdecke köstliche Rezepte.">
|
<title>Suche auf der Website</title>
|
||||||
<title>so.mach.ich.das | Recipes</title>
|
|
||||||
<style>
|
<style>
|
||||||
|
.search {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search__input {
|
||||||
|
font-family: inherit;
|
||||||
|
font-size: inherit;
|
||||||
|
background-color: #f4f2f2;
|
||||||
|
border: none;
|
||||||
|
color: #646464;
|
||||||
|
padding: 0.7rem 1rem;
|
||||||
|
border-radius: 30px;
|
||||||
|
width: 12em;
|
||||||
|
transition: all ease-in-out .5s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search__input:hover,
|
||||||
|
.search__input:focus {
|
||||||
|
box-shadow: 0 0 1em #00000013;
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search__button {
|
||||||
|
border: none;
|
||||||
|
background-color: #f4f2f2;
|
||||||
|
padding: 0.6rem;
|
||||||
|
border-radius: 50%;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search__icon {
|
||||||
|
height: 1.3em;
|
||||||
|
width: 1.3em;
|
||||||
|
fill: #b4b4b4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight {
|
||||||
|
background-color: yellow;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.highlight.active {
|
||||||
|
background-color: orange;
|
||||||
|
}
|
||||||
/* Grundlegendes Styling */
|
/* Grundlegendes Styling */
|
||||||
body {
|
body {
|
||||||
font-family: system-ui, sans-serif;
|
font-family: system-ui, sans-serif;
|
||||||
@ -207,19 +253,100 @@
|
|||||||
<br>
|
<br>
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
<div class="search">
|
||||||
|
<input type="text" id="searchInput" class="search__input" placeholder="Suchbegriff eingeben">
|
||||||
|
<button class="search__button" onclick="highlightSearch()">
|
||||||
|
<svg class="search__icon" viewBox="0 0 24 24">
|
||||||
|
<path d="M21.53 20.47l-3.66-3.66C19.195 15.24 20 13.214 20 11c0-4.97-4.03-9-9-9s-9 4.03-9 9 4.03 9 9 9c2.215 0 4.24-.804 5.808-2.13l3.66 3.66c.147.146.34.22.53.22s.385-.073.53-.22c.295-.293.295-.767.002-1.06zM3.5 11c0-4.135 3.365-7.5 7.5-7.5s7.5 3.365 7.5 7.5-3.365 7.5-7.5 7.5-7.5-3.365-7.5-7.5z"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button onclick="navigateMatches(-1)">⬆️</button>
|
||||||
|
<button onclick="navigateMatches(1)">⬇️</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
<br>
|
||||||
|
<div id="content">
|
||||||
<article class="card">
|
<article class="card">
|
||||||
<img src="johannesbeeressig.png" width="100%" alt="Johannesbeeressig">
|
<img src="johannesbeeressig.png" width="100%" alt="Johannesbeeressig">
|
||||||
<h3 class="title">Johannesbeeressig</h3>
|
<h3 class="title">Johannesbeeressig</h3>
|
||||||
<p class="description">Verleihe deinem Salat eine außergewöhnliche Note mit selbstgemachtem Johannisbeeressig.</p>
|
<p class="description">Verleihe deinem Salat eine außergewöhnliche Note mit selbstgemachtem Johannisbeeressig.</p>
|
||||||
<a href="/Johannesbeeressig/" class="link">See the recipe</a>
|
<a href="/Johannesbeeressig/" class="link">See the recipe</a>
|
||||||
</article>
|
</article>
|
||||||
</main>
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let currentMatch = -1;
|
||||||
|
let matches = [];
|
||||||
|
|
||||||
|
function clearHighlights() {
|
||||||
|
matches.forEach(span => {
|
||||||
|
const parent = span.parentNode;
|
||||||
|
parent.replaceChild(document.createTextNode(span.textContent), span);
|
||||||
|
parent.normalize();
|
||||||
|
});
|
||||||
|
matches = [];
|
||||||
|
currentMatch = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlightSearch() {
|
||||||
|
clearHighlights();
|
||||||
|
const searchInput = document.getElementById("searchInput");
|
||||||
|
const searchTerm = searchInput.value.trim().toLowerCase();
|
||||||
|
if (!searchTerm) return;
|
||||||
|
|
||||||
|
const content = document.getElementById("content");
|
||||||
|
const regex = new RegExp(searchTerm, "gi");
|
||||||
|
|
||||||
|
content.innerHTML = content.innerHTML.replace(/(<mark class="highlight.*?">|<\/mark>)/g, '');
|
||||||
|
|
||||||
|
const walker = document.createTreeWalker(content, NodeFilter.SHOW_TEXT);
|
||||||
|
const nodes = [];
|
||||||
|
|
||||||
|
while (walker.nextNode()) {
|
||||||
|
const node = walker.currentNode;
|
||||||
|
if (node.parentNode && node.nodeValue.toLowerCase().includes(searchTerm)) {
|
||||||
|
nodes.push(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nodes.forEach(node => {
|
||||||
|
const spanWrapper = document.createElement('span');
|
||||||
|
spanWrapper.innerHTML = node.nodeValue.replace(regex, match => `<mark class="highlight">${match}</mark>`);
|
||||||
|
node.parentNode.replaceChild(spanWrapper, node);
|
||||||
|
});
|
||||||
|
|
||||||
|
matches = Array.from(document.querySelectorAll(".highlight"));
|
||||||
|
|
||||||
|
if (matches.length > 0) {
|
||||||
|
currentMatch = 0;
|
||||||
|
scrollToCurrent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function scrollToCurrent() {
|
||||||
|
matches.forEach((el, i) => {
|
||||||
|
el.classList.toggle("active", i === currentMatch);
|
||||||
|
});
|
||||||
|
matches[currentMatch].scrollIntoView({ behavior: "smooth", block: "center" });
|
||||||
|
}
|
||||||
|
|
||||||
|
function navigateMatches(direction) {
|
||||||
|
if (matches.length === 0) return;
|
||||||
|
currentMatch = (currentMatch + direction + matches.length) % matches.length;
|
||||||
|
scrollToCurrent();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Optional: Suche mit Enter starten
|
||||||
|
document.getElementById("searchInput").addEventListener("keydown", e => {
|
||||||
|
if (e.key === "Enter") highlightSearch();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
<script>
|
<script>
|
||||||
// Funktion, die die Ladeanimation nach dem Laden der Seite ausblendet
|
// Funktion, die die Ladeanimation nach dem Laden der Seite ausblendet
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
document.querySelector('.loading-overlay').style.display = 'none';
|
document.querySelector('.loading-overlay').style.display = 'none';
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Reference in New Issue
Block a user