1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 16:13:20 +01:00
invoiceninja/resources/views/partials/warn_session.blade.php
2017-04-26 21:28:24 +03:00

39 lines
1.2 KiB
PHP

<div class="alert alert-warning" style="display:none" id="keepAliveDiv">
{!! trans('texts.page_expire', ['click_here' => link_to('#', trans('texts.click_here'), ['onclick' => 'keepAlive()'])]) !!}
</div>
<script type="text/javascript">
var redirectTimer = null;
function startWarnSessionTimeout() {
var oneMinute = 1000 * 60;
var threeMinutes = oneMinute * 3;
var waitTime = oneMinute * 60 * 4; // 4 hours
setTimeout(function() {
warnSessionExpring();
}, (waitTime - threeMinutes));
}
function warnSessionExpring() {
$("#keepAliveDiv").fadeIn();
redirectTimer = setTimeout(function() {
NINJA.formIsChanged = false;
window.location = '{{ URL::to($redirectTo) }}';
}, 1000 * 60);
}
// keep the token cookie valid to prevent token mismatch errors
function keepAlive() {
clearTimeout(redirectTimer);
$('#keepAliveDiv').fadeOut();
$.get('{{ URL::to('/keep_alive') }}');
startWarnSessionTimeout();
}
$(function() {
if ($('form.warn-on-exit, form.form-signin').length > 0) {
startWarnSessionTimeout();
}
});
</script>