drakosfire commited on
Commit
6dd139d
1 Parent(s): 63e9fef

Updated script.js with error logging for print.window null issue when deployed

Browse files
Files changed (1) hide show
  1. scripts.js +54 -48
scripts.js CHANGED
@@ -92,56 +92,62 @@ document.addEventListener("DOMContentLoaded", function() {
92
  });
93
  });
94
 
95
- window.printPageContainer = function() {
96
- var pageContainer = document.getElementById('brewRenderer');
97
- if (pageContainer) {
98
- var printWindow = window.open('', 'Print Preview', 'height=800,width=600');
99
-
100
- printWindow.document.write(`
101
- <!DOCTYPE html>
102
- <html lang="en">
103
- <head>
104
- <meta charset="UTF-8">
105
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
106
- <link href="./dependencies/all.css" rel="stylesheet">
107
- <link href="./dependencies/css.css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css">
108
- <link href="./dependencies/bundle.css" rel="stylesheet">
109
- <link href="./dependencies/style.css" rel="stylesheet">
110
- <link href="./dependencies/5ePHBstyle.css" rel="stylesheet">
111
- <link href="./storeUI.css" rel="stylesheet">
112
- <title>Print Preview - DnD Stat Block</title>
113
- <link rel="stylesheet" href="styles.css">
114
- <style>
115
- @media print {
 
 
 
 
 
 
 
 
 
 
 
116
 
117
- .page {
118
- page-break-before: auto;
119
- page-break-after: avoid;
120
- page-break-inside: avoid;
121
-
122
- }
123
- .columnWrapper {
124
- overflow: visible;
125
- }
126
-
127
  }
128
- </style>
129
- </head>
130
- <body>
131
- ${pageContainer.innerHTML}
132
- </body>
133
- </html>
134
- `);
135
-
136
- // Wait for the content to be fully loaded before printing
137
- printWindow.onload = function() {
138
- printWindow.print();
139
- printWindow.close(); // Close the print window after printing
140
- };
141
- } else {
142
- console.error('Element with ID "pages" not found.');
143
- }
144
- };
 
 
 
 
 
145
 
146
 
147
  // Store initial positions of the blocks
 
92
  });
93
  });
94
 
95
+ window.printPageContainer = function() {
96
+ var pageContainer = document.getElementById('brewRenderer');
97
+ if (pageContainer) {
98
+ var printWindow = window.open('', 'Print Preview', 'height=800,width=600');
99
+ if (!printWindow) {
100
+ console.error('Failed to open print window.');
101
+ return;
102
+ }
103
+
104
+ console.log('Page container content:', pageContainer.innerHTML); // Debugging line
105
+
106
+ printWindow.document.write(`
107
+ <!DOCTYPE html>
108
+ <html lang="en">
109
+ <head>
110
+ <meta charset="UTF-8">
111
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
112
+ <link href="./dependencies/all.css" rel="stylesheet">
113
+ <link href="./dependencies/css.css?family=Open+Sans:400,300,600,700" rel="stylesheet" type="text/css">
114
+ <link href="./dependencies/bundle.css" rel="stylesheet">
115
+ <link href="./dependencies/style.css" rel="stylesheet">
116
+ <link href="./dependencies/5ePHBstyle.css" rel="stylesheet">
117
+ <link href="./storeUI.css" rel="stylesheet">
118
+ <title>Print Preview - DnD Stat Block</title>
119
+ <link rel="stylesheet" href="styles.css">
120
+ <style>
121
+ @media print {
122
+
123
+ .page {
124
+ page-break-before: auto;
125
+ page-break-after: avoid;
126
+ page-break-inside: avoid;
127
 
 
 
 
 
 
 
 
 
 
 
128
  }
129
+ .columnWrapper {
130
+ overflow: visible;
131
+ }
132
+
133
+ }
134
+ </style>
135
+ </head>
136
+ <body>
137
+ ${pageContainer.innerHTML}
138
+ </body>
139
+ </html>
140
+ `);
141
+
142
+ // Wait for the content to be fully loaded before printing
143
+ printWindow.onload = function() {
144
+ printWindow.print();
145
+ printWindow.close(); // Close the print window after printing
146
+ };
147
+ } else {
148
+ console.error('Element with ID "pages" not found.');
149
+ }
150
+ };
151
 
152
 
153
  // Store initial positions of the blocks