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é.

// <nowiki>
// If FriendlyConfig aint exist.
if( typeof( FriendlyConfig ) == 'undefined' ) {
	FriendlyConfig = {};
}

/**
 FriendlyConfig.summaryAd ( string )
 If ad should be added or not to summary, default [[WP:TW|Twinkle]]
 */
if( typeof( FriendlyConfig.summaryAd ) == 'undefined' ) {
	FriendlyConfig.summaryAd = " ([[WP:TW|twinkle]])";
}

/**
 FriendlyConfig.groupByDefault ( boolean )
 */
if( typeof( FriendlyConfig.groupByDefault ) == 'undefined' ) {
	FriendlyConfig.groupByDefault = true;
}

/**
 FriendlyConfig.watchTaggedPages ( boolean )
 */
if( typeof( FriendlyConfig.watchTaggedPages ) == 'undefined' ) {
	FriendlyConfig.watchTaggedPages = true;
}

/**
 FriendlyConfig.markTaggedPagesAsMinor ( boolean )
 */
if( typeof( FriendlyConfig.markTaggedPagesAsMinor ) == 'undefined' ) {
	FriendlyConfig.markTaggedPagesAsMinor = true;
}

function friendlytag() {
	if( typeof QueryString !== 'undefined' && typeof QueryString.exists === 'function' && QueryString.exists( 'redirect' ) && QueryString.get( 'redirect' ) == 'no' ) {
		isRedirect = true;
		mw.util.addPortletLink( 'p-cactions', "javascript:friendlytag.callback()", "marcar", "friendly-tag", "Tag redirect", "");
	} else if( mw.config.get('wgNamespaceNumber') != 0 || mw.config.get('wgCurRevisionId') == false ) {
		return;
	} else {
		mw.util.addPortletLink( 'p-cactions', "javascript:friendlytag.callback()", "marcar", "friendly-tag", "Tag article", "");
	}
}

$(friendlytag);

friendlytag.callback = function friendlytagCallback( uid ) {
	var Window = new SimpleWindow( 600, 400 );
	if( !isRedirect ) {
		Window.setTitle( "Marcar artículo" );
	} else {
		Window.setTitle( "Marcar artículo" );
	}
	var form = new QuickForm( friendlytag.callback.evaluate );
	
	if( !isRedirect ) {
		form.append( {
				type: 'checkbox',
				list: [
					{
						label: 'Agrupar en {{problemas artículo}} si es posible',
						value: 'group',
						name: 'group',
						tooltip: 'Si se aplican mas de tres plantillas soportadas por {{Problemas artículo}}, esas plantillas serán agrupadas en una sola.',
						checked: FriendlyConfig.groupByDefault
					}
				]
			}
		);

		form.append( { type:'submit' } );

		form.append( { type:'header', label:'Plantillas de mantenimiento' } );
		form.append( { type:'checkbox', name: 'maintenance', list: friendlytag.maintenanceList } );

		form.append( { type:'header', label:'Plantillas de problemas en el artículo' } );
		form.append( { type:'checkbox', name: 'problem', list: friendlytag.problemList } );

		form.append( { type:'header', label:'Wikificares' } );
		form.append( { type:'checkbox', name: 'wikificar', list: friendlytag.wikificarList } );

		form.append( { type:'header', label:'Plantillas de noticias' } );
		form.append( { type:'checkbox', name: 'notice', list: friendlytag.noticeList } );
	} else {
		form.append( { type:'submit' } );
		

		form.append( { type:'header', label:'Plantillas de mantenimiento' } );
		form.append( { type:'checkbox', name: 'maintenance', list: friendlytag.maintenanceList } );

		form.append( { type:'header', label:'Plantillas de problemas en el artículo' } );
		form.append( { type:'checkbox', name: 'problem', list: friendlytag.problemList } );

		form.append( { type:'header', label:'Wikificares' } );
		form.append( { type:'checkbox', name: 'wikificar', list: friendlytag.wikificarList } );

		form.append( { type:'header', label:'Plantillas de noticias' } );
		form.append( { type:'checkbox', name: 'notice', list: friendlytag.noticeList } );
	}
	
	form.append( { type:'submit' } );

	var result = form.render();
	Window.setContent( result );
	Window.display();
}

isRedirect = false;

friendlytag.maintenanceList = [

	{
		label: '{{No neutralidad}}: Artículos que no respeten el punto de vista neutral',
		value: 'No neutralidad' },
	{
		label: '{{copyedit}}: Artículos que necesitan una revisión de ortografía o estilo',
		value: 'copyedit' },
	{
		label: '{{Referencias}}: Artículos que necesitan referencias',
		value: 'Referencias' },
	{
		label: '{{A Meta}}: Artículos que contienen información de coordinación de proyectos y deberían trasladarse a meta',
		value: 'A Meta' },
	{
		label: '{{A Wikilibros}}: Artículos que son guías o manuales y no tienen valor enciclopédico',
		value: 'A Wikilibros' },

	{
		label: '{{A Wikiquote}}: Artículos que solo son una colección de frases',
		value: 'A Wikiquote' },
	{
		label: '{{A Wikisource}}: Artículos que son textos originales o documentos que están en el dominio público',
		value: 'A Wikisource' },
	{
		label: '{{Al Wikcionario}}: Artículo que es una definición de diccionario',
		value: 'Al Wikcionario' },
	{
		label: '{{Artículo infraesbozo}}: El artículo es demasiado reducido como para ser considerado enciclopédico',
		value: 'Artículo infraesbozo|\{\{subst:CURRENTDAY\}\}|\{\{subst:CURRENTMONTHNAME\}\}' },
	{
		label: '{{Contextualizar}}: Artículos sin contexto',
		value: 'Contextualizar|\{\{subst:CURRENTDAY\}\}|\{\{subst:CURRENTMONTHNAME\}\}' },
	{
		label: '{{Nombre japonés}}: Si el artículo sigue la onomástica japonesa',
		value: 'Nombrejaponés' },
	{
		label: '{{Noticias}}: Artículo que es una noticia y no tiene carácter enciclopédico',
		value: 'Noticias' },
	{
		label: '{{Receta}}: Artículos que deberían ser trasladados a wikilibros por ser una receta',
		value: 'Receta' },

	{
		label: '{{Sin notas al pie}}: Faltan notas de pie al artículo',
		value: 'Sinnotasalpie' },
         
        {
		label: '{{Sinrelevancia}}: Artículo sin relevancia',
		value: 'Sinrelevancia|\{\{subst:CURRENTDAY\}\}|\{\{subst:CURRENTMONTHNAME\}\}' }


];

friendlytag.wikificarList= [

	{
		label: '{{Wikificar}}: Sin categoría específica',
		value: 'Wikificar' },
	{
		label: '{{Wikificar|Anime y manga}}',
		value: 'Wikificar|anime y manga' },
	{
		label: '{{Wikificar|arquitectura}}',
		value: 'Wikificar|arquitectura' },
	{
		label: '{{Wikificar|Arte}}',
		value: 'Wikificar|arte' },
	{
		label: '{{Wikificar|biografías}}',
		value: 'Wikificar|biografías' },

	{
		label: '{{Wikificar|Ciencia}}',
		value: 'Wikificar|ciencia' },
	{
		label: '{{Wikificar|Cultura}}',
		value: 'Wikificar|cultura' },
	{
		label: '{{Wikificar|Deporte}}',
		value: 'Wikificar|deporte' },
	{
		label: '{{Wikificar|economía}}',
		value: 'Wikificar|economía' },
	{
		label: '{{Wikificar|empresas}}',
		value: 'Wikificar|empresas' },
	{
		label: '{{Wikificar|geografía}}',
		value: 'Wikificar|geografía' },
	{
		label: '{{Wikificar|historia}}',
		value: 'Wikificar|historia' },
	{
		label: '{{Wikificar|literatura}}',
		value: 'Wikificar|literatura' },
	{
		label: '{{Wikificar|mitología}}',
		value: 'Wikificar|mitología' },
	{
		label: '{{Wikificar|música}}',
		value: 'Wikificar|música' },
	{
		label: '{{Wikificar|ocio}}',
		value: 'Wikificar|ocio' },
	{
		label: '{{Wikificar|política}}',
		value: 'Wikificar|política' },

	{
		label: '{{Wikificar|tecnología}}',
		value: 'Wikificar|tecnología' },
	{
		label: '{{Wikificar|videojuegos}}',
		value: 'Wikificar|videojuegos' }


];

friendlytag.problemList = [
	{
		label: '{{Desactualizado}}: El artículo se encuentra desactualizado',
		value: 'Desactualizado' },
	{
		label: '{{Discutido}}: La exactitud del artículo es discutida',
		value: 'Discutido' },
	{
		label: '{{Fuente primaria}}: Artículos sospechosos de ser una investigación original',
		value: 'Fuenteprimaria|\{\{subst:CURRENTDAY\}\}|\{\{subst:CURRENTMONTHNAME\}\}' },
	{
		label: '{{Mal traducido}}: Traducciones defectuosas',
		value: 'Mal traducido' },
	{
		label: '{{Polémico}}: Artículo polémico que puede estar disputado',
		value: 'Polémico' },
	{
		label: '{{Publicidad}}: La versión actual del artículo parece estar escrita a modo de publicidad',
		value: 'Publicidad' },
	{
		label: '{{Revisar Trad}}: Aún no ha sido revisada la traducción del artículo por terceros',
		value: 'Revisar Trad' },
];

friendlytag.noticeList = [
	{
		label: '{{Actualidad}}: Artículo que se refiere a un acontecimiento en desarrollo',
		value: 'Actualidad' },
	{
		label: '{{Actualidad deporte}}: Artículos que se refieren a un evento deportivo en desarrollo',
		value: 'Actualidad deporte'  },
	{
		label: '{{Actualización}}: Artículo que está siendo actualizado',
		value: 'Actualización' },
	{
		label: '{{Edificio futuro}}: Se refiera a un edificio que se construirá en el futuro',
		value: 'Edificiofuturo' },
	{
		label: '{{En desarrollo}}: Se está trabajando para extender el artículo',
		value: 'En desarrollo' },
	{
		label: '{{Fallecimiento reciente}}: Persona fallecida recientemente',
		value: 'Fallecimiento reciente' },
	{
		label: '{{Futuro single}}: Futuro single musical',
		value: 'Futuro single' },
	{
		label: '{{Futuro vuelo espacial}}: Un vuelo espacial que se desarrollará en un futuro',
		value: 'Futuro vuelo espacial' },
	{
		label: '{{Futuro álbum}}: Un álbum musical que se desarrollará en un futuro',
		value: 'Futuro álbum' },
	{
		label: '{{Estreno próximo}}: Artículo que es sobre una producción cinematográfica próxima a estrenarse',
		value: 'Estreno próximo' }
];

friendlytag.notabilityList = {
	"anime y manga": {
		label: "artículos sobre anime y manga",
		value: "Anime y manga"
	},
	"Arquitectura": {
		label: "artículos sobre edificios",
		value: "arquitectura"
	},
	"arte": {
		label: "artículos de arte",
		value: "arte"
	},
	"ciencia": {
		label: "artículos sobre ciencia",
		value: "ciencia"
	},
	"Episode": {
		label: "notability guideline for television episodes",
		value: "Episode"
	},
	"Fiction": {
		label: "notability guideline for fiction",
		value: "Fiction"
	},
	"Institutions": {
		label: "synonym of \"Companies\"",
		value: "Institutions"
	},
	"Music": {
		label: "notability guideline for music",
		value: "Music"
	},
	"Neologisms": {
		label: "notability guideline for neologisms",
		value: "Neologisms"
	},
	"Numbers": {
		label: "notability guideline for numbers",
		value: "Numbers"
	},
	"Organizations": {
		label: "synonym of \"Companies\"",
		value: "Organizations"
	},
	"Products": {
		label: "notability guideline for products and services",
		value: "Products"
	},
	"Web": {
		label: "notability guideline for web content",
		value: "Web"
	}
};

friendlytag.currentList = {
	"current": {
		label: "{{current}}: article documents a current event",
		value: "current"
	},
	"airing": {
		label: "{{airng}}: program is currently airing",
		value: "airing"
	},
	"bridge under construction": {
		label: "{{bridge under construction}}: article contains information about a bridge currently under construction",
		value: "bridge under construction"
	},
	"building under construction": {
		label: "{{bridge under construction}}: article contains information about a building currently under construction",
		value: "building under construction"
	},
	"antics": {
		label: "{{current antics}}: person is currently participating in a reality television show",
		value: "current antics"
	},
	"bill": {
		label: "{{current bill}}: article documents proposed legislation that is currently being considered",
		value: "current bill"
	},
	"court case": {
		label: "{{current court case}}: article documents a current court case",
		value: "current court case"
	},
	"fiction": {
		label: "{{current fiction}}: article is about a recently released work of fiction",
		value: "current fiction"
	},
	"game": {
		label: "{{current game}}: article documents a current event in video gaming",
		value: "current game"
	},
	"person": {
		label: "{{current person}}: article is about a person involved in a current event",
		value: "current person"
	},
	"product": {
		label: "{{current product}}: article documents a recently released product",
		value: "current product"
	},
	"pw": {
		label: "{{current pw}}: article documents a current professional wrestling event",
		value: "current pw"
	},
	"spaceflight": {
		label: "{{current spaceflight}}: article or section documents a current spaceflight",
		value: "current spaceflight"
	},
	"sport": {
		label: "{{current sport}}: article documents a current sports-related event",
		value: "current sport"
	},
	"delay": {
		label: "{{current sport delay}}: article documents a current sports-related event which may contain information not aired because of tape delay",
		value: "current sport delay"
	},
	"related": {
		label: "{{current related}}: article is related to a current event",
		value: "current related"
	},
	"single": {
		label: "{{current single}}: article documents a current single",
		value: "current single"
	},
	"territorial changes": {
		label: "{{current territorial changes}}: article is subject to current territorial changes and may not represent up-to-date detail",
		value: "current territorial changes"
	},
	"in space": {
		label: "{{in space}}: article documents a person who is currently in space",
		value: "in space"
	},
	"inland waterway under restoration": {
		label: "{{inland waterway under restoration}}: article contains information about an inland waterway currently under restoration",
		value: "inland waterway under restoration"
	},
	"ongoing lawsuit": {
		label: "{{ongoing lawsuit}}: article documents an ongoing lawsuit",
		value: "ongoing lawsuit"
	},
	"ongoing election": {
		label: "{{ongoing election}}: article contains information about an ongoing election",
		value: "ongoing election"
	},
	"ongoing weather": {
		label: "{{ongoing weather}}: article contains information about an ongoing meteorological event or phenomenon",
		value: "ongoing weather"
	},
	"recent death": {
		label: "{{recent death}}: article is about a person who has recently died",
		value: "recent death"
	},
	"recently convicted": {
		label: "{{recently convicted}}: article is about a person who has recently been convicted in a criminal case",
		value: "recently convicted"
	},
	"road under construction": {
		label: "{{road under construction}}: article contains information about a road currently under construction",
		value: "road under construction"
	}
};

friendlytag.futureList = {
	"future0": {
		label: "{{future}}: article is about scheduled or expected future events",
		value: "future"
	},
	"future1": {
		label: "== Education ==",
		value: "future"
	},
	"article": {
		label: "{{future article}}: expected future articles",
		value: "future article"
	},
	"book": {
		label: "{{future book}}: scheduled, forthcoming or expected future book(s)",
		value: "future book"
	},
	"museum": {
		label: "{{future museum}}: planned museum",
		value: "future museum"
	},
	"zoo exhibit": {
		label: "{{future zoo exhibit}}: planned or expected new zoo exhibit",
		value: "future zoo exhibit"
	},
	"future2": {
		label: "== Engineering ==",
		value: "future"
	},
	"building": {
		label: "{{future building}}: expected future buildings or structures",
		value: "future building"
	},
	"chip": {
		label: "{{future chip}}: scheduled or expected future computer chips",
		value: "future chip"
	},
	"dam": {
		label: "{{future dam}}: planned or expected dam",
		value: "future dam"
	},
	"energy infrastructure": {
		label: "{{future energy infrastructure}}: planned or expected future energy production, transmission, distribution or other energy related infrastructure",
		value: "future energy infrastructure"
	},
	"infrastructure": {
		label: "{{future infrastructure}}: planned or expected future infrastructure",
		value: "future infrastructure"
	},
	"mine": {
		label: "{{future mine}}: planned or proposed future mine",
		value: "future mine"
	},
	"pipeline": {
		label: "{{future pipeline}}: planned or expected pipeline",
		value: "future pipeline"
	},
	"power plant": {
		label: "{{future power plant}}: planned or expected power plant",
		value: "future power plant"
	},
	"scientific facility": {
		label: "{{future scientific facility}}: expected future scientific facility",
		value: "future scientific facility"
	},
	"software": {
		label: "{{future software}}: scheduled or expected future software",
		value: "future software"
	},
	"spaceflight": {
		label: "{{future spaceflight}}: scheduled or expected spaceflight",
		value: "future spaceflight"
	},
	"launching": {
		label: "{{launching}}: rocket or spacecraft which is either currently in the process of launching, or is scheduled to launch within the next few days",
		value: "launching"
	},
	"web service": {
		label: "{{future web service}}: scheduled or expected Web service",
		value: "future web service"
	},
	"future3": {
		label: "== Entertainment ==",
		value: "future"
	},
	"album": {
		label: "{{future album}}: scheduled or expected album",
		value: "future album"
	},
	"amusement ride": {
		label: "{{future amusement ride}}: planned or expected future amusement ride",
		value: "future amusement ride"
	},
	"awards show": {
		label: "{{future awards show}}: upcoming awards show",
		value: "future awards show"
	},
	"channel": {
		label: "{{future channel}}: future television station, channel or network",
		value: "future channel"
	},
	"comic": {
		label: "{{future comic}}: scheduled or expected comic book release, or a series already in progress",
		value: "future comic"
	},
	"film": {
		label: "{{future film}}: one or more scheduled or expected films",
		value: "future film"
	},
	"game": {
		label: "{{future game}}: unreleased video game",
		value: "future game"
	},
	"music festival": {
		label: "{{future music festival}}: upcoming music/arts festival",
		value: "future music festival"
	},
	"play article": {
		label: "{{future play article}}: upcoming play or musical",
		value: "future play article"
	},
	"radio": {
		label: "{{future radio}}: future radio station, radio network or radio show",
		value: "future radio"
	},
	"UK radio station": {
		label: "{{future UK radio station}}: future radio station in the United Kingdom",
		value: "future UK radio station"
	},
	"single": {
		label: "{{future single}}: scheduled or expected future single",
		value: "future single"
	},
	"television episode": {
		label: "{{future television episode}}: scheduled upcoming television episode of an already-running TV series",
		value: "future television episode"
	},
	"television series": {
		label: "{{future television series}}: scheduled upcoming television series",
		value: "future television series"
	},
	"webcomic": {
		label: "{{future webcomic}}: scheduled or expected webcomic update/premiere, or a series already in progress",
		value: "future webcomic"
	},
	"future4": {
		label: "== Miscellaneous ==",
		value: "future"
	},
	"concept product": {
		label: "{{concept product}}: contains information about conceptual products",
		value: "concept product"
	},
	"election": {
		label: "{{future election}}: forthcoming or ongoing election",
		value: "future election"
	},
	"election in the United States": {
		label: "{{future election in the United States}}: upcoming or ongoing election in the United States",
		value: "future election in the United States"
	},
	"product": {
		label: "{{future product}}: scheduled or expected future product",
		value: "future product"
	},
	"product small": {
		label: "{{future product small}}: (small) future product, and may contain unverified, unreliable, or incorrect information",
		value: "future product small"
	},
	"future5": {
		label: "== Transportation ==",
		value: "future"
	},
	"aircraft": {
		label: "{{future aircraft}}: scheduled or anticipated future aircraft",
		value: "future aircraft"
	},
	"airline": {
		label: "{{future airline}}: planned or expected new airline",
		value: "future airline"
	},
	"airport": {
		label: "{{future airport}}: planned or expected new airport",
		value: "future airport"
	},
	"airport authority": {
		label: "{{future airport authority}}: planned or expected new airport authority",
		value: "future airport authority"
	},
	"airport expansion": {
		label: "{{future airport expansion}}: planned or expected expansion of an existing airport",
		value: "future airport expansion"
	},
	"Australian public transportation": {
		label: "{{future Australian public transportation}}: planned or expected public transportation infrastructure in Australia",
		value: "future Australian public transportation"
	},
	"automobile": {
		label: "{{future automobile}}: scheduled or anticipated future automobile",
		value: "future automobile"
	},
	"bridge": {
		label: "{{future bridge}}: planned or proposed future bridge",
		value: "future bridge"
	},
	"Canadian public transportation": {
		label: "{{future Canadian public transportation}}: planned or expected public transportation infrastructure in Canada",
		value: "future Canadian public transportation"
	},
	"Chinese public transportation": {
		label: "{{future Chinese public transportation}}: planned or expected public transportation infrastructure in China",
		value: "future Chinese public transportation"
	},
	"concept automobile": {
		label: "{{concept automobile}}: concept automobile",
		value: "concept automobile"
	},
	"French public transportation": {
		label: "{{future French public transportation}}: planned or expected public transportation infrastructure in France",
		value: "future French public transportation"
	},
	"London transport infrastructure": {
		label: "{{future London transport infrastructure}}: planned or expected London Transport infrastructure",
		value: "future London transport infrastructure"
	},
	"motorcycle": {
		label: "{{future motorcycle}}: scheduled or anticipated future motorcycle",
		value: "future motorcycle"
	},
	"public transportation": {
		label: "{{future public transportation}}: planned or expected public transportation infrastructure",
		value: "future public transportation"
	},
	"railway station": {
		label: "{{future railway station}}: planned or expected future railway station",
		value: "future railway station"
	},
	"road": {
		label: "{{future road}}: planned or expected future road",
		value: "future road"
	},
	"tunnel": {
		label: "{{future tunnel}}: planned or expected future tunnel",
		value: "future tunnel"
	},
	"UK public transportation": {
		label: "{{future UK public transportation}}: planned or expected public transportation in the United Kingdom",
		value: "future UK public transportation"
	},
	"USA public transportation": {
		label: "{{future USA public transportation}}: proposed, planned, or expected public transportation infrastructure in the United States",
		value: "future USA public transportation"
	},
	"future6": {
		label: "== Sports ==",
		value: "future"
	},
	"arena": {
		label: "{{future arena}}: planned or proposed arena",
		value: "future arena"
	},
	"motor sport": {
		label: "{{future motor sport}}: future motor sporting event or team",
		value: "future motor sport"
	},
	"pw": {
		label: "{{future pw}}: scheduled professional wrestling event that is taking place in the future",
		value: "future pw"
	},
	"sport": {
		label: "{{future sport}}: future sporting event or team",
		value: "future sport"
	},
	"sports venue": {
		label: "{{future sports venue}}: planned or expected sports venue",
		value: "future sports venue"
	},
	"stadium": {
		label: "{{future stadium}}: planned or proposed stadium",
		value: "future stadium"
	}
};

friendlytag.spellingList = [
	{
		label: '{{R from abbreviation}}: redirect from a title with an abbreviation',
		value: 'R from abbreviation' },
	{
		label: '{{R to list entry}}: redirect to a \"list of minor entities\"-type article which is a collection of brief descriptions for subjects not notable enough to have separate articles',
		value: 'R to list entry' },
	{
		label: '{{R to section}}: sames as {{R to list entry}}, but when list is more sectionlike in organization, such as list of fictional characters in a fictional universe.',
		value: 'R to section' },
	{
		label: '{{R from misspelling}}: redirect from a misspelling or typographical error',
		value: 'R from misspelling' },
	{
		label: '{{R from alternative spelling}}: redirect from a title with a different spelling',
		value: 'R from alternative spelling' },
	{
		label: '{{R from plural}}: redirect from a plural word to the singular equivalent',
		value: 'R from plural' },
	{
		label: '{{R from related word}}: redirect from a related word',
		value: 'R from related word' },
	{
		label: '{{R with possibilities}}: redirect from a title for a topic more detailed than what is currently provided on the target page, or section of that page, hence something which can and should be expanded',
		value: 'R with possibilities' },
	{
		label: '{{R from member}}: redirect from a person who is a member of a group to more general related topics, such as the group, organization, ensemble or team that he or she belongs to',
		value: 'R from member' },
	{
		label: '{{R from other capitalisation}}: redirect from a title with another method of capitalisation',
		value: 'R from other capitalisation' }
];

friendlytag.alternativeList = [
	{
		label: '{{R from alternative name}}: redirect from a title that is another name, a pseudonym, a nickname, or a synonym',
		value: 'R from alternative name' },
	{
		label: '{{R from historic name}}: redirect from a title that is another name, a pseudonym, a nickname, or a synonym that has a significant historic past as a region, state, principate\'s holding, city, city-state or such, but which region has been subsumed into a modern era municipality, district or state, or otherwise suffered from a name change over time',
		value: 'R from historic name' },
	{
		label: '{{R from scientific name}}: redirect from the scientific name to the common name',
		value: 'R from scientific name' },
	{
		label: '{{R to scientific name}}: redirect from the common name to the scientific name',
		value: 'R to scientific name' },
	{
		label: '{{R from alternative language}}: redirect from an English name to a name in another language, or vice-versa',
		value: 'R from alternative language' },
	{
		label: '{{R from ASCII}}: redirect from a title in basic ASCII to the formal article title, with differences that are not diacritical marks (accents, umlauts, etc.)',
		value: 'R from ASCII' },
	{
		label: '{{R from title without diacritics}}: redirect to the article title with diacritical marks (accents, umlauts, etc.)',
		value: 'R from title without diacritics' }
];

friendlytag.administrativeList = [
	{
		label: '{{R to disambiguation page}}: redirect to a disambiguation page',
		value: 'R to disambiguation page' },
	{
		label: '{{R for as of}}: redirect page affects an \"as of ...\" link',
		value: 'R for as of' },
	{
		label: '{{R to decade}}: redirect from a year to the decade article',
		value: 'R to decade' },
	{
		label: '{{R from shortcut}}: redirect from a Wikipedia shortcut',
		value: 'R from shortcut' },
	{
		label: '{{R from CamelCase}}: redirect from a CamelCase title',
		value: 'R from CamelCase' },
	{
		label: '{{R from EXIF}}: redirect of a wikilink created from JPEG EXIF information (i.e. the \"metadata\" section on some image description pages)',
		value: 'R from EXIF' },
	{
		label: '{{R from school}}: redirect from a school article that had very little information',
		value: 'R from school' }
];

// Set to true if template can be grouped into {{articleissues}}
friendlytag.groupHash = {
	'wikificar': true,
	'no neutralidad': true,
	'copyedit': true,
	'referencias': true,
	'contextualizar': true,
	'sinrelevancia': true,
	'desactualizado': true,
	'in-universe': true,
	'internallinks': false,
	'introrewrite': true,
	'nofootnotes': false,
	'orphan': true,
	'plot': true,
	'sections': true,
	'tone': true,
	'toolong': true,
	'tooshort': true,
	'uncategorized': false,
	'verylong': true,
	'wikify': true,
	'advert': true,
	'autobiography': true,
	'coi': true,
	'context': true,
	'disputed': true,
	'hoax': false,
	'non-free': true,
	'notability': true,
	'npov': true,
	'original research': true,
	'primarysources': true,
	'refimprove': true,
	'self-published': true,
	'totally-disputed': false,
	'unencyclopedic': true,
	'unreferenced': true,
	'update': true,
	'weasel': true,
	'currentevent': false,
	'future': false,
	'inuse': false,
	'underconstruction': false
}

friendlytag.callback.change_notability = function friendlytagCallbackChangeNotability(e) {
	if( e.target.checked ) {
		var notabilitySelect = new QuickForm.element( { type:'select', name:'notabilityList' } );

		notabilitySelect.append( { type:'option', label:friendlytag.maintenanceList[0].label, value:"none" } );
		for( var i in friendlytag.notabilityList ) {
			notabilitySelect.append( { type:'option',	label:"{{wikificar|" + i + "}}: "
					+ friendlytag.notabilityList[i].label, value:friendlytag.notabilityList[i].value } );
		}
		e.target.parentNode.removeChild( e.target.nextSibling );
		e.target.parentNode.appendChild( notabilitySelect.render().firstChild );
	} else {
		e.target.parentNode.removeChild( e.target.parentNode.lastChild );
		var notabilityLabel = document.createElement( "label" );
		e.target.parentNode.appendChild( notabilityLabel );
		notabilityLabel.innerHTML = friendlytag.problemList[7].label;
	}
}

friendlytag.callback.change_current = function friendlytagCallbackChangeCurrent(e) {
	if( e.target.checked ) {
		var currentSelect = new QuickForm.element( { type:'select', name:'currentList' } );

		for( var i in friendlytag.currentList ) {
			currentSelect.append( { type:'option',	label:friendlytag.currentList[i].label, value:friendlytag.currentList[i].value } );
		}
		e.target.parentNode.removeChild( e.target.nextSibling );
		e.target.parentNode.appendChild( currentSelect.render().firstChild );
	} else {
		e.target.parentNode.removeChild( e.target.parentNode.lastChild );
		var currentLabel = document.createElement( "label" );
		e.target.parentNode.appendChild( currentLabel );
		currentLabel.innerHTML = friendlytag.noticeList[0].label;
	}
}

friendlytag.callback.change_future = function friendlytagCallbackChangeFuture(e) {
	if( e.target.checked ) {
		var futureSelect = new QuickForm.element( { type:'select', name:'futureList' } );

		for( var i in friendlytag.futureList ) {
			futureSelect.append( { type:'option',	label:friendlytag.futureList[i].label, value:friendlytag.futureList[i].value } );
		}
		e.target.parentNode.removeChild( e.target.nextSibling );
		e.target.parentNode.appendChild( futureSelect.render().firstChild );
	} else {
		e.target.parentNode.removeChild( e.target.parentNode.lastChild );
		var futureLabel = document.createElement( "label" );
		e.target.parentNode.appendChild( futureLabel );
		futureLabel.innerHTML = friendlytag.noticeList[1].label;
	}
}

friendlytag.callbacks = {
	main: function( self ) {
		var form = self.responseXML.getElementById( 'editform' );
		var tagRe, text = '', summaryText = 'Añadida la plantilla';
		var tags = new Array(), groupableTags = new Array();
		
		if( !isRedirect ) {
			// Check for preexisting tags and separate tags into groupable and non-groupable arrays
			Status.info( 'Info:', 'Buscando marcas preexistentes en el artículo' );
			for( var i = 0; i < self.params.tags.length; i++ ) {
				tagRe = new RegExp( '(\{\{' + self.params.tags[i] + '(\||\}\}))', 'im' );
				if( !tagRe.exec( form.wpTextbox1.value ) ) {
					if( friendlytag.groupHash[ self.params.tags[i] ] ) {
						groupableTags = groupableTags.concat( self.params.tags[i] );
					} else {
						tags = tags.concat( self.params.tags[i] );
					}
				} else {
					Status.info( 'Info:', 'Encontrada{{' + self.params.tags[i]
							+ '}} en el artículo, excluyendo' );
				}
			}

			if( self.params.group && groupableTags.length > 3 ) {
				Status.info( 'Info', 'Grouping supported tags into {{articleissues}}' );

				groupableTags.sort();
				text += '{{Usuario:Pericallis/Defectos artículo';
				summaryText += ' {{Usuario:Pericallis/Defectos artículo}} with parameters';
				for( var i = 0; i < groupableTags.length; i++ ) {
					text += '|' + groupableTags[i]
							+ '={{subst:CURRENTMONTHNAME}} {{subst:CURRENTYEAR}}';

					if( i == (groupableTags.length - 1) ) {
						summaryText += ' and';
					} else if ( i < (groupableTags.length - 1) && i != 0 ) {
						summaryText += ',';
					}
					summaryText += ' ' + groupableTags[i];
				}
				text += '}}\n';
			} else {
				tags = tags.concat( groupableTags );
			}
		} else {
			// Check for preexisting tags
			Status.info( 'Info', 'Checking for preexisting tags on the redirect' );
			for( var i = 0; i < self.params.tags.length; i++ ) {
				tagRe = new RegExp( '(\{\{' + self.params.tags[i] + '(\||\}\}))', 'im' );
				if( !tagRe.exec( form.wpTextbox1.value ) ) {
					tags = tags.concat( self.params.tags[i] );
				} else {
					Status.info( 'Info', 'Found {{' + self.params.tags[i]
							+ '}} on the redirect already...excluding' );
				}
			}
		}
		
		tags.sort();
		for( var i = 0; i < tags.length; i++ ) {
			if( tags[i] != 'uncategorized' ) {
				if( tags[i] == 'current' ) {
					text += '{{' + self.params.currentSubcategory;
				} else if( tags[i] == 'future' ) {
					text += '{{' + self.params.futureSubcategory;
				} else {
					text += ( isRedirect ? '\n' : '' ) + '{{' + tags[i];
				}
				
				if( tags[i] == 'notability' && self.params.notabilitySubcategory != 'none' ) {
					text += '|' + self.params.notabilitySubcategory;
				}
				
				text += isRedirect ? '}}' : '}}\n';
			} else {
				form.wpTextbox1.value += '\n\n{{' + tags[i]
						+ '}}';
			}

			if( i == (tags.length - 1) && ( i > 0 || groupableTags.length > 3 ) ) {
				summaryText += ' and';
			} else if ( i < (tags.length - 1) && ( i != 0 || groupableTags.length > 3 ) ) {
				summaryText += ',';
			}
			
			summaryText += ' {{[[Template:';
			if( tags[i] == 'current' ) {
				summaryText += self.params.currentSubcategory + '|' + self.params.currentSubcategory;
			} else if( tags[i] == 'future' ) {
				summaryText += self.params.futureSubcategory + '|' + self.params.futureSubcategory;
			} else {
				summaryText += tags[i] + '|' + tags[i];
			}
			summaryText += ']]}}';
		}
		
		if( !isRedirect ) {
			text += form.wpTextbox1.value;
		} else {
			text = form.wpTextbox1.value + text;
		}
		summaryText += ' al' + ( ( tags.length + ( groupableTags.length > 3 ? 1 : 0 ) ) > 1 ? 's' : '' )
				+ ' ' + ( isRedirect ? 'redirect.' : 'artículo.' ) + FriendlyConfig.summaryAd;
		
		var postData = {
			'wpMinoredit': FriendlyConfig.markTaggedPagesAsMinor ? 1 : undefined,
			'wpWatchthis': form.wpWatchthis.checked ? 1 : (FriendlyConfig.watchTaggedPages ? 1 : undefined),
			'wpStarttime': form.wpStarttime.value,
			'wpEdittime': form.wpEdittime.value,
			'wpAutoSummary': form.wpAutoSummary.value,
			'wpEditToken': form.wpEditToken.value,
			'wpSection': '',
			'wpSummary': summaryText,
			'wpTextbox1': text
		};
 
		self.post( postData );
	}
}

friendlytag.callback.evaluate = function friendlytagCallbackEvaluate(e) {
	var form = e.target;
	var tags = isRedirect ? ( getChecked( form.administrative ).concat( getChecked( form.alternative ) ).concat( getChecked( form.spelling ) ) )
			: ( getChecked( form.notice ).concat( getChecked( form.problem ) ).concat( getChecked( form.wikificar) ).concat( getChecked( form.maintenance ) ) );
	var params;
	if( !isRedirect ) {
		var notabilitySubcategory = null;
		var currentSubcategory = null;
		var futureSubcategory = null;
		var group = form.group.checked;
	}

	if( tags.length == 0 ) {
		alert( 'You must select at least one tag!' );
		return;
	}

	if( !isRedirect ) {
		if( form.problem[7].checked ) {
			notabilitySubcategory = form.problem[7].nextSibling.value;
		}
		
		if( form.notice[0].checked ) {
			currentSubcategory = form.notice[0].nextSibling.value;
		}
		
		if( form.notice[1].checked ) {
			futureSubcategory = form.notice[1].nextSibling.value;
		}

		params = {
			tags: tags,
			group: group,
			notabilitySubcategory: notabilitySubcategory,
			currentSubcategory: currentSubcategory,
			futureSubcategory: futureSubcategory
		}
	} else {
		params = {
			tags: tags
		}
	}

	Status.init( form );

	var query = { 
		'title': mw.config.get('wgPageName'), 
		'action': 'submit'
	};
	Wikipedia.actionCompleted.redirect = mw.config.get('wgPageName');
	Wikipedia.actionCompleted.notice = "Marcando artículo: Completado, recargando artículo en unos segundos";
	var wikipedia_wiki = new Wikipedia.wiki( 'Modificando el artículo', query, friendlytag.callbacks.main );
	wikipedia_wiki.params = params;
	wikipedia_wiki.get();
}
// </nowiki>