CoreFiles by mySites.guru
keepalive.js48 lines, 1,638 bytes, from Joomla_4.0.0-beta1-Beta-Full_Package.zip
Raw History Compare with 3.9.0-beta4
md5
fae0ac030f767b8ba35c7392a04ecc09
sha1
40d4002f0b5348771b85b8c8652dea3d9ed521fd
sha256
51068e36f7c75d60ef0dc128c0a58a4917e4628f44e993c704486f9e7c45f221
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright   Copyright (C) 2005 - 2020 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * Keepalive javascript behavior
 *
 * Used for keeping the session alive
 *
 * @package  Joomla.JavaScript
 * @since    3.7.0
 */
(function (document, Joomla) {
  'use strict';

  var keepAlive = function keepAlive(keepAliveUri) {
    Joomla.request({
      url: keepAliveUri
    });
  };

  var onBoot = function onBoot() {
    if (!Joomla || typeof Joomla.getOptions !== 'function' && typeof Joomla.request !== 'function') {
      throw new Error('core.js was not properly initialised');
    }

    var keepAliveOptions = Joomla.getOptions('system.keepalive');
    var keepAliveInterval = keepAliveOptions && keepAliveOptions.interval ? parseInt(keepAliveOptions.interval, 10) : 45 * 1000;
    var keepAliveUri = keepAliveOptions && keepAliveOptions.uri ? keepAliveOptions.uri.replace(/&/g, '&') : ''; // Fallback in case no keepalive uri was found.

    if (keepAliveUri === '') {
      var systemPaths = Joomla.getOptions('system.paths');
      keepAliveUri = "".concat(systemPaths ? "".concat(systemPaths.root, "/index.php") : window.location.pathname, "?option=com_ajax&format=json");
    }

    setInterval(keepAlive, keepAliveInterval, keepAliveUri); // Cleanup

    document.removeEventListener('DOMContentLoaded', onBoot);
  };

  document.addEventListener('DOMContentLoaded', onBoot, true);
})(document, Joomla);

The same content is in 5 releases, Joomla 4.0.0-beta to 4.0.0-beta5. See them all, or every version of this file.