wiki-grav/plugins/form/app/utils/keep-alive.js
2022-04-24 14:32:58 +02:00

18 lines
468 B
JavaScript

import $ from 'jquery';
import {config} from 'grav-form';
const MAX_SAFE_DELAY = 2147483647;
$(document).ready(() => {
const keepAlive = $('[data-grav-keepalive]');
if (keepAlive.length) {
const timeout = config.session_timeout / 1.5 * 1000;
setInterval(() => {
$.ajax({
url: `${config.base_url_relative}/task${config.param_sep}keep-alive`
});
}, Math.min(timeout, MAX_SAFE_DELAY));
}
});