commit 22/01/2026
This commit is contained in:
@@ -9,7 +9,7 @@ $(document).ready(function() {
|
||||
});
|
||||
});
|
||||
|
||||
$(window).on('beforeunload', function() {
|
||||
$(window).on('unload', function() {
|
||||
console.log("User is leaving home.html");
|
||||
// Your cleanup code here
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
$(document).ready(function() {
|
||||
$(document).ready(function () {
|
||||
// Your code here
|
||||
console.log("log.js is loaded and ready.");
|
||||
let $logchooser = $('#logchooser');
|
||||
@@ -7,19 +7,19 @@ $(document).ready(function() {
|
||||
$logchooser.val(new Date().toISOString().split('T')[0]);
|
||||
}
|
||||
|
||||
$('#logoutbtn').on('click', function() {
|
||||
$('#logoutbtn').on('click', function () {
|
||||
// Clear session storage on logout
|
||||
fetch('/logout').then(() => {
|
||||
window.location.href = '/login.html';
|
||||
window.location.href = '/login.html';
|
||||
});
|
||||
});
|
||||
$logchooser.on('change', function() {
|
||||
$logchooser.on('change', function () {
|
||||
const selectedLog = $(this).val();
|
||||
GetLog(selectedLog);
|
||||
});
|
||||
});
|
||||
|
||||
$(window).on('beforeunload', function() {
|
||||
$(window).on('unload', function () {
|
||||
console.log("User is leaving log.html");
|
||||
// Your cleanup code here
|
||||
});
|
||||
@@ -27,9 +27,42 @@ $(window).on('beforeunload', function() {
|
||||
// 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){
|
||||
Get('getLogs?' + new URLSearchParams({ date: date }).toString(), function (data) {
|
||||
console.log(data);
|
||||
}, function(error){
|
||||
fill_table(data);
|
||||
}, function (error) {
|
||||
fill_table(null);
|
||||
alert(error);
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {Object} logdata
|
||||
* @property {number} index Index number of the log entry
|
||||
* @property {string} date Date string in format dd/mm/yyyy
|
||||
* @property {string} time Time string in format HH:MM:SS
|
||||
* @property {string} function Function name where the log was generated
|
||||
* @property {string} message Log message
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fill table with logdata
|
||||
* @param {logdata[]} data
|
||||
*/
|
||||
function fill_table(data) {
|
||||
let $logtablebody = $('#logtablebody');
|
||||
$logtablebody.empty();
|
||||
if (data && Array.isArray(data) && data.length > 0) {
|
||||
data.forEach(function (logentry) {
|
||||
let row = `<tr>
|
||||
<td>${logentry.index}</td>
|
||||
<td>${logentry.date}</td>
|
||||
<td>${logentry.time}</td>
|
||||
<td>${logentry.function}</td>
|
||||
<td>${logentry.message}</td>
|
||||
</tr>`;
|
||||
$logtablebody.append(row);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ $(document).ready(function() {
|
||||
}
|
||||
});
|
||||
|
||||
$(window).on('beforeunload', function() {
|
||||
$(window).on('unload', function() {
|
||||
console.log("User is leaving login.html");
|
||||
// Your cleanup code here
|
||||
});
|
||||
@@ -20,7 +20,7 @@ $(document).ready(function () {
|
||||
});
|
||||
});
|
||||
|
||||
$(window).on('beforeunload', function () {
|
||||
$(window).on('unload', function () {
|
||||
console.log("User is leaving setting.html");
|
||||
// Your cleanup code here
|
||||
});
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="col-1">No</th>
|
||||
<th class="col-2">Date</th>
|
||||
<th class="col-2">Time</th>
|
||||
<th class="col-2">Category</th>
|
||||
<th class="col-sm-1">No</th>
|
||||
<th class="col-sm-2 col-lg-1">Date</th>
|
||||
<th class="col-sm-2 col-lg-1">Time</th>
|
||||
<th class="col-sm-2 col-lg-2">Category</th>
|
||||
<th>Message</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in New Issue
Block a user