오늘의 잔디

searchInput & searchResults UI 추가 (HTML)<!-- ✅ 🔍 일정 검색창 -->
<div id="search-container" style="margin: 40px 0 0 60px; text-align: left;">
<input
type="text"
id="searchInput"
placeholder="🔍 일정 검색 (예: 운동, 회의)"
style="padding: 10px; width: 250px; border-radius: 8px; border: 1px solid #ccc;"
/>
</div>
<!-- ✅ 🔍 검색 결과 표시 영역 -->
<div id="searchResults" style="margin: 10px 0 0 60px; text-align: left; color: white;"></div>
let allEvents = []; // 서버에서 받아온 전체 일정을 저장
fetch 이후 위치에서 아래처럼 저장:
.then(eventList => {
...
allEvents = eventList; // ✅ 검색을 위한 원본 데이터 저장
});
index.js)document.getElementById("searchInput").addEventListener("input", function () {
const keyword = this.value.trim().toLowerCase();
const resultBox = document.getElementById("searchResults");
resultBox.innerHTML = "";
if (keyword === "") return;
const matched = allEvents.filter(ev =>
ev.title.toLowerCase().includes(keyword)
);
if (matched.length === 0) {
resultBox.innerHTML = "<p>🔍 검색 결과가 없습니다.</p>";
return;
}
matched.forEach(ev => {
const div = document.createElement("div");
div.classList.add("search-result-item");
div.textContent = `📌 ${ev.title} - ${ev.date}`;
div.style.marginBottom = "6px";
div.style.cursor = "pointer";
// ✅ 검색 결과 클릭 시 해당 날짜로 이동 + 강조 효과
div.addEventListener("click", () => {
currentMonth = moment(ev.date);
renderCalendar();
setTimeout(() => {
const target = document.querySelector(`.day[data-date="${ev.date}"]`);
if (target) {
target.classList.add("highlight");
setTimeout(() => target.classList.remove("highlight"), 2000);
}
}, 100);
});
resultBox.appendChild(div);
});
});
style.css).highlight {
outline: 3px solid yellow;
border-radius: 8px;
}

