CoreFiles by mySites.guru
run-schedule.js33 lines, 1,076 bytes, from Joomla_4.3.1-Stable-Full_Package.zip
Raw History Compare with 4.3.0
md5
df78e9dd7ee07b2f9bf6fca3d3201fee
sha1
a672ce8f56b081a422091ffe9c111883a2db7256
sha256
3d162626f386d3f964319d4eaeb940d098c52926f3f2dcd961daf982fc51391b
/**
 * @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 13 releases, Joomla 4.3.0-alpha1 to 4.3.1. See them all, or every version of this file.