[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 (function () { 2 'use strict'; 3 4 /** 5 * @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org> 6 * @license GNU General Public License version 2 or later; see LICENSE.txt 7 */ 8 (function (document, Joomla) { 9 var init = function init() { 10 // Cleanup 11 window.removeEventListener('load', init); // Get the elements 12 13 var elements = [].slice.call(document.querySelectorAll('.system-counter')); 14 15 if (elements.length) { 16 elements.forEach(function (element) { 17 var badgeurl = element.getAttribute('data-url'); 18 19 if (badgeurl && Joomla && Joomla.request && typeof Joomla.request === 'function') { 20 Joomla.enqueueRequest({ 21 url: badgeurl, 22 method: 'POST', 23 promise: true 24 }).then(function (xhr) { 25 var resp = xhr.responseText; 26 var response; 27 28 try { 29 response = JSON.parse(resp); 30 } catch (error) { 31 throw new Error('Failed to parse JSON'); 32 } 33 34 if (response.error || !response.success) { 35 element.classList.remove('icon-spin'); 36 element.classList.remove('icon-spinner'); 37 element.classList.add('text-danger'); 38 element.classList.add('icon-remove'); 39 } else if (response.data) { 40 var elem = document.createElement('span'); 41 elem.classList.add('float-end'); 42 elem.classList.add('badge'); 43 elem.classList.add('bg-warning', 'text-dark'); 44 elem.innerHTML = Joomla.sanitizeHtml(response.data); 45 element.parentNode.replaceChild(elem, element); 46 } else { 47 element.classList.remove('icon-spin'); 48 element.classList.remove('icon-spinner'); 49 element.classList.add('icon-check'); 50 element.classList.add('text-success'); 51 } 52 }).catch(function () { 53 element.classList.remove('icon-spin'); 54 element.classList.remove('icon-spinner'); 55 element.classList.add('text-danger'); 56 element.classList.add('icon-remove'); 57 }); 58 } 59 }); 60 } 61 }; // Give some times to the layout and other scripts to settle their stuff 62 63 64 window.addEventListener('load', function () { 65 setTimeout(init, 300); 66 }); 67 })(document, Joomla); 68 69 })();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |