MediaWiki:Gadget-nav-requisiti.js: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
utilizzo di OOjs UI e mw.Api |
m uniformato stile commenti, variabili globali |
||
Riga 9:
* @author https://it.wikipedia.org/wiki/Utente:Rotpunkt
*/
/* global mediaWiki, jQuery, OO */
( function ( mw, $ ) {
'use strict';
// la finestra di dialogo per la ricerca delle informazioni utente
var searchDialog;
/**
* Ricerca la data di registrazione di un utente.
*
* @param {string} user - il nome dell'utente.▼
* @param {string} user - Il nome dell'utente
* @param {function} registrationHandler - */
function getRegistration( user, registrationHandler ) {
Line 35 ⟶ 37:
/**
* Ricerca i 500 contributi utente successivi alla data "start".
*
* @param {string} user - il nome dell'utente.▼
* @param {string}
* @param {string} start - La data di inizio
* @param {function} contribsHandler - */
function getUserContribs( user, start, contribsHandler ) {
Line 56 ⟶ 59:
/**
* Parsifica un timestamp in date (1 gen 2001) e time (01:23).
*
* @return {string} La data nel formato '1 gen 2001 alle 01:23'
*/
function parseTimestamp( timestamp ) {
Line 77 ⟶ 82:
/**
* Formatta le informazioni su data di registrazione, primo, 50esimo e 500esimo edit di un utente.
*
* @param {string}
* @return {string} Le informazioni formattate
*/
function formatResult( registration, contribs ) {
Line 93 ⟶ 100:
*/
function searchHandler() {
var user = $.trim( searchDialog.textInput.getValue() );
if ( !user ) {
searchDialog.resultLabel.setLabel( $( '<p>Il nome utente è obbligatorio.</p>' ) );
} else {
searchDialog.resultLabel.setLabel( 'Ricerca in corso...' );
getRegistration( user, function ( registration ) {
if ( registration ) {
getUserContribs( user, registration, function ( contribs ) {
searchDialog.resultLabel.setLabel( $( '<p>' + formatResult( registration, contribs ) + '</p>' ) );
} );
} else {
searchDialog.resultLabel.setLabel( $( '<p>L\'utente ' + user + ' non è registrato.</p>' ) );
}
} );
Line 112 ⟶ 119:
/**
* Crea la finestra di dialogo per la ricerca delle informazioni utente.
*
* @return {Object} L'oggetto derivato da OO.ui.Dialog che rappresenta la finestra
*/
function buildSearchDialog() {
Line 124 ⟶ 133:
SearchDialog.prototype.initialize = function () {
SearchDialog.parent.prototype.initialize.call( this );
var resultLabel = new OO.ui.LabelWidget( {
classes: [ 'grv-container' ],
label: ' '
} );
var textInput = new mw.widgets.UserInputWidget();
textInput.on( 'enter', searchHandler );
var textInputLayout = new OO.ui.FieldLayout( textInput, {
Line 146 ⟶ 155:
classes: [ 'grv-container-button' ]
} );
this.textInput = textInput;
this.resultLabel = resultLabel;
this.panelLayout = new OO.ui.PanelLayout( { padded: true, expanded: false } );
this.panelLayout.$element.append( textInputLayout.$element, resultLabel.$element, buttons.$element );
Line 159 ⟶ 170:
$( function () {
var windowManager;
var portletLink = mw.util.addPortletLink( 'p-navigation', '#', 'Verifica requisiti di voto' );
$( portletLink ).click( function ( event ) {
|