drakosfire
commited on
Commit
•
6dd139d
1
Parent(s):
63e9fef
Updated script.js with error logging for print.window null issue when deployed
Browse files- scripts.js +54 -48
scripts.js
CHANGED
@@ -92,56 +92,62 @@ document.addEventListener("DOMContentLoaded", function() {
|
|
92 |
});
|
93 |
});
|
94 |
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
</
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
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
|