first commit
This commit is contained in:
33
web/static/js/app.js
Normal file
33
web/static/js/app.js
Normal file
@@ -0,0 +1,33 @@
|
||||
// Homework Manager JavaScript
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Auto-dismiss alerts after 5 seconds
|
||||
const alerts = document.querySelectorAll('.alert:not(.alert-danger)');
|
||||
alerts.forEach(function(alert) {
|
||||
setTimeout(function() {
|
||||
alert.classList.add('fade');
|
||||
setTimeout(function() {
|
||||
alert.remove();
|
||||
}, 150);
|
||||
}, 5000);
|
||||
});
|
||||
|
||||
// Confirm dialogs for dangerous actions
|
||||
const confirmForms = document.querySelectorAll('form[data-confirm]');
|
||||
confirmForms.forEach(function(form) {
|
||||
form.addEventListener('submit', function(e) {
|
||||
if (!confirm(form.dataset.confirm)) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Set default datetime to now + 1 day for new assignments
|
||||
const dueDateInput = document.getElementById('due_date');
|
||||
if (dueDateInput && !dueDateInput.value) {
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
tomorrow.setHours(23, 59, 0, 0);
|
||||
dueDateInput.value = tomorrow.toISOString().slice(0, 16);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user