|
|
(No se muestran 6 ediciones intermedias del mismo usuario) |
Línea 1: |
Línea 1: |
| mw.loader.using('mediawiki.util', function () {
| |
| document.addEventListener('DOMContentLoaded', function () {
| |
| const button = document.getElementById('crear-noticia-boton');
| |
| if (!button) return;
| |
|
| |
|
| button.addEventListener('click', function () {
| |
| const titleInput = document.getElementById('crear-noticia-titulo');
| |
| const dateInput = document.getElementById('crear-noticia-fecha');
| |
|
| |
| const rawTitle = titleInput?.value.trim();
| |
| const date = dateInput?.value || new Date().toISOString().slice(0, 10);
| |
|
| |
| if (!rawTitle) {
| |
| alert('Por favor escribe un título para la noticia.');
| |
| return;
| |
| }
| |
|
| |
| const cleanTitle = rawTitle.replace(/ /g, '_').replace(/[^\wáéíóúÁÉÍÓÚñÑ0-9_-]/g, '');
| |
| const pageName = 'Noticia:' + cleanTitle;
| |
|
| |
| const preloadContent = encodeURIComponent(
| |
| `{{NoticiaMeta|fecha=${date}}}\n\n== ${rawTitle} ==\n\nEscribe aquí el contenido de la noticia.`
| |
| );
| |
|
| |
| const url = mw.util.getUrl(pageName, {
| |
| action: 'edit',
| |
| preloadtext: preloadContent,
| |
| veaction: 'edit'
| |
| });
| |
|
| |
| window.location.href = url;
| |
| });
| |
| });
| |
| });
| |