Commit 60a33914 authored by Michal Čihař's avatar Michal Čihař

Avoid client side auto locking if user is idle

If user did no activity in 5 minutes, let the locks expire.
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent fb1f2f0e
......@@ -747,10 +747,13 @@ $(function () {
/* Lock updates */
if ($('#js-lock').length > 0) {
var jsLockUpdate = window.setInterval(function () {
/* No locking for idle users */
if (idleTime >= 5) {
return;
}
$.ajax({
url: $('#js-lock').attr('href'),
success: function(data) {
console.log(data);
if (! data.status) {
$('.lock-error').remove();
var message = $('<div class="alert lock-error alert-danger"></div>');
......@@ -761,6 +764,27 @@ $(function () {
dataType: 'json'
});
}, 19000);
var idleTime = 0;
var idleInterval = setInterval(
function () {
idleTime = idleTime + 1;
},
60000 // 1 minute
);
// Zero the idle timer on mouse movement.
$(document).click(function (e) {
idleTime = 0;
});
$(document).mousemove(function (e) {
idleTime = 0;
});
$(document).keypress(function (e) {
idleTime = 0;
});
window.setInterval(function () {
window.clearInterval(jsLockUpdate);
}, 3600000);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment