Files
sirh/static/js/sirh-index.js
2026-05-07 15:23:47 +00:00

75 lines
2.4 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', function() {
navigator.serviceWorker.register('{% static "sw.js" %}').then(function(reg) {
console.log('Service worker registered.', reg);
}).catch(function(err) {
console.warn('Service worker registration failed:', err);
});
});
}
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var messageModal = new bootstrap.Modal(document.getElementById('messageModal'));
messageModal.show();
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var politiqueModal = new bootstrap.Modal(document.getElementById('politiqueModal'));
politiqueModal.show();
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
var politiqueModal = new bootstrap.Modal(document.getElementById('politiqueModal'));
politiqueModal.show();
});
</script>
>
<script>
document.addEventListener("DOMContentLoaded", function() {
var modal = new bootstrap.Modal(document.getElementById('politiqueModal'));
modal.show();
});
</script>
{% endif %}
<!-- Scripts -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://code.jquery.com/jquery-3.7.0.min.js"></script>
<script>
// Afficher / masquer le mot de passe
function togglePassword() {
const input = document.querySelector('input[name="password"]');
input.type = input.type === 'password' ? 'text' : 'password';
}
// AJAX pour réinitialisation
$('#resetPasswordForm').on('submit', function(e) {
e.preventDefault();
const email = $('input[name="email"]').val();
const csrfToken = $('[name=csrfmiddlewaretoken]').val();
$.ajax({
url: "{% url 'password_reset' %}",
type: 'POST',
data: {
'email': email,
'csrfmiddlewaretoken': csrfToken
},
success: function(response) {
$('#resetMessage').html('<div class="alert alert-success">Email envoyé ! Vérifiez votre boîte de réception.</div>');
},
error: function() {
$('#resetMessage').html('<div class="alert alert-danger">Erreur lors de lenvoi. Vérifiez lemail.</div>');
}
});
});
</script>