Spaces:
Sleeping
Sleeping
Commit
·
a702223
1
Parent(s):
dbc3a91
moving window.open to earlier in printPDF() to try to associate with user click
Browse files- requirements.txt +0 -1
- scripts.js +16 -4
- static/closed-mimic-trashcan.png +3 -0
- static/mimic_trashcan.png +3 -0
requirements.txt
CHANGED
@@ -2,4 +2,3 @@ flask
|
|
2 |
flask-cors
|
3 |
fal_client
|
4 |
openai
|
5 |
-
pdfkit
|
|
|
2 |
flask-cors
|
3 |
fal_client
|
4 |
openai
|
|
scripts.js
CHANGED
@@ -244,13 +244,25 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
244 |
// );
|
245 |
|
246 |
function printPDF() {
|
|
|
247 |
var brewRendererContent = document.getElementById('brewRenderer').innerHTML;
|
248 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
249 |
var form = document.createElement("form");
|
250 |
form.setAttribute("method", "post");
|
251 |
-
form.setAttribute("action", "/proxy.html");
|
252 |
form.setAttribute("target", "pdf-preview");
|
253 |
|
|
|
254 |
var hiddenField = document.createElement("input");
|
255 |
hiddenField.setAttribute("type", "hidden");
|
256 |
hiddenField.setAttribute("name", "htmlContent");
|
@@ -259,11 +271,10 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
259 |
form.appendChild(hiddenField);
|
260 |
document.body.appendChild(form);
|
261 |
|
262 |
-
//
|
263 |
-
var previewWindow = window.open('', 'pdf-preview', 'width=800,height=600');
|
264 |
form.submit();
|
265 |
|
266 |
-
//
|
267 |
setTimeout(function() {
|
268 |
form.remove();
|
269 |
}, 1000);
|
@@ -271,6 +282,7 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
271 |
|
272 |
document.getElementById('printButton').addEventListener('click', printPDF);
|
273 |
|
|
|
274 |
|
275 |
|
276 |
// Store initial positions of the blocks
|
|
|
244 |
// );
|
245 |
|
246 |
function printPDF() {
|
247 |
+
// Capture the innerHTML of brewRenderer
|
248 |
var brewRendererContent = document.getElementById('brewRenderer').innerHTML;
|
249 |
|
250 |
+
// Open a new window immediately on user interaction
|
251 |
+
var previewWindow = window.open('', 'pdf-preview', 'width=800,height=600');
|
252 |
+
|
253 |
+
// Check if the window was blocked
|
254 |
+
if (!previewWindow) {
|
255 |
+
alert("Popup blocked! Please allow popups for this website to preview the PDF.");
|
256 |
+
return;
|
257 |
+
}
|
258 |
+
|
259 |
+
// Create a form to send the content to the proxy
|
260 |
var form = document.createElement("form");
|
261 |
form.setAttribute("method", "post");
|
262 |
+
form.setAttribute("action", "/proxy.html");
|
263 |
form.setAttribute("target", "pdf-preview");
|
264 |
|
265 |
+
// Create a hidden input to store the HTML content
|
266 |
var hiddenField = document.createElement("input");
|
267 |
hiddenField.setAttribute("type", "hidden");
|
268 |
hiddenField.setAttribute("name", "htmlContent");
|
|
|
271 |
form.appendChild(hiddenField);
|
272 |
document.body.appendChild(form);
|
273 |
|
274 |
+
// Submit the form, which will load the proxy.html in the new window
|
|
|
275 |
form.submit();
|
276 |
|
277 |
+
// Clean up the form after a short delay
|
278 |
setTimeout(function() {
|
279 |
form.remove();
|
280 |
}, 1000);
|
|
|
282 |
|
283 |
document.getElementById('printButton').addEventListener('click', printPDF);
|
284 |
|
285 |
+
|
286 |
|
287 |
|
288 |
// Store initial positions of the blocks
|
static/closed-mimic-trashcan.png
ADDED
![]() |
Git LFS Details
|
static/mimic_trashcan.png
ADDED
![]() |
Git LFS Details
|