MediaWiki:Gadget-nav-requisiti.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
aggiungo versione 2 che conta anche gli edit cancellati, vedi discussione
aggiorno v2 a requisiti di voto arbcom, vedi discussione
 
(3 versioni intermedie di 2 utenti non mostrate)
Riga 58:
}
 
function getUserContribs2verifyVotingEligibility( user, endDateObjectdate, contribsHandlerresultHandler ) {
$.get( `https://itwikiapi.toolforge.org/v1/users/${ user }/voting-eligibility/${ date }` )
var contribs = {};
} ) .then( function ( data3data ) {
var thirtyDays = 30 * 24 * 60 * 60 * 1000, sixtyDays = 60 * 24 * 60 * 60 * 1000;
resultHandler( data );
var basePath = 'https://xtools.wmcloud.org/api/user/simple_editcount/it.wikipedia/' + user + '/all//';
$.when( } );
$.get( basePath + endDateObject.toISOString().slice( 0, 10 ) ),
$.get( basePath + new Date( endDateObject.getTime() - sixtyDays ).toISOString().slice( 0, 10 ) )
).then( function ( data1, data2 ) {
contribs.d1 = data1[0].live_edit_count + data1[0].deleted_edit_count;
contribs.d2 = data2[0].live_edit_count + data2[0].deleted_edit_count;
if ( contribs.d2 > 0 ) {
return $.Deferred().resolve();
} else {
return $.get(
basePath + new Date( endDateObject.getTime() - thirtyDays ).toISOString().slice( 0, 10 )
);
}
} ).then( function ( data3 ) {
if ( data3 ) {
contribs.d3 = data3.live_edit_count + data3.deleted_edit_count;
}
contribsHandler( contribs );
} );
}
 
Line 122 ⟶ 104:
}
 
function formatResult2( registration, contribsresult ) {
const registrationTS = result.requirements.registration.timestamp,
oldActivity = result.requirements.oldactivity,
recentActivity = result.requirements.recentactivity;
 
var info = '';
info += '<p><b>Registrazione</b>: ' + (registration registrationTS ? parseTimestamp( registrationregistrationTS ) : 'pre 2006' ) + '<br/p>';
info += '<p><b>Attività minima complessiva</b><br>' + oldActivity.editcount + ' modifiche valide tra ';
info += 'Almeno una modifica 30 giorni prima: ' + ( contribs.d2 > 0 || contribs.d3 > 0 ? '✓' : '✗' ) + '<br/>';
info += 'AlmenoparseTimestamp( unaoldActivity.interval.starttimestamp modifica) 60+ giorni' prima:e ' + parseTimestamp( contribsoldActivity.d2 > 0 ? '✓' : '✗'interval.endtimestamp ) + '<br/p>';
info += '50esima<p><b>Attività modifica:minima recente</b><br>' + ( contribsrecentActivity.d1editcount >=+ 50 ? '✓' :modifiche '✗'valide )tra + '<br/>';
info += parseTimestamp( recentActivity.interval.starttimestamp ) + ' e ' + parseTimestamp( recentActivity.interval.endtimestamp ) + '</p>';
info += '500esima modifica: ' + ( contribs.d1 >= 500 ? '✓' : '✗' );
info += '<p><b>Diritto di voto</b>: ' + ( result.eligible ? 'sì' : 'no' ) + '</p>';
return info;
}
Line 156 ⟶ 143:
var user = $.trim( searchDialog2.textInput.getValue() );
var date = $.trim( searchDialog2.dateInput.getValue() );
var dateObject = new Date( date );
if ( !user ) {
searchDialog2.resultLabel.setLabel( $( '<p>Il nome utente &egrave; obbligatorio.</p>' ) );
} else if ( !date || !/^\d{4}\-\d\d\-\d\d$/.test( date ) || isNaN( dateObject ) ) {
searchDialog2.resultLabel.setLabel( $( '<p>Inserire una data valida.</p>' ) );
} else {
searchDialog2.resultLabel.setLabel( 'Ricerca in corso...' );
getUserInfoverifyVotingEligibility( user, date, function ( userInforesult ) {
if ( userInforesult.useridrequirements.registration.requirementsatisfied ) {
searchDialog2.resultLabel.setLabel( $( '<p>' + formatResult2( userInfo.registration, contribsresult ) + '</p>' ) );
getUserContribs2( user, dateObject, function ( contribs ) {
searchDialog2.resultLabel.setLabel( $( '<p>' + formatResult2( userInfo.registration, contribs ) + '</p>' ) );
} );
} else {
searchDialog2.resultLabel.setLabel( $( '<p>L\'utente ' + user + ' non &egrave; registrato.</p>' ) );
Line 228 ⟶ 212:
 
function buildSearchDialog2() {
var style = '.grv-container { height: 100px164px; margin: .4em 0 .6em }' +
'.grv-container-button { width: 100%; text-align: center }';
mw.util.addCSS( style );
Line 242 ⟶ 226:
label: ' '
} );
var textInput = new mw.widgets.UserInputWidget(); {
required: true
} else {);
textInput.on( 'enter', searchHandler );
var textInputLayout = new OO.ui.FieldLayout( textInput, {
Line 248 ⟶ 234:
align: 'top'
} );
var $dateOverlay = $( '<div>' ).appendTo( this.$element );
var dateInput = new OOmw.uiwidgets.TextInputWidgetDateInputWidget( {
label: 'Formato YYYY-MM-DD'
required: true,
$overlay: $dateOverlay
} );
var dateInputLayout = new OO.ui.FieldLayout( dateInput, {
label: 'Data inizio votazioneprocedura:',
align: 'top'
} );
Line 287 ⟶ 275:
var windowManager2;
var portletLink = mw.util.addPortletLink( 'p-navigation', '#', 'Verifica requisiti di voto' );
var portletLink2 = mw.util.addPortletLink( 'p-navigation', '#', 'Verifica requisiti di voto v2arbcom' );
$( portletLink ).click( function ( event ) {
event.preventDefault();
Line 308 ⟶ 296:
event.preventDefault();
mw.loader.using( [ 'mediawiki.api', 'oojs-ui-core', 'oojs-ui-widgets',
'oojs-ui-windows', 'mediawiki.widgets.UserInputWidget' ] ),
'mediawiki.widgets.DateInputWidget' ] )
.done( function () {
if ( !searchDialog2 ) {