CoreFiles by mySites.guru
run-schedule.js35 lines, 1,077 bytes, from Joomla_6.2.0-alpha2-Alpha-Full_Package.zip
Raw History Compare with 6.2.0-alpha1
md5
8397c2fcbfcddcc770a4a25be026270e
sha1
51c296caf209ef8d4175e789bd8293cf404f45a9
sha256
db0b41b5c963f2104299e9ec6ce6f0ab5fb36046b9209a40d2e8198e4b155b63
/**
 * @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(() => fetch(uri, {
    method: 'GET'
  }), interval);

  // Run it at the beginning at least once
  fetch(uri, {
    method: 'GET'
  });
};
(document => {
  document.addEventListener('DOMContentLoaded', initScheduler);
})(document);

The same content is in 120 releases, Joomla 5.2.0-alpha1 to 6.3.0-alpha1. See them all, or every version of this file.