mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
🔒DB lock v0.4 #685 + 🔔userNotifications
This commit is contained in:
51
front/js/tests.js
Executable file
51
front/js/tests.js
Executable file
@@ -0,0 +1,51 @@
|
||||
// --------------------------------------------------
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user