CoreFiles by mySites.guru
privacycheck.es6.js66 lines, 2,658 bytes, from Joomla_4.0.0-beta6-Beta-Full_Package.zip
Raw History Compare with 4.0.0-beta5
md5
4670c5b544e9386611836265fdccb1d8
sha1
89f868013b37e50b9ee919be53115d90ed3b8fa8
sha256
40aa47af01661c8b57355c843a54b99ce9363b67acd030c1f8dd6ce748d4d54c
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright  (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
 * @license    GNU General Public License version 2 or later; see LICENSE.txt
 */
(document => {
  'use strict';

  document.addEventListener('DOMContentLoaded', () => {
    const variables = Joomla.getOptions('js-privacy-check');
    const ajaxUrl = variables.plg_quickicon_privacycheck_ajax_url;
    const url = variables.plg_quickicon_privacycheck_url;
    const text = variables.plg_quickicon_privacycheck_text;
    const quickicon = document.getElementById('plg_quickicon_privacycheck');
    const link = quickicon.querySelector('span.j-links-link');
    Joomla.request({
      url: ajaxUrl,
      method: 'GET',
      data: '',
      perform: true,
      onSuccess: response => {
        try {
          const request = JSON.parse(response);

          if (request.data.number_urgent_requests) {
            // Quickicon on dashboard shows message
            link.textContent = `${text.REQUESTFOUND} ${request.data.number_urgent_requests}`; // Quickicon becomes red

            quickicon.classList.add('danger'); // Span in alert message

            const countSpan = document.createElement('span');
            countSpan.classList.add('label', 'label-important');
            countSpan.textContent = request.data.number_urgent_requests; // Button in alert to 'view requests'

            const requestButton = document.createElement('button');
            requestButton.classList.add('btn', 'btn-primary');
            requestButton.setAttribute('onclick', `document.location='${url}'`);
            requestButton.textContent = text.REQUESTFOUND_BUTTON;
            const div = document.createElement('div');
            div.classList.add('alert', 'alert-error', 'alert-joomlaupdate');
            div.appendChild(countSpan);
            div.insertAdjacentText('beforeend', ` ${text.REQUESTFOUND_MESSAGE}`);
            div.appendChild(requestButton); // Add elements to container for alert messages

            const container = document.querySelector('#system-message-container');
            container.insertBefore(div, container.firstChild);
          } else {
            quickicon.classList.add('success');
            link.textContent = text.NOREQUEST;
          }
        } catch (e) {
          quickicon.classList.add('danger');
          link.textContent = text.ERROR;
        }
      },
      onError: () => {
        quickicon.classList.add('danger');
        link.textContent = text.ERROR;
      }
    });
  });
})(document);

The same content is in 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.