[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/media/plg_quickicon_extensionupdate/js/ -> extensionupdatecheck.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    const fetchUpdate = () => {
   8      if (Joomla.getOptions('js-extensions-update')) {
   9        const options = Joomla.getOptions('js-extensions-update');
  10  
  11        const update = (type, text) => {
  12          const link = document.getElementById('plg_quickicon_extensionupdate');
  13          const linkSpans = [].slice.call(link.querySelectorAll('span.j-links-link'));
  14  
  15          if (link) {
  16            link.classList.add(type);
  17          }
  18  
  19          if (linkSpans.length) {
  20            linkSpans.forEach(span => {
  21              span.innerHTML = Joomla.sanitizeHtml(text);
  22            });
  23          }
  24        };
  25        /**
  26         * DO NOT use fetch() for QuickIcon requests. They must be queued.
  27         *
  28         * @see https://github.com/joomla/joomla-cms/issues/38001
  29         */
  30  
  31  
  32        Joomla.enqueueRequest({
  33          url: options.ajaxUrl,
  34          method: 'GET',
  35          promise: true
  36        }).then(xhr => {
  37          const response = xhr.responseText;
  38          const updateInfoList = JSON.parse(response);
  39  
  40          if (Array.isArray(updateInfoList)) {
  41            if (updateInfoList.length === 0) {
  42              // No updates
  43              update('success', Joomla.Text._('PLG_QUICKICON_EXTENSIONUPDATE_UPTODATE'));
  44            } else {
  45              update('danger', Joomla.Text._('PLG_QUICKICON_EXTENSIONUPDATE_UPDATEFOUND').replace('%s', `<span class="badge text-dark bg-light">$updateInfoList.length}</span>`));
  46            }
  47          } else {
  48            // An error occurred
  49            update('danger', Joomla.Text._('PLG_QUICKICON_EXTENSIONUPDATE_ERROR'));
  50          }
  51        }).catch(() => {
  52          // An error occurred
  53          update('danger', Joomla.Text._('PLG_QUICKICON_EXTENSIONUPDATE_ERROR'));
  54        });
  55      }
  56    }; // Give some times to the layout and other scripts to settle their stuff
  57  
  58  
  59    window.addEventListener('load', () => {
  60      setTimeout(fetchUpdate, 330);
  61    });
  62  })();


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