| Server IP : 182.53.201.61 / Your IP : 216.73.217.175 Web Server : Apache/2.2.15 (Fedora) System : Linux km10.dyndns.org 2.6.31.5-127.fc12.i686.PAE #1 SMP Sat Nov 7 21:25:57 EST 2009 i686 User : apache ( 48) PHP Version : 5.3.3 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/Menu_Nurse/wd/js/ |
Upload File : |
// Dashboard JavaScript functionality
document.addEventListener('DOMContentLoaded', function() {
// Date picker enhancement
const dateInput = document.getElementById('fetch_date');
const today = new Date().toISOString().split('T')[0];
// Set default date to today if no date is selected
if (dateInput && !dateInput.value) {
dateInput.value = today;
}
// Add date validation
if (dateInput) {
dateInput.addEventListener('change', function() {
const selectedDate = new Date(this.value);
const today = new Date();
// Prevent selecting future dates
if (selectedDate > today) {
alert('Cannot select future dates. Please select today or a past date.');
this.value = today.toISOString().split('T')[0];
}
});
}
// Auto-submit form when date changes (optional)
const autoSubmitCheckbox = document.getElementById('auto_submit');
if (autoSubmitCheckbox && dateInput) {
dateInput.addEventListener('change', function() {
if (autoSubmitCheckbox.checked) {
this.form.submit();
}
});
}
// Add keyboard shortcuts
document.addEventListener('keydown', function(e) {
// Ctrl/Cmd + Enter to submit the form
if ((e.ctrlKey || e.metaKey) && e.key === 'Enter') {
const form = document.querySelector('form[method="get"]');
if (form) {
form.submit();
}
}
// Escape key to clear date
if (e.key === 'Escape') {
if (dateInput) {
dateInput.value = '';
}
}
});
// Add loading indicator
const forms = document.querySelectorAll('form');
forms.forEach(form => {
form.addEventListener('submit', function() {
const submitBtn = this.querySelector('button[type="submit"]');
if (submitBtn) {
submitBtn.innerHTML = '<span class="spinner-border spinner-border-sm me-2"></span>Loading...';
submitBtn.disabled = true;
}
});
});
// Table row highlighting
const tableRows = document.querySelectorAll('tbody tr');
tableRows.forEach(row => {
row.addEventListener('mouseenter', function() {
this.style.backgroundColor = '#f8f9fa';
});
row.addEventListener('mouseleave', function() {
this.style.backgroundColor = '';
});
});
// Add copy functionality for table data
const copyButtons = document.querySelectorAll('.copy-data');
copyButtons.forEach(button => {
button.addEventListener('click', function() {
const table = this.closest('.table-responsive').querySelector('table');
const rows = table.querySelectorAll('tbody tr');
let csvContent = '';
// Get headers
const headers = table.querySelectorAll('thead th');
const headerRow = Array.from(headers).map(th => th.textContent.trim()).join(',');
csvContent += headerRow + '\n';
// Get data rows
rows.forEach(row => {
const cells = row.querySelectorAll('td');
const rowData = Array.from(cells).map(cell => cell.textContent.trim()).join(',');
csvContent += rowData + '\n';
});
// Copy to clipboard
navigator.clipboard.writeText(csvContent).then(() => {
alert('Table data copied to clipboard!');
}).catch(err => {
console.error('Failed to copy: ', err);
});
});
});
});