Diferencia entre revisiones de «MediaWiki:Common.js»
De FSF
Sin resumen de edición |
Sin resumen de edición Etiqueta: Reversión manual |
||
| (No se muestran 22 ediciones intermedias del mismo usuario) | |||
| Línea 1: | Línea 1: | ||
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */ | /* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */ | ||
/* MediaWiki:Common.js */ | |||
/* 20260224 - Anexo para agregar encabezado arriba del SUMARIO del toc. Plantilla:FSF Panel Diario */ | /* 20260224 - Anexo para agregar encabezado arriba del SUMARIO del toc. Plantilla:FSF Panel Diario */ | ||
/* 20260226 - FSF Panel Diario ultra ligero sin API */ | /* 20260226 - FSF Panel Diario ultra ligero sin API */ | ||
| Línea 5: | Línea 6: | ||
/* -- 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); | |||
}); | }); | ||
--/ | |||
/* -- | /* -- | ||
| Línea 108: | Línea 128: | ||
}); | }); | ||
*/ | */ | ||
/* 20260427 - Boton de donativos. */ | |||
mw.loader.using(['mediawiki.util']).then(function () { | |||
function addDonateButton() { | |||
// ESTE selector sí existe en tu header (ya lo vi en tu captura) | |||
var header = document.querySelector('#mw-header'); | |||
if (!header) { | |||
console.log("No se encontró #mw-header"); | |||
return; | |||
} | |||
// evitar duplicados | |||
if (document.getElementById('fsf-donate-btn')) return; | |||
var btn = document.createElement('a'); | |||
btn.id = 'fsf-donate-btn'; | |||
btn.href = 'https://familiasuperfeliz.com/index.php/Donativos'; | |||
btn.textContent = '💙 Donar'; | |||
btn.title = 'Apoya este proyecto'; | |||
header.appendChild(btn); | |||
console.log("Botón agregado en header"); | |||
} | |||
window.addEventListener('load', function () { | |||
setTimeout(addDonateButton, 300); | |||
}); | |||
}); | |||
/* 20260427 - BOTON PULL DOWN MENU. */ | |||
mw.loader.using(['mediawiki.util']).then(function () { | |||
mw.hook('wikipage.content').add(function () { | |||
if (document.getElementById('fsf-menu')) return; | |||
var header = document.querySelector('#mw-header'); | |||
if (!header) return; | |||
// Contenedor | |||
var container = document.createElement('div'); | |||
container.id = 'fsf-menu'; | |||
// Botón principal | |||
var button = document.createElement('button'); | |||
button.id = 'fsf-menu-btn'; | |||
button.textContent = '⚙ Opciones'; | |||
// Dropdown | |||
var dropdown = document.createElement('div'); | |||
dropdown.id = 'fsf-dropdown'; | |||
dropdown.innerHTML = ` | |||
<a href="/index.php/Donativos">💙 Donar</a> | |||
<a href="/index.php/Inicio">🏠 Inicio</a> | |||
<a href="/index.php/Especial:Preferencias">⚙ Preferencias</a> | |||
<a href="#" id="fsf-toggle-sidebar">🧭 Sidebar: ON</a> | |||
`; | |||
container.appendChild(button); | |||
container.appendChild(dropdown); | |||
header.appendChild(container); | |||
// Toggle | |||
button.addEventListener('click', function (e) { | |||
e.stopPropagation(); | |||
dropdown.classList.toggle('show'); | |||
}); | |||
// Cerrar al hacer clic fuera | |||
document.addEventListener('click', function () { | |||
dropdown.classList.remove('show'); | |||
}); | |||
}); | |||
}); | |||
/* ============================================================ | |||
WikiFSF — CONTROLES DE PANELES LATERALES | |||
2026-09-06 | |||
Sidebar izquierdo y panel derecho independientes. | |||
Estado persistente mediante localStorage. | |||
============================================================ */ | |||
/* ============================================================ | |||
WikiFSF — Botón mostrar / ocultar Sidebar | |||
============================================================ */ | |||
mw.hook('wikipage.content').add(function () { | |||
var boton = document.getElementById('fsf-toggle-sidebar'); | |||
if (!boton) return; | |||
if (boton.dataset.fsfSidebarReady === '1') return; | |||
boton.dataset.fsfSidebarReady = '1'; | |||
boton.addEventListener('click', function (e) { | |||
e.preventDefault(); | |||
e.stopPropagation(); | |||
var oculto = document.body.classList.toggle( | |||
'fsf-sidebar-oculto' | |||
); | |||
boton.textContent = oculto | |||
? '🧭 Sidebar: OFF' | |||
: '🧭 Sidebar: ON'; | |||
}); | |||
}); | |||
/* PRUEBA TEMPORAL — Sidebar */ | |||
/* | |||
$(function () { | |||
document.body.classList.add('fsf-test-sidebar-oculto'); | |||
}); */ | |||
/* ============================================================ */ | |||
/* ============================================================ */ | |||
/* alert('WikiFSF TEST'); */ | |||
Revisión actual - 19:41 6 sep 2026
/* Cualquier código JavaScript escrito aquí se cargará para todos los usuarios en cada carga de página */
/* MediaWiki:Common.js */
/* 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);
});
});
*/
/* 20260427 - Boton de donativos. */
mw.loader.using(['mediawiki.util']).then(function () {
function addDonateButton() {
// ESTE selector sí existe en tu header (ya lo vi en tu captura)
var header = document.querySelector('#mw-header');
if (!header) {
console.log("No se encontró #mw-header");
return;
}
// evitar duplicados
if (document.getElementById('fsf-donate-btn')) return;
var btn = document.createElement('a');
btn.id = 'fsf-donate-btn';
btn.href = 'https://familiasuperfeliz.com/index.php/Donativos';
btn.textContent = '💙 Donar';
btn.title = 'Apoya este proyecto';
header.appendChild(btn);
console.log("Botón agregado en header");
}
window.addEventListener('load', function () {
setTimeout(addDonateButton, 300);
});
});
/* 20260427 - BOTON PULL DOWN MENU. */
mw.loader.using(['mediawiki.util']).then(function () {
mw.hook('wikipage.content').add(function () {
if (document.getElementById('fsf-menu')) return;
var header = document.querySelector('#mw-header');
if (!header) return;
// Contenedor
var container = document.createElement('div');
container.id = 'fsf-menu';
// Botón principal
var button = document.createElement('button');
button.id = 'fsf-menu-btn';
button.textContent = '⚙ Opciones';
// Dropdown
var dropdown = document.createElement('div');
dropdown.id = 'fsf-dropdown';
dropdown.innerHTML = `
<a href="/index.php/Donativos">💙 Donar</a>
<a href="/index.php/Inicio">🏠 Inicio</a>
<a href="/index.php/Especial:Preferencias">⚙ Preferencias</a>
<a href="#" id="fsf-toggle-sidebar">🧭 Sidebar: ON</a>
`;
container.appendChild(button);
container.appendChild(dropdown);
header.appendChild(container);
// Toggle
button.addEventListener('click', function (e) {
e.stopPropagation();
dropdown.classList.toggle('show');
});
// Cerrar al hacer clic fuera
document.addEventListener('click', function () {
dropdown.classList.remove('show');
});
});
});
/* ============================================================
WikiFSF — CONTROLES DE PANELES LATERALES
2026-09-06
Sidebar izquierdo y panel derecho independientes.
Estado persistente mediante localStorage.
============================================================ */
/* ============================================================
WikiFSF — Botón mostrar / ocultar Sidebar
============================================================ */
mw.hook('wikipage.content').add(function () {
var boton = document.getElementById('fsf-toggle-sidebar');
if (!boton) return;
if (boton.dataset.fsfSidebarReady === '1') return;
boton.dataset.fsfSidebarReady = '1';
boton.addEventListener('click', function (e) {
e.preventDefault();
e.stopPropagation();
var oculto = document.body.classList.toggle(
'fsf-sidebar-oculto'
);
boton.textContent = oculto
? '🧭 Sidebar: OFF'
: '🧭 Sidebar: ON';
});
});
/* PRUEBA TEMPORAL — Sidebar */
/*
$(function () {
document.body.classList.add('fsf-test-sidebar-oculto');
}); */
/* ============================================================ */
/* ============================================================ */
/* alert('WikiFSF TEST'); */