From 389e125cef7db247ce655393577dc2f74af681d6 Mon Sep 17 00:00:00 2001 From: Yisroel Baum Date: Fri, 24 Apr 2026 10:21:53 +0300 Subject: [PATCH] open modal on create plan click --- public/js/home.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/public/js/home.js b/public/js/home.js index 700bef8..198b122 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -1,5 +1,6 @@ document.addEventListener('DOMContentLoaded', () => { const textsList = document.getElementById('texts-list'); + const createPlanModal = document.getElementById('create-plan-modal'); async function loadTexts() { const response = await fetch('/api/texts'); @@ -13,5 +14,20 @@ document.addEventListener('DOMContentLoaded', () => { .join(''); } + function openCreatePlanModal(textId) { + createPlanModal.dataset.textId = textId; + createPlanModal.hidden = false; + } + + textsList.addEventListener('click', (clickEvent) => { + const createPlanButton = clickEvent.target.closest( + 'button.create-plan' + ); + if (createPlanButton === null) { + return; + } + openCreatePlanModal(createPlanButton.dataset.textId); + }); + loadTexts(); });