Menú alternativo
Menú alternativo personal
No has accedido
Tu dirección IP será visible si haces alguna edición

Diferencia entre revisiones de «MediaWiki:Common.js»

Página de la interfaz de MediaWiki
Sin resumen de edición
Sin resumen de edición
Línea 6: Línea 6:
}
}
} );
} );
const ELECTION_2024_PAGE_ID = 1792;
const ELECTION_2024_STATEMENTS_PAGE_ID = 1794;
const ELECTION_2024_RESULTS_PAGE_ID = 1794;


const ELECTION_2024_PAGE_IDS = [
const ELECTION_2024_PAGE_IDS = [
1792,
ELECTION_2024_PAGE_ID,
1794,
ELECTION_2024_STATEMENTS_PAGE_ID,
1795
ELECTION_2024_RESULTS_PAGE_ID
];
];


Línea 20: Línea 24:
'border-bottom': '3px solid #833ab4'
'border-bottom': '3px solid #833ab4'
} );
} );
}
if (
mw.config.get( 'wgArticleId' ) === ELECTION_2024_STATEMENTS_PAGE_ID &&
mw.config.get( 'wgUserName' ) !== null
) {
mw.loader.using( [
'oojs-ui',
'mediawiki.api',
'mediawiki.widgets.DateInputWidget'
] ).then( () => {
const realNameInput = new OO.ui.TextInputWidget( {
placeholder: 'Tu nombre real (opcional)'
} );
const spokenLanguagesInput = new OO.ui.TextInputWidget( {
placeholder: 'es-n, en-2, ...',
required: true,
indicator: 'required'
} );
const signupDateInput = new mw.widgets.DateInputWidget( {
required: true,
indicator: 'required'
} );
const projectsInput = new OO.ui.TextInputWidget( {
placeholder: 'eswiki, eswikivoyage, ...',
required: true,
indicator: 'required'
} );
const statementInput = new OO.ui.MultilineTextInputWidget( {
placeholder: 'Por qué quieres ser miembro de la comisión administrativa...',
required: true,
indicator: 'required',
rows: 5
} );
const submitButton = new OO.ui.ButtonInputWidget( {
label: 'Publicar',
type: 'submit',
flags: [
'primary',
'progressive'
]
} );
const fieldset = new OO.ui.FieldsetLayout( {
label: 'Ingresa los datos de tu candidatura',
classes: [ 'container' ]
} );
fieldset.addItems( [
new OO.ui.FieldLayout( realNameInput, {
label: 'Nombre real'
} ),
new OO.ui.FieldLayout( spokenLanguagesInput, {
label: 'Idiomas hablados'
} ),
new OO.ui.FieldLayout( signupDateInput, {
label: 'Fecha de ingreso'
} ),
new OO.ui.FieldLayout( projectsInput, {
label: 'Proyectos'
} ),
new OO.ui.FieldLayout( statementInput, {
label: 'Presentación'
} ),
new OO.ui.FieldLayout( submitButton )
] );
const form = new OO.ui.FormLayout( {
items: [ fieldset ],
id: 'create-new-statement'
} );
form.on( 'submit', ( event ) => {
const username = mw.config.get( 'wgUserName' );
const realName = realNameInput.getValue();
const spokenLanguages = spokenLanguagesInput.getValue();
const signupDate = signupDateInput.getValue();
const projects = projectsInput.getValue();
const statement = statementInput.getValue();
const template = `
{{election/statement
|username = ${username}
|real-name = ${realName}
|languages = ${spokenLanguages}
|signup-date = ${signupDate}
|projects = ${projects}
|statement = ${statement}
}}`
.replace( /\s{2,}/g, '\n');
const parameters = {
action: 'edit',
title: 'Internal:Elecciones/CA/2024/Candidaturas/lista',
appendtext: template,
format: 'json'
};
const api = new mw.Api();
api.postWithToken( 'csrf', parameters ).done( () => {
mw.notify( 'Candidatura agregada con éxito. Recargando...' );
setTimeout( () => {
window.location.reload();
}, 3000 );
} );
} );
$( '#form-anchor' ).append( form.$element );
} );
}
}

Revisión del 02:34 18 oct 2024

// ocultar mw-pt-translate-header para los anónimos

mw.loader.using( [ 'mediawiki.user' ], function () {
	if ( mw.user.isAnon() === 1 ) {
		mw.util.addCSS( '.mw-pt-translate-header { display: none; }' );
	}
} );

const ELECTION_2024_PAGE_ID = 1792;
const ELECTION_2024_STATEMENTS_PAGE_ID = 1794;
const ELECTION_2024_RESULTS_PAGE_ID = 1794;

const ELECTION_2024_PAGE_IDS = [
	ELECTION_2024_PAGE_ID,
	ELECTION_2024_STATEMENTS_PAGE_ID,
	ELECTION_2024_RESULTS_PAGE_ID
];

if ( ELECTION_2024_PAGE_IDS.includes( mw.config.get( 'wgArticleId' ) ) ) {
	$( '.navbar li:has(a.selflink)' )
		.css( {
	  		'border-radius': '5px 5px 0 0',
			'border-bottom-left-radius': '0px',
			'border-bottom': '3px solid #833ab4'
		} );
}

if (
	mw.config.get( 'wgArticleId' ) === ELECTION_2024_STATEMENTS_PAGE_ID &&
	mw.config.get( 'wgUserName' ) !== null
) {
	mw.loader.using( [
		'oojs-ui',
		'mediawiki.api',
		'mediawiki.widgets.DateInputWidget'
	] ).then( () => {
		const realNameInput = new OO.ui.TextInputWidget( {
			placeholder: 'Tu nombre real (opcional)'
		} );
		const spokenLanguagesInput = new OO.ui.TextInputWidget( {
			placeholder: 'es-n, en-2, ...',
			required: true,
			indicator: 'required'
		} );
		const signupDateInput = new mw.widgets.DateInputWidget( {
			required: true,
			indicator: 'required'
		} );
		const projectsInput = new OO.ui.TextInputWidget( {
			placeholder: 'eswiki, eswikivoyage, ...',
			required: true,
			indicator: 'required'
		} );
		const statementInput = new OO.ui.MultilineTextInputWidget( {
			placeholder: 'Por qué quieres ser miembro de la comisión administrativa...',
			required: true,
			indicator: 'required',
			rows: 5
		} );
	
		const submitButton = new OO.ui.ButtonInputWidget( { 
			label: 'Publicar',
			type: 'submit',
			flags: [
				'primary',
				'progressive'
			]
		} );
		 
		const fieldset = new OO.ui.FieldsetLayout( { 
			label: 'Ingresa los datos de tu candidatura',
			classes: [ 'container' ]
		} );
		 
		fieldset.addItems( [ 
			new OO.ui.FieldLayout( realNameInput, {
				label: 'Nombre real'
			} ),
			new OO.ui.FieldLayout( spokenLanguagesInput, { 
				label: 'Idiomas hablados'
			} ),
			new OO.ui.FieldLayout( signupDateInput, { 
				label: 'Fecha de ingreso'
			} ),
			new OO.ui.FieldLayout( projectsInput, { 
				label: 'Proyectos'
			} ),
			new OO.ui.FieldLayout( statementInput, { 
				label: 'Presentación'
			} ),
			new OO.ui.FieldLayout( submitButton )	 
		] );
		 
		const form = new OO.ui.FormLayout(	{
			items: [ fieldset ],
			id: 'create-new-statement'
		} );
	
		form.on( 'submit', ( event ) => {
			const username = mw.config.get( 'wgUserName' );
			const realName = realNameInput.getValue();
			const spokenLanguages = spokenLanguagesInput.getValue();
			const signupDate = signupDateInput.getValue();
			const projects = projectsInput.getValue();
			const statement = statementInput.getValue();
	
			const template = `
				{{election/statement
				 |username = ${username}
				 |real-name = ${realName}
				 |languages = ${spokenLanguages}
				 |signup-date = ${signupDate}
				 |projects = ${projects}
				 |statement = ${statement}
				}}`
				.replace( /\s{2,}/g, '\n');
	
			const parameters = {
				action: 'edit',
				title: 'Internal:Elecciones/CA/2024/Candidaturas/lista',
				appendtext: template,
				format: 'json'
			};
			const api = new mw.Api();
	
			api.postWithToken( 'csrf', parameters ).done( () => {
				mw.notify( 'Candidatura agregada con éxito. Recargando...' );
	
				setTimeout( () => {
					window.location.reload();
				}, 3000 );
			} );
		} );
	
		$( '#form-anchor' ).append( form.$element );
	} );
}