User:Theopolisme/stubs.js

// 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 TWINKLE */ if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) { TwinkleConfig.summaryAd = " (TW)"; } /** TwinkleConfig.deletionSummaryAd (string) If ad should be added or not to deletion summary, default TWINKLE */ if( typeof( TwinkleConfig.deletionSummaryAd ) == 'undefined' ) { TwinkleConfig.deletionSummaryAd = " (TW)"; } /** TwinkleConfig.watchSpeedyPages (array) What types of actions that should result in forced addition to watchlist */ if( typeof( TwinkleConfig.watchSpeedyPages ) == 'undefined' ) { TwinkleConfig.watchSpeedyPages = [ 'G3', 'G10', 'G11', 'G12' ]; } /** 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 = [ 'G1', 'G2', 'G3', 'G4', 'G10', 'G11', 'G12', 'A1', 'A2', 'A3', 'A4', 'A5', 'I1','T2' ]; } /** TwinkleConfig.userTalkPageMode may take arguments: 'window': open a new window, remmenber 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.deleteTalkPageOnDelete If talk page if exists should also be deleted (QD G8) when speedying a page (admin only) */ if( typeof( TwinkleConfig.deleteTalkPageOnDelete ) == 'undefined' ) { TwinkleConfig.deleteTalkPageOnDelete = false; } /** TwinkleConfig.toolboxButtons (string) If id defined in this array, the button of the action is located in the 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:true }; } function twinkletag { if( wgNamespaceNumber == 0 ) { twAddPortletLink( "javascript:twinkletag.callback", "Stub", "tw-tag", "Add stub template(s)", ""); }		return; } $(twinkletag); twinkletag.callback = function twinkletagCallback { var Window = new SimpleWindow( 800, 400 ); Window.setTitle( "Add stub template(s)" ); var form = new QuickForm( twinkletag.callback.evaluateUser, 'change' ); form.append( { type:'header', label:'General' } ); form.append( {			type: 'radio',			name: 'mtpl',			list: [				{ 					label: ,					value: 'Stub',					tooltip: 'for all stubs that can not fit into any stub we have' 				},				{ 					label: ,					value: 'List-stub',					tooltip: 'for lists only' 				}			]		}); form.append( { type:'header', label:'Countries & Geography' } ); form.append( {			type: 'radio',			name: 'mtpl',			list: [				{ 					label: ,					value: 'Geo-stub',					tooltip: 'all geographical locations (places, towns, cities, etc)' 				},				{ 					label: ,					value: 'France-geo-stub',					tooltip: 'France geography topics.'				},				{					label: ,					value: 'US-geo-stub',					tooltip: 'United States geography topics'				},				{					label: ,					value: 'Asia-stub',					tooltip: 'for use with anything about Asia, except people.'				},				{					label: ,					value: 'Japan-stub',					tooltip: 'for use with anything about Japan, except people.'				},				{					label: ,					value: 'Japan-sports-bio-stub',					tooltip: 'Japanese sport biographies.'				},				{					label: ,					value: 'Europe-stub',					tooltip: 'for use with anything about Europe, except people.'				},				{					label: ,					value: 'Switzerland-stub',					tooltip: 'for use with anything about Switzerland, except people.' },				{					label: '', value: 'North-America-stub', tooltip: 'for use with anthing about North America, except people.' },				{					label: '', value: 'US-stub', tooltip: 'for use with anything about the United States, except people and geography.' },				{					label: '', value: 'US-bio-stub', tooltip: 'United States biography stubs.' },				{					label: '', value: 'US-geo-stub', tooltip: 'United States geography topics.' }			]		});	form.append( { type:'header', label:'Miscellaneous' } );	form.append( { type: 'radio', name: 'mtpl', list: [ { 					label: '', value: 'Food-stub', },				{ 					label: '', value: 'History-stub', },				{					label: '', value: 'Military-geo-stub', },				{					label: '', value: 'Politics-stub', },				{					label: '', value: 'Religion-stub', },				{					label: '', value: 'Transport-stub', tooltip: 'any moving object' }			]		});

form.append( { type:'header', label:'People' } ); form.append( {			type: 'radio',			name: 'mtpl',			list: [				{ 					label: ,					value: 'Actor-stub',				},				{ 					label: ,					value: 'US-actor-stub',					tooltip: 'Unites States actor biographies'				},				{					label: ,					value: 'Bio-stub',					tooltip: 'all people, no matter who or what profession'				},				{					label: ,					value: 'US-bio-stub',					tooltip: 'American biographies'				},				{					label: '',					value: 'US-actor-stub',					tooltip: 'Unites States actor biographies'				},				{					label: ' ',					value: 'Sports-bio-stub',					tooltip: 'people from with sport as profession'				},				{					label: ' ',					value: 'Japan-sports-bio-stub',					tooltip: 'Japanese athlete biographies'				}			]		});

form.append( { type:'header', label:'Science' } ); form.append( {			type: 'radio',			name: 'mtpl',			list: [				{ 					label: ,					value: 'Sci-stub',					tooltip: 'anything science related (all branches and their tools)'				},				{ 					label: ,					value: 'Biology-stub',				},				{					label: ,					value: 'Chem-stub',				},				{					label: ,					value: 'Math-stub',				},				{					label: '',					value: 'Med-stub',				},				{					label: ' ',					value: 'Physics-stub',				},				{					label: ' ',					value: 'Weather-stub',				}			]		});

form.append( { type:'header', label:'Sports' } ); form.append( {			type: 'radio',			name: 'mtpl',			list: [				{ 					label: ,					value: 'Sports-stub',					tooltip: 'all sports and sports items, not people' 				},				{ 					label: ,					value: 'Sports-bio-stub',					tooltip: 'people from with sport as profession' 				},				{ 					label: '',					value: 'Japan-sports-bio-stub',					tooltip: 'Japanese athlete biographies' 				}			]		});

form.append( { type:'header', label:'Technology' } ); form.append( {			type: 'radio',			name: 'mtpl',			list: [				{ 					label: ,					value: 'Tech-stub',					tooltip: 'All technology related stubs' 				},				{ 					label: ,					value: 'Video-game-stub',					tooltip: 'Stubs to do with video games' 				}			]		});

form.append( { type:'header', label:'The Arts' } ); form.append( {			type: 'radio',			name: 'mtpl',			list: [				{ 					label: ,					value: 'Performing-arts-stub',					tooltip: 'general stub for the performing arts'				},				{ 					label: ,					value: 'Actor-stub',				},				{					label: ,					value: 'US-actor-stub',					tooltip: 'Unites States actor biographies'				},				{					label: ,					value: 'Movie-stub',					tooltip: 'all movie articles except people'				},				{					label: ,					value: 'Music-stub',					tooltip: 'all music articles except people'				},				{					label: ,					value: 'TV-stub',					tooltip: 'all television articles except people'				},				{					label: '',					value: 'Lit-stub',					tooltip: 'all literature articles except people'				}			]		});

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

twinkletag.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 been deleted" ); return; }			var query = { 'title': wgPageName, 'action': 'submit' };			var wikipedia_wiki = new Wikipedia.wiki( 'Tagging page', query, twinkletag.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; self.statelem.status( 'Checking for tags on the page...' );

var tag = new RegExp('(\{\{(?:'+self.params.normalized+')\}\})').exec( text ); if( tag ) { self.statelem.error( [ htmlNode( 'strong', tag[0] ), " is already placed on the page." ] ) return; }			var code, content; switch( self.params.normalized ) { case "Stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "List-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Geo-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "France-geo-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "US-geo-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Asia-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Japan-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Japan-sports-bio-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Europe-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Switzerland-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "North-America-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "US-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "US-actor-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "US-bio-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "US-geo-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Food-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "History-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Military-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Politics-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Religion-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Transport-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Actor-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Bio-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Sports-bio-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Sci-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Biology-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Chem-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Math-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Med-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Physics-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Weather-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Sports-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Tech-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Video-game-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Performing-arts-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Actor-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Movie-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Music-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "TV-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; case "Lit-stub": code = "\{\{" + self.params.normalized+ "\}\}"; content = text + "\n" + code; break; default: code = "\{\{" + self.params.normalized+ "\}\}"; content = code + "\n" + text; break; }			var postData = { 'wpMinoredit': TwinkleConfig.markSpeedyPagesAsMinor ? '' : undefined, 'wpWatchthis': (self.params.watch || form.wpWatchthis.checked ) ? '' : undefined, 'wpStarttime': form.wpStarttime.value, 'wpEdittime': form.wpEdittime.value, 'wpAutoSummary': form.wpAutoSummary.value, 'wpEditToken': form.wpEditToken.value, 'wpSummary': "Adding stub template: "+ TwinkleConfig.summaryAd, 'wpTextbox1': content };			self.post( postData ); },		userNotification: function( self ) { var form = self.responseXML.getElementById( 'editform' ); var text = form.wpTextbox1.value; text += "\n\{\{subst:QD-notice|page=" + wgPageName + "|cat=" + self.params.normalized + "|reason=" + twinklespeedy.reasonHash[ self.params.value ] + "\}\} \~\~\~\~"; 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, 'wpSummary': 'Notification: Quick deletion nomination of \[\[' + wgPageName + '\]\].' + TwinkleConfig.summaryAd, 'wpTextbox1': text };			self.post( postData ); }	} } twinkletag.callback.evaluateUser = function twinkletagCallbackEvaluateUser(e) { wgPageName = wgPageName.replace( /_/g, ' ' ); // for queen/king/whatever and country! var value = e.target.value; //var normalized = twinkletag.normalizeHash[ value ]; var params = { value: value, normalized: value, watch: false, usertalk: false };	Status.init( e.target.form ); Wikipedia.actionCompleted.redirect = wgPageName; Wikipedia.actionCompleted.notice = "Tagging complete"; var query = { 'action': 'query', 'titles': wgPageName }	var wikipedia_api = new Wikipedia.api( 'Checking if page exists', query, twinkletag.callbacks.user.main ); wikipedia_api.params = params; wikipedia_api.post; } //