CoreFiles by mySites.guru
privacycheck.es6.js66 lines, 2,703 bytes, from Joomla_4.0.0-alpha12-Alpha-Full_Package.zip
Raw History Compare with 4.0.0-alpha11
md5
0da5850de5d4660d871a221675635b92
sha1
09194f0d98562e92d9d88e4e3f08c0c5ae518e3c
sha256
3904271b698197c2807289a988edc1d4c6cae42d3e2183cc712e3ae4a0d53285
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
 * @copyright  Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
 * @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 = "".concat(text.REQUESTFOUND, " ").concat(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='".concat(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', " ".concat(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-alpha11 to 4.0.0-alpha12. See them all, or every version of this file.