Diferencia entre revisiones de «MediaWiki:Common.js»
De FSF
Sin resumen de edición |
Sin resumen de edición |
||
| Línea 9: | Línea 9: | ||
function injectViews() { | function injectViews() { | ||
let | let footer = document.querySelector("#footer-info"); | ||
let | let panel = document.getElementById("fsf-views"); | ||
if (footer && panel) { | |||
let text = footer.innerText; | |||
// Buscar número de visitas | |||
let match = text.match(/(\d+)\s+visitas/); | |||
if (match) { | if (match) { | ||
panel.innerHTML = "👁️ " + match[1] + " visitas"; | |||
} else { | } else { | ||
panel.innerHTML = "👁️ —"; | |||
} | } | ||
} else { | } else { | ||
setTimeout(injectViews, 500); | setTimeout(injectViews, 500); | ||
} | } | ||
Revisión del 04:52 25 mar 2026
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
/* 20260224 - Anexo para agregar encabezado arriba del SUMARIO del toc. Plantilla:FSF Panel Diario */
/* 20260226 - FSF Panel Diario ultra ligero sin API */
/* --------------------------------------------------------------- */
/* -- Para poder ver la cantidad de vistas de la pagina segun el footer de WikiFSF - 2260325 */
document.addEventListener("DOMContentLoaded", function () {
function injectViews() {
let footer = document.querySelector("#footer-info");
let panel = document.getElementById("fsf-views");
if (footer && panel) {
let text = footer.innerText;
// Buscar número de visitas
let match = text.match(/(\d+)\s+visitas/);
if (match) {
panel.innerHTML = "👁️ " + match[1] + " visitas";
} else {
panel.innerHTML = "👁️ —";
}
} else {
setTimeout(injectViews, 500);
}
}
injectViews();
});
/* --
document.addEventListener("DOMContentLoaded", function () {
// Buscar el texto de vistas en el footer
let footerViews = document.querySelector("#footer-info-views");
// Buscar el contenedor en el FSF Panel
let panelViews = document.getElementById("fsf-views");
if (footerViews && panelViews) {
panelViews.innerHTML = footerViews.innerText;
}
});
--}}
/* -- Ciertas ligas externas no cierran la ventana local o actual; si se usa la Plantilla:Ext la URL se abre en un pestaña nueva. --*/
mw.loader.using('mediawiki.util').then(function () {
$(function () {
$('a.external').each(function () {
if (!this.href.includes(location.hostname)) {
$(this)
.attr('target', '_blank')
.attr('rel', 'noopener noreferrer');
}
});
});
});
/* --
document.addEventListener("DOMContentLoaded", function () {
document.querySelectorAll("a.external").forEach(function(link) {
link.setAttribute("target", "_blank");
link.setAttribute("rel", "noopener noreferrer");
});
}); --*/
/* --------------------------------------------------------------- */
/*
mw.loader.using('mediawiki.util').then(function () {
$(function () {
// Solo si existe TOC
if (!$('#toc').length) return;
var pageId = mw.config.get('wgArticleId');
var namespace = mw.config.get('wgNamespaceNumber');
var isSpecial = mw.config.get('wgCanonicalSpecialPageName');
// Evitar páginas especiales o sin ID real
if (!pageId || pageId <= 0 || isSpecial) return;
var panelHTML =
'<div class="fsf-panel-container" ' +
'style="margin-bottom:8px; padding:6px 10px; background:#f8f9fa; border:1px solid #ddd; font-size:90%;">' +
'<strong>FSF Diario</strong> · ID: ' + pageId +
'</div>';
$('#toc').prepend(panelHTML);
});
});
*/