mirror of
https://github.com/Dvorinka/PPve.git
synced 2026-06-04 04:22:58 +00:00
rer
This commit is contained in:
+18
-2
@@ -1778,18 +1778,34 @@
|
|||||||
return vehicleEventsCount;
|
return vehicleEventsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debounce function to prevent multiple rapid calls
|
||||||
|
function debounce(func, wait) {
|
||||||
|
let timeout;
|
||||||
|
return function executedFunction(...args) {
|
||||||
|
const later = () => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
func(...args);
|
||||||
|
};
|
||||||
|
clearTimeout(timeout);
|
||||||
|
timeout = setTimeout(later, wait);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Debounced version of checkHighTraffic
|
||||||
|
const debouncedCheckHighTraffic = debounce(checkHighTraffic, 300);
|
||||||
|
|
||||||
// Add event listeners for high traffic checking
|
// Add event listeners for high traffic checking
|
||||||
document.getElementById('vehicle').addEventListener('change', function() {
|
document.getElementById('vehicle').addEventListener('change', function() {
|
||||||
const startDate = document.getElementById('startDate').value;
|
const startDate = document.getElementById('startDate').value;
|
||||||
if (startDate) {
|
if (startDate) {
|
||||||
checkHighTraffic(this.value, new Date(startDate));
|
debouncedCheckHighTraffic(this.value, new Date(startDate));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('startDate').addEventListener('change', function() {
|
document.getElementById('startDate').addEventListener('change', function() {
|
||||||
const vehicle = document.getElementById('vehicle').value;
|
const vehicle = document.getElementById('vehicle').value;
|
||||||
if (vehicle) {
|
if (vehicle) {
|
||||||
checkHighTraffic(vehicle, new Date(this.value));
|
debouncedCheckHighTraffic(vehicle, new Date(this.value));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user