35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
$(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);
|
|
})
|
|
} |