Skip to content

Commit 19d0d51

Browse files
committed
Add newsletter preview
1 parent d3dbc4a commit 19d0d51

File tree

1 file changed

+31
-19
lines changed

1 file changed

+31
-19
lines changed

frontend/index.html

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,21 +147,6 @@
147147
max-height: 400px;
148148
overflow: auto;
149149
}
150-
151-
#preview-container {
152-
background-color: #fff;
153-
border-radius: 5px;
154-
padding: 20px;
155-
margin-bottom: 20px;
156-
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
157-
display: none;
158-
}
159-
160-
.iframe-container {
161-
position: relative;
162-
overflow: hidden;
163-
padding-top: 5px;
164-
}
165150
</style>
166151
</head>
167152
<body>
@@ -195,7 +180,20 @@ <h2>Opportunities</h2>
195180

196181
<button id="generate-btn">Generate Newsletter</button>
197182
<div id="download-link"></div>
198-
<pre id="html-preview"></pre>
183+
<div id="preview-container" style="display: none">
184+
<h2 style="margin-top: 20px; text-align: center">
185+
Newsletter Preview
186+
</h2>
187+
<div
188+
id="newsletter-preview"
189+
style="
190+
border: 1px solid #ddd;
191+
border-radius: 5px;
192+
margin-top: 15px;
193+
overflow: auto;
194+
"
195+
></div>
196+
</div>
199197
</div>
200198
</div>
201199

@@ -208,7 +206,6 @@ <h2>Opportunities</h2>
208206
"opportunities-container"
209207
);
210208
const downloadLink = document.getElementById("download-link");
211-
const htmlPreview = document.getElementById("html-preview");
212209

213210
// Add button event listeners
214211
document
@@ -753,6 +750,19 @@ <h3 style="color: #1051ea; font-weight: bold; font-size: 18px; font-family: Helv
753750
};
754751
});
755752

753+
// Generate preview with local data
754+
const previewContainer =
755+
document.getElementById("preview-container");
756+
const previewElement =
757+
document.getElementById("newsletter-preview");
758+
const localHtml = generateNewsletterHTML(
759+
events,
760+
articles,
761+
opportunities
762+
);
763+
previewElement.innerHTML = localHtml;
764+
previewContainer.style.display = "block";
765+
756766
// Send the data to backend
757767
fetch("http://localhost:5000/generate", {
758768
method: "POST",
@@ -774,10 +784,12 @@ <h3 style="color: #1051ea; font-weight: bold; font-size: 18px; font-family: Helv
774784
const url = URL.createObjectURL(blob);
775785

776786
downloadLink.innerHTML = `
777-
<a href="${url}" download="newsletter.html">Download Newsletter HTML</a>
778-
<p>Right-click and select "Save as" to download the newsletter</p>
787+
<a href="${url}" download="newsletter.html">Click Here to Download Newsletter HTML</a>
779788
`;
780789
downloadLink.style.display = "block";
790+
791+
// Update preview with server-generated HTML if it differs
792+
previewElement.innerHTML = htmlContent;
781793
} else {
782794
alert("Error: " + data.error);
783795
}

0 commit comments

Comments
 (0)