drakosfire commited on
Commit
a702223
1 Parent(s): dbc3a91

moving window.open to earlier in printPDF() to try to associate with user click

Browse files
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"); // Flask route
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
- // Open the form submission in a new window
263
- var previewWindow = window.open('', 'pdf-preview', 'width=800,height=600');
264
  form.submit();
265
 
266
- // Optionally clean up the form after submission
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

  • SHA256: 024c948ed4d4d3ed43af666149e8d1bfe9623dbb9a7950202b21d2e89006d051
  • Pointer size: 131 Bytes
  • Size of remote file: 481 kB
static/mimic_trashcan.png ADDED

Git LFS Details

  • SHA256: f7335ca7729250517199f465ea29ae6f9c12b460eec5a6fb9595a7c6578242da
  • Pointer size: 131 Bytes
  • Size of remote file: 558 kB