[ 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 window.customElements.define('joomla-hidden-mail', class extends HTMLElement { 6 constructor() { 7 super(); 8 this.newElement = ''; 9 this.base = ''; 10 } 11 /** 12 * Lifecycle 13 */ 14 15 16 disconnectedCallback() { 17 this.innerHTML = ''; 18 } 19 /** 20 * Lifecycle 21 */ 22 23 24 connectedCallback() { 25 this.base = `$this.getAttribute('base')}/`; 26 27 if (this.getAttribute('is-link') === '1') { 28 this.newElement = document.createElement('a'); 29 this.newElement.setAttribute('href', `mailto:$this.constructor.b64DecodeUnicode(this.getAttribute('first'))}@$this.constructor.b64DecodeUnicode(this.getAttribute('last'))}`); // Get all of the original element attributes, and pass them to the link 30 31 [].slice.call(this.attributes).forEach((attribute, index) => { 32 const { 33 nodeName 34 } = this.attributes.item(index); 35 36 if (nodeName) { 37 // We do care for some attributes 38 if (['is-link', 'is-email', 'first', 'last', 'text'].indexOf(nodeName) === -1) { 39 const { 40 nodeValue 41 } = this.attributes.item(index); 42 this.newElement.setAttribute(nodeName, nodeValue); 43 } 44 } 45 }); 46 } else { 47 this.newElement = document.createElement('span'); 48 } 49 50 if (this.getAttribute('text')) { 51 let innerStr = this.constructor.b64DecodeUnicode(this.getAttribute('text')); 52 innerStr = innerStr.replace('src="images/', `src="$this.base}images/`).replace('src="media/', `src="$this.base}media/`); 53 this.newElement.innerHTML = Joomla.sanitizeHtml(innerStr); 54 } else { 55 this.newElement.innerText = `$window.atob(this.getAttribute('first'))}@$window.atob(this.getAttribute('last'))}`; 56 } // Remove the noscript message 57 58 59 this.innerText = ''; // Display the new element 60 61 this.appendChild(this.newElement); 62 } 63 64 static b64DecodeUnicode(str) { 65 return decodeURIComponent(Array.prototype.map.call(atob(str), c => `%${`00$c.charCodeAt(0).toString(16)}`.slice(-2)}`).join('')); 66 } 67 68 });
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 |