keep-alive.js 468 B

1234567891011121314151617
  1. import $ from 'jquery';
  2. import {config} from 'grav-form';
  3. const MAX_SAFE_DELAY = 2147483647;
  4. $(document).ready(() => {
  5. const keepAlive = $('[data-grav-keepalive]');
  6. if (keepAlive.length) {
  7. const timeout = config.session_timeout / 1.5 * 1000;
  8. setInterval(() => {
  9. $.ajax({
  10. url: `${config.base_url_relative}/task${config.param_sep}keep-alive`
  11. });
  12. }, Math.min(timeout, MAX_SAFE_DELAY));
  13. }
  14. });