mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
v2.70
This commit is contained in:
@@ -1,9 +1,89 @@
|
||||
/* -----------------------------------------------------------------------------
|
||||
Pi.Alert Common Javascript functions
|
||||
* Pi.Alert
|
||||
* Open Source Network Guard / WIFI & LAN intrusion detector
|
||||
*
|
||||
* pialert_common.js - Front module. Common Javascript functions
|
||||
*-------------------------------------------------------------------------------
|
||||
* Puche 2021 pi.alert.application@gmail.com GNU GPLv3
|
||||
----------------------------------------------------------------------------- */
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
var timerRefreshData = ''
|
||||
var modalCallbackFunction = '';
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showModal (title, message, btnCancel, btnOK, callbackFunction) {
|
||||
// set captions
|
||||
$('#modal-title').html (title);
|
||||
$('#modal-message').html (message);
|
||||
$('#modal-cancel').html (btnCancel);
|
||||
$('#modal-OK').html (btnOK);
|
||||
modalCallbackFunction = callbackFunction;
|
||||
|
||||
// Show modal
|
||||
$('#modal-warning').modal('show');
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function modalOK () {
|
||||
// Hide modal
|
||||
$('#modal-warning').modal('hide');
|
||||
|
||||
// timer to execute function
|
||||
window.setTimeout( function() {
|
||||
window[modalCallbackFunction]();
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function showMessage (textMessage="") {
|
||||
if (textMessage.toLowerCase().includes("error") ) {
|
||||
// show error
|
||||
alert (textMessage);
|
||||
} else {
|
||||
// show temporal notification
|
||||
$("#alert-message").html (textMessage);
|
||||
$("#notification").fadeIn(1, function () {
|
||||
window.setTimeout( function() {
|
||||
$("#notification").fadeOut(500)
|
||||
}, 3000);
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function setParameter (parameter, value) {
|
||||
// Retry
|
||||
$.get('php/server/parameters.php?action=set¶meter=' + parameter +
|
||||
'&value='+ value,
|
||||
function(data) {
|
||||
if (data != "OK") {
|
||||
// Retry
|
||||
sleep (200);
|
||||
$.get('php/server/parameters.php?action=set¶meter=' + parameter +
|
||||
'&value='+ value,
|
||||
function(data) {
|
||||
if (data != "OK") {
|
||||
// alert (data);
|
||||
} else {
|
||||
// alert ("OK. Second attempt");
|
||||
};
|
||||
} );
|
||||
};
|
||||
} );
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function sleep(milliseconds) {
|
||||
const date = Date.now();
|
||||
let currentDate = null;
|
||||
do {
|
||||
currentDate = Date.now();
|
||||
} while (currentDate - date < milliseconds);
|
||||
}
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -35,5 +115,7 @@ function newTimerRefreshData (refeshFunction) {
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
function debugTimer () {
|
||||
document.getElementById ('pageTitle').innerHTML = (new Date().getSeconds());
|
||||
$('#pageTitle').html (new Date().getSeconds());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user