|
13 | 13 | .footer { color: #aaa; font-size: 14px; margin-top: 40px; } |
14 | 14 | .report-btn { background: #ef4444; color: white; border: none; border-radius: 8px; padding: 10px 20px; font-size: 16px; cursor: pointer; margin-top: 20px; } |
15 | 15 | .report-btn:hover { background: #dc2626; } |
16 | | - .report-btn[data-enabled="false"] { display: none; } /* Hide button if reporting is disabled */ |
17 | 16 | </style> |
18 | 17 | </head> |
19 | 18 | <body> |
|
23 | 22 | <div id="error-message" class="error-message">ERROR_MESSAGE</div> |
24 | 23 | <img class="gif" src="ERROR_GIF" alt="Error illustration"> |
25 | 24 | <!-- New report button --> |
26 | | - <button id="open-report-modal" class="report-btn" data-link="" data-site="" data-enabled="false">Signaler cette erreur</button> |
| 25 | + <button id="open-report-modal" class="report-btn" data-link="" data-site="">Signaler cette erreur</button> |
27 | 26 | </div> |
28 | 27 | <!-- Embedded front-end script for modal and reporting --> |
29 | 28 | <script> |
|
176 | 175 | } |
177 | 176 | // ====== wire the button ====== |
178 | 177 | const wireButton = () => { |
179 | | - ensureModal(); |
180 | | - const btn = document.getElementById('open-report-modal'); |
181 | | - if (!btn) return; |
182 | | - |
183 | | - // Dynamically set the button's visibility based on ENABLE_REPORTING_ERRORS |
184 | | - fetch('/worker/api/env') |
185 | | - .then(res => res.json()) |
186 | | - .then(env => { |
187 | | - const isEnabled = env.ENABLE_REPORTING_ERRORS === true || env.ENABLE_REPORTING_ERRORS === 'true'; |
188 | | - btn.setAttribute('data-enabled', isEnabled ? 'true' : 'false'); // Explicitly set "true" or "false" |
189 | | - if (isEnabled) { |
190 | | - btn.addEventListener('click', e => { |
191 | | - e.preventDefault(); |
192 | | - showModal(); |
193 | | - }); |
194 | | - // Set dynamic attributes |
195 | | - btn.setAttribute('data-link', location.href); |
196 | | - btn.setAttribute('data-site', location.hostname); |
197 | | - } |
198 | | - }) |
199 | | - .catch(() => { |
200 | | - btn.setAttribute('data-enabled', 'false'); // Fallback to "false" on error |
201 | | - }); |
202 | | - }; |
203 | | - |
204 | | - document.addEventListener('DOMContentLoaded', wireButton); |
| 178 | + ensureModal() |
| 179 | + const btn = document.getElementById('open-report-modal') |
| 180 | + if (!btn) return |
| 181 | + btn.addEventListener('click', e => { |
| 182 | + e.preventDefault() |
| 183 | + showModal() |
| 184 | + }) |
| 185 | + // Set dynamic attributes |
| 186 | + btn.setAttribute('data-link', location.href) |
| 187 | + btn.setAttribute('data-site', location.hostname) |
| 188 | + } |
| 189 | + document.addEventListener('DOMContentLoaded', wireButton) |
205 | 190 | </script> |
206 | 191 | </body> |
207 | 192 | </html> |
0 commit comments