1/* ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 2 COMPARTIR 3 Pinta la fila de botones dentro de cualquier elemento con 4 id="rejilla-compartir", y se encarga de copiar el enlace y de 5 abrir el menú de compartir del propio móvil. 6 7 Para quitar o añadir una red, edita la lista CANALES. 8 ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ */ 9(function () { 10 "use strict"; 11 12 var enc = encodeURIComponent; 13 14 /* Los iconos van en el mismo lienzo de 24x24 que los del sitio */ 15 var ICONOS = { 16 nativo: '<path d="M18 16.1a3 3 0 0 0-2 .8l-7.1-4.2c0-.2.1-.4.1-.7s0-.5-.1-.7L16 7.2a3 3 0 1 0-1-2.2c0 .3 0 .5.1.7L8 9.9a3 3 0 1 0 0 4.2l7.1 4.2c0 .2-.1.4-.1.6a3 3 0 1 0 3-2.8z"/>', 17 whatsapp: '<path d="M12 2a10 10 0 0 0-8.5 15.2L2 22l4.9-1.4A10 10 0 1 0 12 2zm0 18.2a8.2 8.2 0 0 1-4.2-1.2l-.3-.2-2.9.8.8-2.9-.2-.3A8.2 8.2 0 1 1 12 20.2zm4.6-6.1c-.3-.1-1.5-.7-1.7-.8-.2-.1-.4-.1-.6.1l-.8 1c-.2.2-.3.2-.6.1a6.7 6.7 0 0 1-3.3-2.9c-.2-.4.2-.4.6-1.2.1-.1 0-.3 0-.4L9.5 8c-.2-.5-.4-.4-.6-.4h-.5a1 1 0 0 0-.7.3 3 3 0 0 0-.9 2.2 5.2 5.2 0 0 0 1.1 2.7 11.9 11.9 0 0 0 4.6 4c1.9.8 2.7.8 3.6.7a3 3 0 0 0 2-1.4 2.4 2.4 0 0 0 .2-1.4c-.1-.2-.3-.3-.6-.4z"/>', 18 telegram: '<path d="M21.9 4.3 19 19.5c-.2 1-.8 1.2-1.6.8l-4.4-3.3-2.1 2c-.2.3-.4.5-.9.5l.3-4.5 8.2-7.4c.4-.3-.1-.5-.6-.2L7.8 13.2 3.4 11.8c-1-.3-1-1 .2-1.4l17-6.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.3 2.9-2 3z"/>', 22 bluesky: '<path d="M12 10.8C10.9 8.6 7.9 4.5 5.1 2.6 2.2.6 1.1 1 .4 1.3c-.8.4-.9 1.6-.9 2.3s.4 5.7.6 6.6c.7 3 3.9 4 6.8 3.7h.3c-2.9.5-5.5 1.5-2.1 5.3 3.7 4 5.1-.9 5.8-3.3l1.1-3.1 1.1 3.1c.7 2.4 2.1 7.3 5.8 3.3 3.4-3.8.8-4.8-2.1-5.3h.3c2.9.3 6.1-.7 6.8-3.7.2-.9.6-5.9.6-6.6s-.1-1.9-.9-2.3C22.9 1 21.8.6 18.9 2.6 16.1 4.5 13.1 8.6 12 10.8z"/>', 23 email: '<path d="M20 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zm0 4.2-8 5-8-5V6l8 5 8-5v2.2z"/>', 24 instalar: '<path d="M12 3v10.6l3.3-3.3 1.4 1.4L12 17.4l-4.7-4.7 1.4-1.4 3.3 3.3V3h2zM5 19h14v2H5v-2z"/>', 25 copiar: '<path d="M16 1H4a2 2 0 0 0-2 2v14h2V3h12V1zm3 4H8a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2zm0 16H8V7h11v14z"/>' 26 }; 27 28 var CANALES = [ 29 { id: "whatsapp", nombre: "WhatsApp", url: function (u, t) { return "https://api.whatsapp.com/send?text=" + enc(t + " " + u); } }, 30 { id: "telegram", nombre: "Telegram", url: function (u, t) { return "https://t.me/share/url?url=" + enc(u) + "&text=" + enc(t); } }, 31 { id: "facebook", nombre: "Facebook", url: function (u) { return "https://www.facebook.com/sharer/sharer.php?u=" + enc(u); } }, 32 { id: "x", nombre: "X", url: function (u, t) { return "https://twitter.com/intent/tweet?url=" + enc(u) + "&text=" + enc(t); } }, 33 { id: "threads", nombre: "Threads", url: function (u, t) { return "https://www.threads.net/intent/post?text=" + enc(t + " " + u); } }, 34 { id: "bluesky", nombre: "Bluesky", url: function (u, t) { return "https://bsky.app/intent/compose?text=" + enc(t + " " + u); } }, 35 { id: "email", nombre: "", clave: "shareEmail", 36 url: function (u, t) { return "mailto:?subject=" + enc(t) + "&body=" + enc(t + "\n\n" + u); } } 37 ]; 38 39 function texto(clave, respaldo) { 40 try { 41 var lang = document.documentElement.lang || "es"; 42 var t = (typeof I18N !== "undefined" && (I18N[lang] || I18N.es)) || {}; 43 return t[clave] || respaldo; 44 } catch (e) { return respaldo; } 45 } 46 47 function estaPagina() { 48 var canonica = document.querySelector('link[rel="canonical"]'); 49 return { 50 url: canonica ? canonica.href : location.href.split("#")[0], 51 titulo: document.title 52 }; 53 } 54 55 function icono(id) { 56 return '<svg viewBox="0 0 24 24" aria-hidden="true">' + (ICONOS[id] || "") + "</svg>"; 57 } 58 59 60 /* ââ Instalar como aplicación âââââââââââââââââââââââââââââââ 61 El navegador avisa cuando la web se puede instalar. Se guarda 62 ese aviso y se enseña el botón; si nunca avisa (ya está 63 instalada, o el navegador no lo admite) el botón no aparece. */ 64 var aviso = null; 65 66 window.addEventListener("beforeinstallprompt", function (e) { 67 e.preventDefault(); 68 aviso = e; 69 pintar(); 70 }); 71 72 window.addEventListener("appinstalled", function () { 73 aviso = null; 74 pintar(); 75 }); 76 77 function pintar() { 78 var caja = document.getElementById("rejilla-compartir"); 79 if (!caja) return; 80 81 var d = estaPagina(); 82 var mensaje = texto("shareMessage", d.titulo); 83 var html = ""; 84 85 if (navigator.share) { 86 html += '<button type="button" class="enlace-red compartir-boton" data-accion="nativo">' + 87 icono("nativo") + '<span data-i18n="shareNative">' + texto("shareNative", "Compartir") + "</span></button>"; 88 } 89 90 CANALES.forEach(function (c) { 91 var etiqueta = c.nombre || texto(c.clave, "Correo"); 92 html += '<a class="enlace-red" href="' + c.url(d.url, mensaje) + '" target="_blank" rel="noopener">' + 93 icono(c.id) + "<span" + (c.clave ? ' data-i18n="' + c.clave + '"' : "") + ">" + etiqueta + "</span></a>"; 94 }); 95 96 if (aviso) { 97 html += '<button type="button" class="enlace-red compartir-boton" data-accion="instalar">' + 98 icono("instalar") + '<span data-i18n="installApp">' + texto("installApp", "Instalar como aplicación") + "</span></button>"; 99 } 100 101 html += '<button type="button" class="enlace-red compartir-boton" data-accion="copiar">' + 102 icono("copiar") + '<span data-i18n="shareCopy">' + texto("shareCopy", "Copiar enlace") + "</span></button>"; 103 104 caja.innerHTML = html; 105 } 106 107 function copiar(boton) { 108 var url = estaPagina().url; 109 var span = boton.querySelector("span"); 110 var antes = span ? span.textContent : ""; 111 112 function avisar(bien) { 113 if (!span) return; 114 span.textContent = bien ? texto("shareCopied", "Enlace copiado") 115 : texto("shareCopyError", "No se ha podido copiar"); 116 boton.classList.add("copiado"); 117 setTimeout(function () { 118 span.textContent = antes; 119 boton.classList.remove("copiado"); 120 }, 2200); 121 } 122 123 if (navigator.clipboard && window.isSecureContext) { 124 navigator.clipboard.writeText(url).then(function () { avisar(true); }, function () { avisar(false); }); 125 return; 126 } 127 try { 128 var t = document.createElement("textarea"); 129 t.value = url; 130 t.style.cssText = "position:fixed;opacity:0"; 131 document.body.appendChild(t); 132 t.select(); 133 var bien = document.execCommand("copy"); 134 t.remove(); 135 avisar(bien); 136 } catch (e) { avisar(false); } 137 } 138 139 document.addEventListener("click", function (e) { 140 var boton = e.target.closest && e.target.closest("[data-accion]"); 141 if (!boton) return; 142 if (boton.dataset.accion === "copiar") { e.preventDefault(); copiar(boton); } 143 if (boton.dataset.accion === "instalar") { 144 e.preventDefault(); 145 if (!aviso) return; 146 aviso.prompt(); 147 aviso.userChoice.then(function () { aviso = null; pintar(); }, 148 function () { aviso = null; pintar(); }); 149 } 150 if (boton.dataset.accion === "nativo") { 151 e.preventDefault(); 152 var d = estaPagina(); 153 navigator.share({ title: d.titulo, text: texto("shareMessage", d.titulo), url: d.url }) 154 .catch(function () { /* el usuario ha cancelado */ }); 155 } 156 }); 157 158 if (document.readyState === "loading") { 159 document.addEventListener("DOMContentLoaded", pintar); 160 } else { 161 pintar(); 162 } 163 164 /* El sitio ya avisa cuando se cambia de idioma: los textos de los 165 botones los rehace i18n.js solo, pero las direcciones llevan el 166 mensaje dentro, asà que hay que volver a montarlas. */ 167 document.addEventListener("langchange", pintar); 168 window.pintarCompartir = pintar; 169})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.