drakosfire commited on
Commit
3a05b59
1 Parent(s): 67ba65c

created event listener for button that connects button to call to open window, might work? Works locally.

Browse files
Files changed (2) hide show
  1. scripts.js +12 -4
  2. storeUI.html +1 -1
scripts.js CHANGED
@@ -91,8 +91,17 @@ document.addEventListener("DOMContentLoaded", function() {
91
  console.error('Error:', error);
92
  });
93
  });
94
-
95
- window.printPageContainer = function() {
 
 
 
 
 
 
 
 
 
96
  var pageContainer = document.getElementById('brewRenderer');
97
 
98
  htmlContent = `
@@ -131,8 +140,7 @@ document.addEventListener("DOMContentLoaded", function() {
131
  </html>
132
  `;
133
  // Open a new tab
134
- const newTab = window.open('', '_blank');
135
-
136
  // Check if the new tab was blocked
137
  if (newTab) {
138
  // Write the HTML content to the new tab
 
91
  console.error('Error:', error);
92
  });
93
  });
94
+ document.getElementById('printButton').addEventListener('click', function() {
95
+ const newTab = window.open('', '_blank');
96
+
97
+ if (newTab) {
98
+ // Call the function to write content
99
+ window.printPageContainer(newTab);
100
+ } else {
101
+ console.error('Failed to open a new tab. It may have been blocked by the browser.');
102
+ }
103
+ });
104
+ window.printPageContainer = function(newTab) {
105
  var pageContainer = document.getElementById('brewRenderer');
106
 
107
  htmlContent = `
 
140
  </html>
141
  `;
142
  // Open a new tab
143
+
 
144
  // Check if the new tab was blocked
145
  if (newTab) {
146
  // Write the HTML content to the new tab
storeUI.html CHANGED
@@ -31,7 +31,7 @@
31
  <button id="submitDescription">Submit</button>
32
  <button id="parseHTML">Parse HTML</button>
33
  <button id="resetButton">Reset</button>
34
- <button onclick="printPageContainer()">Open Tab to print</button>
35
  <div class="brewRenderer" id="brewRenderer">
36
 
37
  <div class="pages" id="pages">
 
31
  <button id="submitDescription">Submit</button>
32
  <button id="parseHTML">Parse HTML</button>
33
  <button id="resetButton">Reset</button>
34
+ <button id="printButton">Open Tab to print</button>
35
  <div class="brewRenderer" id="brewRenderer">
36
 
37
  <div class="pages" id="pages">