CoreFiles by mySites.guru
keepalive.js48 lines, 1,625 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
a36639a0ae408bc6e8683e02135b4c70
sha1
3fa7edb619a673d2ff2bcfea51781df98a5f3782
sha256
6f5bade16c5e7e904608fd972331c18cf7e2ed04d6ad918eafb3dd5ba9235f1e
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
 * @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(/&amp;/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 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.