Dear All, @brainstorrrm @givemeawhisky @brett-haralson
I am working on an on idle logout, I have written the below code and it works to the point that if no actions are taken it starts the process of counting down and calling log out, however I have not been able to achieve the countdown reset piece and this is key, so I can hide and show elements etc but it would be great to achieve the reset piece.
I provide the current code that I have, I am keen to achieve this so if individuals walk away from their computers but leave the screen open and not secure they are then logged out automatically, obviously I know that if someone else is in the room then there is the ability for that individual to access the screen etc but it does aid with providing some security.
If you are able to help with the code and help develop a working example it would be greatly appreciated.
Best wishes,
Si
$w.onReady(function () {
myFunction();
});
setInterval(function () {
startCheck();
}, 30000)
function myFunction() {
$w("#page1").onMouseIn((event) => {
$w("#text45").hide();
var X = event.clientX;
console.log(X)
memory.setItem("positionX", X);
var Y = event.clientY;
console.log(Y)
memory.setItem("positionY", Y);
setInterval(function () {
startCheck();
}, 30000)
})
$w("#page1").onMouseOut((event) => {
$w("#text45").hide();
var X = event.clientX;
console.log(X)
memory.setItem("positionX", X);
var Y = event.clientY;
console.log(Y)
memory.setItem("positionY", Y);
setInterval(function () {
startCheck();
}, 30000)
})
$w("#page1").onClick((event) => {
$w("#text45").hide();
var X = event.clientX;
console.log(X)
memory.setItem("positionX", X);
var Y = event.clientY;
console.log(Y)
memory.setItem("positionY", Y);
setInterval(function () {
startCheck();
}, 30000)
})
$w("#page1").onDblClick((event) => {
$w("#text45").hide();
var X = event.clientX;
console.log(X)
memory.setItem("positionX", X);
var Y = event.clientY;
console.log(Y)
memory.setItem("positionY", Y);
setInterval(function () {
startCheck();
}, 30000)
})
}
function startCheck() {
checkMemory();
}
function checkMemory() {
var A = memory.getItem("positionX");
console.log(A)
var B = memory.getItem("positionY");
console.log(B)
let data = [A, B]
return data;
}
setInterval(function () {
checkMemory();
}, 30000)
function checkMemoryData() {
var data = checkMemory();
var firstA = data[0];
var secondA = data[1];
var A = memory.getItem("positionX");
var B = memory.getItem("positionY");
if (firstA === A) {
$w("#text45").show();
$w('#text45').text = "00:00";
let isVisible = $w("#text45").isVisible;
let hidden = $w("#text45").hidden;
if (isVisible === true) {
timerForLogout();
} else if (hidden)
myFunction();
}
}
setInterval(function () {
checkMemoryData();
}, 60000)
function timerForLogout() {
var counter = 30;
var countDown = setInterval(function () {
let minutes = (counter / 60) | 0;
let seconds = (counter % 60) | 0;
minutes = minutes < 10 ? "0" + minutes : minutes;
seconds = seconds < 10 ? "0" + seconds : seconds;
$w("#text45").show();
$w('#text45').text = minutes + ":" + seconds;
counter--
if (counter === 0) {
console.log("User logged Out")
clearInterval(countDown);
}
}, 1000);
}