Usuario:Jorge 2701/Tags.js

De Wikipedia, la enciclopedia libre

Nota: Después de guardar, debes refrescar la caché de tu navegador para ver los cambios. Internet Explorer: mantén presionada Ctrl mientras pulsas Actualizar. Firefox: mientras presionas Mayús pulsas el botón Actualizar, (o presiona Ctrl-Shift-R). Los usuarios de Google Chrome y Safari pueden simplemente pulsar el botón Recargar. Para más detalles e instrucciones acerca de otros exploradores, véase Ayuda:Cómo limpiar la caché.

// If TwinkleConfig aint exist.
if( typeof( TwinkleConfig ) == 'undefined' ) {
	TwinkleConfig = {};
}
 
/**
 TwinkleConfig.summaryAd (string)en.wikipedia.org
 If ad should be added or not to summary, default [[WP:TWINKLE|TWINKLE]]
 */
if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) {
	TwinkleConfig.summaryAd = " usando [[w:es:WP:TW|TW]]";
}
 
/**
 TwinkleConfig.deletionSummaryAd (string)
 If ad should be added or not to deletion summary, default [[WP:TWINKLE|TWINKLE]]
 */
if( typeof( TwinkleConfig.deletionSummaryAd ) == 'undefined' ) {
	TwinkleConfig.deletionSummaryAd = " usando [[w:es:WP:TW|TW]]";
}
 
 
/**
 TwinkleConfig.watchSpeedyPages (array)
 What types of actions that should result in forced addition to watchlist
 */
if( typeof( TwinkleConfig.watchSpeedyPages ) == 'undefined' ) {
	TwinkleConfig.watchSpeedyPages = [ ];
}
 
/**
 TwinkleConfig.markSpeedyPagesAsMinor (boolean)
 If, when applying speedy template to page, to mark the edit as minor, default true
 */
if( typeof( TwinkleConfig.markSpeedyPagesAsMinor ) == 'undefined' ) {
	TwinkleConfig.markSpeedyPagesAsMinor = true;
}
 
/**
 TwinkleConfig.notifyUserOnSpeedyDeletionNomination (array)
 What types of actions that should result that the author of the page should be notified of nomination
 */
if( typeof( TwinkleConfig.notifyUserOnSpeedyDeletionNomination ) == 'undefined' ) {
	TwinkleConfig.notifyUserOnSpeedyDeletionNomination = [ 'a', 'b', 'c', 'd', 'e', 'f', 'f', 'h', 'i',];
}
 
/**
 TwinkleConfig.userTalkPageMode may take arguments:
 'window': open a new window, remember the opened window
 'tab': opens in a new tab, if possible.
 'blank': force open in a new window, even if a such window exist
 */
if( typeof( TwinkleConfig.userTalkPageMode ) == 'undefined' ) {
	TwinkleConfig.userTalkPageMode = 'window';
}
 
/**
 TwinkleConfig.toolboxButtons (string)
 If id defined in this array, the button of the action is located inthe toolbox instead of in
 the actions bar.
 */
if( typeof( TwinkleConfig.toolboxButtons ) == 'undefined' ) {
	TwinkleConfig.toolboxButtons = [];
}
 
/**
 TwinkleConfig.orphanNormalPagesOnSpeedyDelete (hash)
 Defines if all backlinks to a page should be removed.
 property 'exclude' defined actions not to orphan
 */
if( typeof( TwinkleConfig.orphanBacklinksOnSpeedyDelete ) == 'undefined' ) {
	TwinkleConfig.orphanBacklinksOnSpeedyDelete = { exclude: ['g6'], orphan:false };
}
 
function twinklespeedy() {
	if( wgNamespaceNumber < 0 || wgCurRevisionId == false ) {
		return;
                         }
		mw.util.addPortletLink( 'p-cactions', "javascript:twinklespeedy.callback()", "Marcar", "tw-Marcar", "Marcar esta página", "");	
}
$(twinklespeedy);
 
twinklespeedy.callback = function twinklespeedyCallback() {
	var Window = new SimpleWindow( 800, 400 );
	Window.setTitle( "Colocar Plantillas" );

	form.append( {
			type: 'checkbox',
			list: [
				{
					label: 'Aviso al autor',
					value: 'notify',
					name: 'notify',
                                        tooltip: 'Notifica al autor del artículo',
					checked: true,
					disabled: userIsInGroup( 'sysop' ),
					event: function( event ) {
						event.stopPropagation();
					}
				}
			]
		}
	);
	form.append( { type:'header', label:'Criticas (Banda roja)' } );
	form.append( {
			type: 'radio',
			name: 'br',
			list: [
                                { 
					label: 'Sin Relevancia Aparente', 
					value: 'Sin relevancia', 
					tooltip: 'Artículos de personas, grupos musicales, páginas web o empresas, entre otros, que no prueban su relevancia enciclopédica.' },
				{ 
					label: 'Promocional',
					value: 'Promocional', 
					tooltip: 'Posible autopromoción o contenido publicitario.'
				},
				{ 
					label: 'Contextualizar',
					value: 'Contextualizar', 
					tooltip: 'Páginas sin contextos claros.'
				},
				{ 
					label: 'Fuente primaria', 
					value: 'Fuente primaria', 
					tooltip: 'Fuente primaria.' 
				},
				{ 
					label: 'Infraesbozo',
					value: 'Infraesbozo',
					tooltip: 'Infraesbozo.' 
				},
				{ 
					label: 'Traducción automática',
					value: 'Autotrad',
					tooltip: 'Traducción automática.' 
				},
				{ 
					label: 'Posible plagio', 
					value: 'Copyvio', 
					tooltip: 'Páginas que pueden ser un plagio de otra página.' 
				},
				{ 
					label: 'Otros', 
					value: 'Otros', 
					tooltip: 'Elige un motivo personalizado que no encaje con los motivos anteriores.' 
				}
			]
		} ); 
if( wgNamespaceNumber ==  0 || wgNamespaceNumber == 1 ) {
	form.append( { type:'header', label:'Amarilla' } );
	form.append( {
			type: 'radio',
			name: 'br',
			list: [
                                {
					label: 'Referencias',
					value: 'Referencias',
					tooltip: 'Artículos sin referencias.'
				},
				{ 
					label: 'A2. Infraesbozo', 
					value: 'A2', 
					tooltip: 'Artículos de apenas una o dos líneas que carezcan de contexto que permita calificarlos como esbozos.' 
				},
				{
					label: 'A3. No traducido',
					value: 'A3',
					tooltip: 'Si el artículo esta en su totalidad en otro idioma que no es español'
				},
                                { 
					label: 'A4. No enciclopédico', 
					value: 'A4', 
					tooltip: 'Artículos de personas, grupos musicales, páginas web o empresas, entre otros, que claramente no cuentan con relevancia enciclopédica.' },
				{ 
					label: 'Otros', 
					value: 'Otros', 
					tooltip: 'Elige un motivo personalizado que no encaje con los motivos anteriores.' 
				}
			]
		} );
}

if( wgNamespaceNumber ==  0) {
	form.append( { type:'header', label: 'Otras razones' } );
	form.append( {
			type: 'radio',
			name: 'br',
			list: [
				{
					label: 'Sin contenido',
					value: 'Vacío',
					tooltip: 'Artículos que no contienen información, vacíos en su totalidad o solo contienen imágenes o plantillas '
				},
				{ 
					label: 'Otra opción', 
					value: 'Otros', 
					tooltip: 'Elige un motivo personalizado que no encaje con los motivos anteriores.' 
				}
			]
		} ); }
	var result = form.render();
	Window.setContent( result );
	Window.display();
}
 
twinklespeedy.normalizeHash = {
	'Sin relevancia': 'a',
        'Promocional': 'b',
        'Fuente Primaria': 'c',
        'Contextualizar': 'd',
        'Infraesbozo': 'e',
        'Autotrad': 'f',
        'Copyvio': 'g',
        'Referencias': 'h',
        'Otros': 'i',
};
 
twinklespeedy.reasonHash = {
	'Sin relevancia': 'SRA',
        'Promocional': 'Promocional',
        'Fuente Primaria': 'Fuente Primaria',
        'Contextualizar': 'Contextualizar',
        'Infraesbozo': 'Infraesbozo',
        'Autotrad': 'Autotrad',
        'Copyvio': 'Copyvio',
        'Referencias': 'Referencias',
        'Otros': 'i',
};
 
twinklespeedy.callbacks = {

	user: {
		main: function( self ) {
			var xmlDoc = self.responseXML;
 
			var exists = xmlDoc.evaluate( 'boolean(//pages/page[not(@missing)])', xmlDoc, null, XPathResult.BOOLEAN_TYPE, null ).booleanValue;
 
			if( ! exists ) {
				self.statelem.error( "It seems that the page doesn't exists, perhaps it has already been deleted" );
				return;
			}
			var query = { 
				'title': wgPageName, 
				'action': 'submit'
			};
 
			var wikipedia_wiki = new Wikipedia.wiki( 'Nominando página', query, twinklespeedy.callbacks.user.tagPage );
			wikipedia_wiki.params = self.params;
			wikipedia_wiki.followRedirect = false;
			wikipedia_wiki.get();
		},
		tagPage: function( self ) {
			form = this.responseXML.getElementById( 'editform' );
			var text = form.wpTextbox1.value;
			var code;
			switch( self.params.normalized ) {
			case 'g':
				var url = prompt( 'Inserta la URL, incluyendo el http://' );
				if( url == null ) {
					return;
				}
				code = "\{\{Copyvio\|1=" + url + "|2=\~\~\~\~|3=\{\{subst:CURRENTDAY\}\}|4=\{\{subst:CURRENTMONTHNAME\}\}\}\}<!--";
				break;
			case 'i':
				var url = prompt( 'Razón para su borrado:' );
				if( url == null ) {
					return;
				}
				code = "\{\{destruir\|" + url + "\}\}";
				break;
			case 'h':
				code = " +  self.params.value + "\}\}";
				break;
			default:
				code = "\{\{" +  self.params.value + "|2=\{\{subst:CURRENTDAY\}\}|3=\{\{subst:CURRENTMONTHNAME\}\}\}\}";
				break;
			}
 
			// Notification to first contributor
			var query = {
				'action': 'query',
				'prop': 'revisions',
				'titles': wgPageName,
				'rvlimit': 1,
				'rvprop': 'user',
				'rvdir': 'newer'
			}
			var callback = function( self ) {
				var xmlDoc = self.responseXML;
				var user = xmlDoc.evaluate( '//rev/@user', xmlDoc, null, XPathResult.STRING_TYPE, null ).stringValue;
				var query = {
					'title': 'Usuario discusión:' + user,
					'action': 'submit'
				};
				var wikipedia_wiki = new Wikipedia.wiki( 'Notificando al usuario (' + user + ')', query, twinklespeedy.callbacks.user.userNotification );
				wikipedia_wiki.params = self.params;
				wikipedia_wiki.get();
			}
 
			if( self.params.usertalk ) {
				var wikipedia_api = new Wikipedia.api( 'Grabbing data of initial contributor', query, callback );
				wikipedia_api.params = self.params;
				wikipedia_api.post();
			}
		            switch( self.params.normalized ){
			            case 'g':
   			            var postData = {
				            'wpMinoredit': TwinkleConfig.markSpeedyPagesAsMinor ? '' : undefined,
				            'wpWatchthis': self.params.watch ? '' : undefined,
				            'wpStarttime': form.wpStarttime.value,
				            'wpEdittime': form.wpEdittime.value,
				            'wpAutoSummary': form.wpAutoSummary.value,
			              'wpEditToken': form.wpEditToken.value,
				            'wpSection': '',
				            'wpSummary': "Marcando página como «[[WP:BR#G6|Posible Plagio]]» " + TwinkleConfig.summaryAd,
                    'wpTextbox1': code + "\n" + text
                    }
                  break;
			            case 'i':
   			           var postData = {
				           'wpMinoredit': TwinkleConfig.markSpeedyPagesAsMinor ? '' : undefined,
				           'wpWatchthis': self.params.watch ? '' : undefined,
				           'wpStarttime': form.wpStarttime.value,
				           'wpEdittime': form.wpEdittime.value,
				           'wpAutoSummary': form.wpAutoSummary.value,
			             'wpEditToken': form.wpEditToken.value,
				           'wpSection': '',
				           'wpSummary': "Marcando página para [[WP:BR|destruir]] " + TwinkleConfig.summaryAd,
                   'wpTextbox1': code + "\n" + text
                   }
			            break;
			            default:
   			           var postData = {
				           'wpMinoredit': TwinkleConfig.markSpeedyPagesAsMinor ? '' : undefined,
				           'wpWatchthis': self.params.watch ? '' : undefined,
				           'wpStarttime': form.wpStarttime.value,
				           'wpEdittime': form.wpEdittime.value,
				           'wpAutoSummary': form.wpAutoSummary.value,
			             'wpEditToken': form.wpEditToken.value,
				           'wpSection': '',
				           'wpSummary': "Marcando página con \{\{" +  self.params.value + "\}\} + TwinkleConfig.summaryAd,
                   'wpTextbox1': code + "\n" + text
                   }
			          }
			self.post( postData );
                },
		userNotification: function( self ) {
			var form = self.responseXML.getElementById( 'editform' );
			var text = form.wpTextbox1.value;
			text += "\n\{\{subst:Usuario:Jorge 2701/Pruebas|1=" + wgPageName + "|2=" + self.params.normalized.toUpperCase() + "\}\}";
			var postData = {
				'wpMinoredit': form.wpMinoredit.checked ? '' : undefined,
				'wpWatchthis': form.wpWatchthis.checked ? '' : undefined,
				'wpStarttime': form.wpStarttime.value,
				'wpEdittime': form.wpEdittime.value,
				'wpAutoSummary': form.wpAutoSummary.value,
				'wpEditToken': form.wpEditToken.value,
				'wpSection': '',
				'wpSummary': 'Notificación de... en «\[\[' + wgPageName + '\]\]». ' + TwinkleConfig.summaryAd,
				'wpTextbox1': text
			};
			self.post( postData );
		}
	}
}
 
twinklespeedy.callback.evaluateSysop = function twinklespeedyCallbackEvaluateSysop(e) {
 
	wgPageName = wgPageName.replace( /_/g, ' ' ); // for queen/king/whatever and country!
 
	var tag_only = e.target.form.tag_only;
	if( tag_only && tag_only.checked ) {
		return twinklespeedy.callback.evaluateUser(e);
	}
 
	var value = e.target.value;
	var normalized = twinklespeedy.normalizeHash[ value ];
 
	var params = {
		value: value,
		normalized: normalized,
		watch: TwinkleConfig.watchSpeedyPages.indexOf( normalized ) != -1,
		reason: twinklespeedy.reasonHash[ value ]
	};
	Status.init( e.target.form );
 
	var query = {
		'action': 'query',
		'titles': wgPageName
	}
	var wikipedia_api = new Wikipedia.api( 'Viendo si la página existe', query, twinklespeedy.callbacks.sysop.main );
	wikipedia_api.params = params;
	wikipedia_api.post();
}
 
 
 
twinklespeedy.callback.evaluateUser = function twinklespeedyCallbackEvaluateUser(e) {
	wgPageName = wgPageName.replace( /_/g, ' ' ); // for queen/king/whatever and country!
	var value = e.target.value;
	var normalized = twinklespeedy.normalizeHash[ value ];
 
	var params = {
		value: value,
		normalized: normalized,
		watch: TwinkleConfig.watchSpeedyPages.indexOf( normalized ) != -1,
		usertalk: TwinkleConfig.notifyUserOnSpeedyDeletionNomination.indexOf( normalized ) != -1 && e.target.form.notify.checked
	};
 
	Status.init( e.target.form );
 
	Wikipedia.actionCompleted.redirect = wgPageName;
	Wikipedia.actionCompleted.notice = "Terminado";
 
	var query = {
		'action': 'query',
		'titles': wgPageName
	}
 
	var wikipedia_api = new Wikipedia.api( 'Viendo si la página existe', query, twinklespeedy.callbacks.user.main );
	wikipedia_api.params = params;
	wikipedia_api.post();
 
}