Files
NetAlertX/front/js/tests.js
2024-06-01 20:05:15 +10:00

52 lines
1.3 KiB
JavaScript
Executable File

// --------------------------------------------------
// Check if database is locked
function lockDatabase(delay=20) {
$.ajax({
url: 'php/server/dbHelper.php', // Replace with the actual path to your PHP file
type: 'GET',
data: { action: 'lockDatabase', delay: delay },
success: function(response) {
console.log('Executed');
},
error: function() {
console.log('Error ocurred');
}
});
let times = delay;
let countdownInterval = setInterval(() => {
times--;
console.log(`Remaining time: ${times} seconds`);
if (times <= 0) {
clearInterval(countdownInterval);
console.log('Countdown finished');
}
}, 1000);
}
function writeNotification(content, level) {
const phpEndpoint = 'php/server/utilNotification.php';
$.ajax({
url: phpEndpoint, // Change this to the path of your PHP script
type: 'GET',
data: {
action: 'write_notification',
content: content,
level: level
},
success: function(response) {
alert('Notification written successfully.');
},
error: function(xhr, status, error) {
console.error('Error writing notification:', error);
}
});
}