Skip to content

Commit c64f2bc

Browse files
committed
edit
1 parent 2ed9289 commit c64f2bc

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

html/error-template.html

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
.footer { color: #aaa; font-size: 14px; margin-top: 40px; }
1414
.report-btn { background: #ef4444; color: white; border: none; border-radius: 8px; padding: 10px 20px; font-size: 16px; cursor: pointer; margin-top: 20px; }
1515
.report-btn:hover { background: #dc2626; }
16-
.report-btn[data-enabled="false"] { display: none; } /* Hide button if reporting is disabled */
1716
</style>
1817
</head>
1918
<body>
@@ -23,7 +22,7 @@
2322
<div id="error-message" class="error-message">ERROR_MESSAGE</div>
2423
<img class="gif" src="ERROR_GIF" alt="Error illustration">
2524
<!-- 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>
2726
</div>
2827
<!-- Embedded front-end script for modal and reporting -->
2928
<script>
@@ -176,32 +175,18 @@
176175
}
177176
// ====== wire the button ======
178177
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)
205190
</script>
206191
</body>
207192
</html>

0 commit comments

Comments
 (0)