Diferencia entre revisiones de «MediaWiki:Common.js»
De FSF
Sin resumen de edición |
Sin resumen de edición |
||
| (No se muestran 3 ediciones intermedias del mismo usuario) | |||
| Línea 5: | Línea 5: | ||
/* -- Para poder ver la cantidad de vistas de la pagina segun el footer de WikiFSF - 2260325 */ | /* -- Para poder ver la cantidad de vistas de la pagina segun el footer de WikiFSF - 2260325 */ | ||
mw.hook('wikipage.content').add(function () { | |||
let footer = document.getElementById('footer-info'); | |||
let panel = document.getElementById('fsf-views'); | |||
if (!footer || !panel) return; | |||
let texto = footer.innerText; | |||
let match = texto.match(/(\d+)\s+visitas/); | |||
if (match) { | |||
panel.textContent = " " + match[1] + " "; | |||
} else { | |||
panel.textContent = "—"; | |||
} | |||
}); | |||
/* -- | |||
document.addEventListener("DOMContentLoaded", function () { | document.addEventListener("DOMContentLoaded", function () { | ||
function | function buscarVistas() { | ||
let footer = document.querySelector("#footer-info"); | let footer = document.querySelector("#footer-info"); | ||
let panel = document.getElementById("fsf-views"); | let panel = document.getElementById("fsf-views"); | ||
if (!footer || !panel) return; | if (!footer || !panel) return false; | ||
let texto = footer.innerText; | |||
let match = texto.match(/(\d+)\s+visitas/); | |||
let match = | |||
if (match) { | if (match) { | ||
panel.innerHTML = "👁️ " + match[1] + " visitas"; | panel.innerHTML = "👁️ " + match[1] + " visitas"; | ||
return true; | |||
} | } | ||
return false; | |||
} | } | ||
// | // Intentar varias veces (clave en MediaWiki) | ||
let intentos = 0; | |||
let intervalo = setInterval(function () { | |||
if (buscarVistas() || intentos > 10) { | |||
clearInterval(intervalo); | |||
} | |||
intentos++; | |||
}, 300); | |||
}); | }); | ||
--/ | |||
/* -- | /* -- | ||
Revisión actual - 05:10 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 */
mw.hook('wikipage.content').add(function () {
let footer = document.getElementById('footer-info');
let panel = document.getElementById('fsf-views');
if (!footer || !panel) return;
let texto = footer.innerText;
let match = texto.match(/(\d+)\s+visitas/);
if (match) {
panel.textContent = " " + match[1] + " ";
} else {
panel.textContent = "—";
}
});
/* --
document.addEventListener("DOMContentLoaded", function () {
function buscarVistas() {
let footer = document.querySelector("#footer-info");
let panel = document.getElementById("fsf-views");
if (!footer || !panel) return false;
let texto = footer.innerText;
let match = texto.match(/(\d+)\s+visitas/);
if (match) {
panel.innerHTML = "👁️ " + match[1] + " visitas";
return true;
}
return false;
}
// Intentar varias veces (clave en MediaWiki)
let intentos = 0;
let intervalo = setInterval(function () {
if (buscarVistas() || intentos > 10) {
clearInterval(intervalo);
}
intentos++;
}, 300);
});
--/
/* --
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);
});
});
*/