[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/system/js/ -> keepalive.js (source)

   1  /**
   2   * @copyright   (C) 2018 Open Source Matters, Inc. <https://www.joomla.org>
   3   * @license     GNU General Public License version 2 or later; see LICENSE.txt
   4   */
   5  
   6  /**
   7   * Keepalive javascript behavior
   8   *
   9   * Used for keeping the session alive
  10   *
  11   * @package  Joomla.JavaScript
  12   * @since    3.7.0
  13   */
  14  if (!window.Joomla) {
  15    throw new Error('Joomla API was not properly initialised');
  16  }
  17  
  18  const keepAliveOptions = Joomla.getOptions('system.keepalive');
  19  const keepAliveInterval = keepAliveOptions && keepAliveOptions.interval ? parseInt(keepAliveOptions.interval, 10) : 45 * 1000;
  20  let keepAliveUri = keepAliveOptions && keepAliveOptions.uri ? keepAliveOptions.uri.replace(/&amp;/g, '&') : ''; // Fallback in case no keepalive uri was found.
  21  
  22  if (keepAliveUri === '') {
  23    const systemPaths = Joomla.getOptions('system.paths');
  24    keepAliveUri = `$systemPaths ? `$systemPaths.root}/index.php` : window.location.pathname}?option=com_ajax&format=json`;
  25  }
  26  
  27  setInterval(() => navigator.sendBeacon(keepAliveUri), keepAliveInterval);


Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer