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