Commit a81d45ae authored by Your Name's avatar Your Name

Fix null addEventListener error on login page

Check if modal elements exist before adding event listeners to prevent
Uncaught TypeError: Cannot read properties of null (reading 'addEventListener')
parent 7b3166c3
...@@ -878,23 +878,32 @@ along with this program. If not, see <https://www.gnu.org/licenses/>. ...@@ -878,23 +878,32 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
} }
// Close modals when clicking outside // Close modals when clicking outside
document.getElementById('donateModal').addEventListener('click', function(e) { const donateModal = document.getElementById('donateModal');
if (e.target === this) { if (donateModal) {
closeDonateModal(); donateModal.addEventListener('click', function(e) {
} if (e.target === this) {
}); closeDonateModal();
}
});
}
document.getElementById('welcomeModal').addEventListener('click', function(e) { const welcomeModal = document.getElementById('welcomeModal');
if (e.target === this) { if (welcomeModal) {
closeWelcomeModal(); welcomeModal.addEventListener('click', function(e) {
} if (e.target === this) {
}); closeWelcomeModal();
}
});
}
document.getElementById('contactModal').addEventListener('click', function(e) { const contactModal = document.getElementById('contactModal');
if (e.target === this) { if (contactModal) {
closeContactModal(); contactModal.addEventListener('click', function(e) {
} if (e.target === this) {
}); closeContactModal();
}
});
}
</script> </script>
{% block extra_js %}{% endblock %} {% block extra_js %}{% endblock %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment