commit 22/01/2026

This commit is contained in:
2026-01-22 13:57:34 +07:00
parent 34cf8c97df
commit ffd41ee225
10 changed files with 163 additions and 72 deletions

View File

@@ -1,15 +1,35 @@
$(document).ready(function() {
// Your code here
console.log("log.js is loaded and ready.");
let $logchooser = $('#logchooser');
// if logchooser value is null, set to today's date in format mm/dd/yyyy
if ($logchooser.val() === null) {
$logchooser.val(new Date().toISOString().split('T')[0]);
}
$('#logoutbtn').on('click', function() {
// Clear session storage on logout
fetch('/logout').then(() => {
window.location.href = '/login.html';
});
});
$logchooser.on('change', function() {
const selectedLog = $(this).val();
GetLog(selectedLog);
});
});
$(window).on('beforeunload', function() {
console.log("User is leaving log.html");
// Your cleanup code here
});
});
// function GetLog with date parameter in string, with default value today's date in format dd/mm/yyyy
function GetLog(date = new Date().toISOString().split('T')[0]) {
console.log("Fetching logs for date: " + date);
Get('getLogs?'+new URLSearchParams({date: date}).toString(), function(data){
console.log(data);
}, function(error){
alert(error);
})
}