CoreFiles by mySites.guru
run-schedule.js34 lines, 1,076 bytes, from Joomla_4.2.4-Stable-Full_Package.zip
Raw History Compare with 4.2.3
md5
d30e27548849fbffc8f0b202238f6f82
sha1
2b702b9281f96486ed1359dd80ddf3cf90bbf4d3
sha256
4ee702986290f850e64fa0bdbd659067d03b9335f4ef926f8e6afdf538912b23
/**
 * @copyright   (C) 2021 Open Source Matters, Inc. <https://www.joomla.org>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

/**
 * Makes calls to com_ajax to trigger the Scheduler.
 *
 * Used for lazy scheduling of tasks.
 *
 * @package  Joomla.Plugins
 * @subpackage System.ScheduleRunner
 *
 * @since    4.1.0
 */
if (!window.Joomla) {
  throw new Error('Joomla API was not properly initialised');
}

const initScheduler = () => {
  const options = Joomla.getOptions('plg_system_schedulerunner');
  const paths = Joomla.getOptions('system.paths');
  const interval = (options && options.interval ? parseInt(options.interval, 10) : 300) * 1000;
  const uri = `${paths ? `${paths.root}/index.php` : window.location.pathname}?option=com_ajax&format=raw&plugin=RunSchedulerLazy&group=system`;
  setInterval(() => navigator.sendBeacon(uri), interval); // Run it at the beginning at least once

  navigator.sendBeacon(uri);
};

(document => {
  document.addEventListener('DOMContentLoaded', () => {
    initScheduler();
  });
})(document);

The same content is in 39 releases, Joomla 4.1.0-rc2 to 4.2.9. See them all, or every version of this file.