Difference between revisions 3762304 and 3762311 on simplewiki

// If TwinkleConfig aint exist.
if( typeof( TwinkleConfig ) == 'undefined' ) {
	TwinkleConfig = {};
}

/**
 TwinkleConfig.defaultGroup (int)
 if true, watch the page which has been dispatched an warning or notice, if false, default applies
(contracted; show full)twinklewelcome.callback = function twinklewelcomeCallback() {
	var Window = new SimpleWindow( 600, 400 );
	Window.setTitle( "Twinkle ยท Welcome user" );
	var form = new QuickForm( twinklewelcome.callback.evaluate );

	var main_select = form.append( {
			type:'field',
			label:'Choose 
type of warning/notice to issue',
			tooltip:'First choose a main warning group, then the specific warning to issuewelcome message template',
			tooltip:'Choose your welcome message you want to use. There are different types of welcome templates.'
		} );

	var main_group = main_select.append( {
			type:'select',
			name:'main_group',
			event:twinklewelcome.callback.change_category
		} );

	main_group.append( { type:'option', label:'General Note (1)', value:'level1', selected: ( TwinkleConfig.defaultWarningGroup == 1 || TwinkleConfig.defaultWarningGroup < 1 || ( userIsInGroup( 'sysop' ) ? TwinkleConfig.defaultWarningGroup > 8 : TwinkleConfig.defaultWarningGroup > 7 ) ) } );
	main_group.append( { type:'option', label:'Caution (2)', value:'level2', selected: ( TwinkleConfig.defaultWarningGroup == 2 ) } );
	main_group.append( { type:'option', label:'Warning (3)', value:'level3', selected: ( TwinkleConfig.defaultWarningGroup == 3 ) } );
	main_group.append( { type:'option', label:'Final warning (4)', value:'level4', selected: ( TwinkleConfig.defaultWarningGroup == 4 ) } );
	main_group.append( { type:'option', label:'Only warning (4im)', value:'level4im', selected: ( TwinkleConfig.defaultWarningGroup == 5 ) } );
	main_group.append( { type:'option', label:'Single issue notices', value:'singlenotice', selected: ( TwinkleConfig.defaultWarningGroup == 6 ) } );
	main_group.append( { type:'option', label:'Single issue warnings', value:'singlewarn', selected: ( TwinkleConfig.defaultWarningGroup == 7 ) } );
    main_group.append( { type:'option', label:'Welcome messages', value:'welcome', selected: ( TwinkleConfig.defaultWarningGroup == 9 ) } );
	if( userIsInGroup( 'sysop' ) ) {
		main_group.append( { type:'option', label:'Blocking', value:'block', selected: ( TwinkleConfig.defaultWarningGroup == 8 ) } );
	}

	main_select.append( { type:'select', name:'sub_group', event:twinklewelcome.callback.change_subcategory } ); //Will be empty to begin with.

	form.append( {
			type:'input',
			name:'article',
			label:'Linked article',
			value:( QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '' ),
			tooltip:'An article might be linked to the notice, either it was a revert to said article that dispatched this notice. Leave empty for no article to be linked'
		} );


	var more = form.append( { type:'field', label:'Fill in an optional reason and hit \"Submit\"' } );
	more.append( { type:'textarea', label:'More:', name:'reason', tooltip:'Perhaps a reason, or that a more detailed notice must be appended' } );
	more.append( { type:'submit', label:'Submit' } );
	var result = form.render();
	Window.setContent( result );
	Window.display();
	result.main_group.root = result;

	// We must init the first choice (General Note);
	var evt = document.createEvent( "Event" );
	evt.initEvent( 'change', true, true );
	result.main_group.dispatchEvent( evt );

}

// This is all the messages that might be dispatched by the code
twinklewelcome.messages = {
	level1: {
		"uw-vandalism1": { 
			label:"Vandalism", 
			summary:"General note: Vandalism" 
		},
		"uw-test1": { 
			label:"Editing tests", 
			summary:"General note: Editing tests" 
		},
		"uw-delete1": { 
			label:"Page blanking, removal of content or templates", 
			summary:"General note: Page blanking, removal of content or templates" 
		},
		"uw-create1": { 
			label:"Creating inappropriate pages", 
			summary:"General note: Creating inappropriate pages" 
		},
		"uw-spam1": { 
			label:"Adding spam links", 
			summary:"General note: Adding spam links" 
		},
		"uw-advert1": { 
			label:"Using Wikipedia for advertising or promotion", 
			summary:"General note: Using Wikipedia for advertising or promotion" 
		},
		"uw-npov1": { 
			label:"Not writing from a neutral point of view", 
			summary:"General note: Not adhering to neutral point of view" 
		},
		"uw-mos1": { 
			label:"Manual of style", 
			summary:"General note: Formatting, date, language, etc (Manual of style)" 
		},
		"uw-npa1": { 
			label:"Personal attack directed at a specific editor", 
			summary:"General note: Personal attack directed at a specific editor" 
		},
		"uw-agf1": { 
			label:"Not assuming good faith", 
			summary:"General note: Not assuming good faith" 
		},
		"uw-copyright1": { 
			label:"Copyright violation", 
			summary:"General note: Violating copyright" 
		},
		"uw-error1": { 
			label:"Adding incorrect information", 
			summary:"General note: Adding incorrect information" 
		}

	},
	level2: {
		"uw-vandalism2": { 
			label:"Vandalism", 
			summary:"Caution: Vandalism" 
		},
		"uw-test2": { 
			label:"Editing tests", 
			summary:"Caution: Editing tests" 
		},
		"uw-delete2": { 
			label:"Page blanking, removal of content or templates", 
			summary:"Caution: Page blanking, removal of content or templates" 
		},
		"uw-create2": { 
			label:"Creating inappropriate pages", 
			summary:"Caution: Creating inappropriate pages" 
		},
		"uw-advert2": { 
			label:"Using Wikipedia for advertising or promotion", 
			summary:"Caution: Using Wikipedia for advertising or promotion" 
		},
		"uw-npov2": { 
			label:"Not adhering to neutral point of view", 
			summary:"Caution: Not adhering to neutral point of view" 
		},
		"uw-mos2": { 
			label:"Manual of style", 
			summary:"Caution: Formatting, date, language, etc (Manual of style)" 
		},
		"uw-npa2": { 
			label:"Personal attack directed at a specific editor", 
			summary:"Caution: Personal attack directed at a specific editor" 
		},
		"uw-agf2": { 
			label:"Not assuming good faith", 
			summary:"Caution: Not assuming good faith" 
		},
		"uw-copyright2": { 
			label:"Copyright violation", 
			summary:"Caution: Violating copyright" 
		},
		"uw-error2": { 
			label:"Adding incorrect information", 
			summary:"Caution: Adding incorrect information" 
		}

	},
	level3: {
		"uw-vandalism3": { 
			label:"Vandalism", 
			summary:"Warning: Vandalism" 
		},
		"uw-test3": { 
			label:"Editing tests", 
			summary:"Warning: Editing tests" 
		},
		"uw-delete3": { 
			label:"Page blanking, removal of content or templates", 
			summary:"Warning: Page blanking, removal of content or templates" 
		},
		"uw-create3": { 
			label:"Creating inappropriate pages", 
			summary:"Warning: Creating inappropriate pages" 
		},
		"uw-npov3": { 
			label:"Not adhering to neutral point of view", 
			summary:"Warning: Not adhering to neutral point of view" 
		},
		"uw-mos3": { 
			label:"Manual of style", 
			summary:"Warning: Formatting, date, language, etc (Manual of style)" 
		},
		"uw-npa3": { 
			label:"Personal attack directed at a specific editor", 
			summary:"Warning: Personal attack directed at a specific editor" 
		},
		"uw-agf3": { 
			label:"Not assuming good faith", 
			summary:"Warning: Not assuming good faith" 
		}
	},
	level4: {
		"uw-vandalism4": { 
			label:"Vandalism", 
			summary:"Final warning: Vandalism" 
		},
		"uw-test4": { 
			label:"Editing tests", 
			summary:"Final warning: Editing tests" 
		},
		"uw-create4": { 
			label:"Creating inappropriate pages", 
			summary:"Final warning: Creating inappropriate pages" 
		},
		"uw-npov4": { 
			label:"Not adhering to neutral point of view", 
			summary:"Final warning: Not adhering to neutral point of view" 
		},
		"uw-mos4": { 
			label:"Manual of style", 
			summary:"Final warning: Formatting, date, language, etc (Manual of style)" 
		},
		"uw-npa4": { 
			label:"Personal attack directed at a specific editor", 
			summary:"Final warning: Personal attack directed at a specific editor"
		}
	},
	level4im: {
		"uw-vandalism4im": { 
			label:"Vandalism", 
			summary:"Only warning: Vandalism" 
		},
		"uw-test4im": { 
			label:"Editing tests", 
			summary:"Only warning: Editing tests" 
		},
		"uw-npov4im": { 
			label:"Not adhering to neutral point of view", 
			summary:"Only warning: Not adhering to neutral point of view" 
		},
		"uw-mos4im": { 
			label:"Manual of style", 
			summary:"Only warning: Formatting, date, language, etc (Manual of style)" 
		},
		"uw-npa4im": { 
			label:"Personal attack directed at a specific editor", 
			summary:"Only warning: Personal attack directed at a specific editor"
		}
	},
	welcome: {
		"anon": { 
			label:"Welcomes and suggests getting username", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcome": { 
			label:"Plain text welcome", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcome2": { 
			label:"Welcome with graphic and orange background", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcomeg": { 
			label:"Welcome with blue background", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcomeq": { 
			label:"Like welcomeg but shorter", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcome-en": { 
			label:"Welcome from English Wikipedia", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcome-iw": { 
			label:"Welcome from another Wikipedia", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcomevandal": { 
			label:"Welcome with information about vandalism", 
			summary:"Welcome to the Simple English Wikipedia" 
		}
	},
	singlenotice: {
		"uw-badcat": { 
			label:"Adding incorrect categories", 
			summary:"Notice: Adding incorrect categories" 
		},
		"uw-bite": { 
			label:"\"Biting\" newcomers", 
			summary:"Notice: \"Biting\" newcomers" 
		},
		"uw-encopypaste": { 
			label:"Direct copying of article from English Wikipedia", 
			summary:"Notice: Direct copying of article from English Wikipedia" 
		},
		"uw-lang": { 
			label:"Changing between types of English without a good reason", 
			summary:"Notice: Unnecessarily changing between British and American English" 
		},
		"uw-newarticle": { 
			label:"Tips on creating new articles", 
			summary:"Notice: How to make your articles better" 
		},
		"uw-otherweb": { 
			label:"Use \"Other websites\", not \"External links\"", 
			summary:"Notice: Use \"Other websites\", not \"External links\"" 
		},
		"uw-selfrevert": { 
			label:"Undoing recent test", 
			summary:"Notice: Undoing recent test" 
		},
		"uw-simple": { 
			label:"Not making changes in simple English", 
			summary:"Notice: Not making changes in simple English" 
		},
		"uw-spellcheck": { 
			label:"Review spelling, etc.", 
			summary:"Notice: Review spelling, etc." 
		},
		"uw-subst": { 
			label:"Remember to subst: templates", 
			summary:"Notice: Remember to subst: templates" 
		},
		"uw-tilde": { 
			label:"Not signing posts", 
			summary:"Notice: Not signing posts" 
		},
		"uw-upload": { 
			label:"Image uploads not allowed in Simple English Wikipedia", 
			summary:"Notice: Image uploads not allowed in Simple English Wikipedia"
		}
	},
	singlewarn: {
		"uw-attack": { 
			label:"Creating attack pages", 
			summary:"Warning: Creating attack pages" 
		},
                "uw-disruption": { 
			label:"Project disruption", 
			summary:"Warning: Project disruption" 
		},
		"uw-qd": { 
			label:"Removing quick deletion templates from articles", 
			summary:"Warning: Removing quick deletion templates from articles"
		},
		"uw-userpage": { 
			label:"Userpage or subpage is against policy", 
			summary:"Warning: Userpage or subpage is against policy"
		},
		"cyberbully warning": { 
			label:"Cyberbullying", 
			summary:"Warning: Cyberbullying"
		}
	},
	block: {
		"uw-block1": {
			'label':"Block level 1",
			'summary':"You have been temporarily blocked"
		},
		"uw-block2": {
			'label':"Block level 2",
			'summary':"You have been blocked"
		},
		"uw-block3": {
			'label':"Block level 3",
			'summary':"You have been indefinitely blocked"
		},
		"UsernameBlocked": {
			'label':"Username block",
			'summary':"You have been blocked for violation of the [[WP:U|username policy]]"
		},
		"UsernameHardBlocked": {
			'label':"Username hard block",
			'summary':"You have been blocked for a blatant violation of the [[WP:U|username policy]]"
		},
                "openproxy": {
			'label':"Open proxy",
			'summary':"You have been blocked because this IP is an [[open proxy]]"    main_group.append( { type:'option', label:'Welcome messages', value:'welcome', selected: ( TwinkleConfig.defaultWarningGroup == 9 ) } );

	main_select.append( { type:'select', name:'sub_group', event:twinklewelcome.callback.change_subcategory } ); //Will be empty to begin with.

	form.append( {
			type:'input',
			name:'article',
			label:'Linked article',
			value:( QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '' ),
			tooltip:'An article might be linked to the notice, either it was a revert to said article that dispatched this notice. Leave empty for no article to be linked.'
		} );


	var more = form.append( { type:'field', label:'Fill in an optional personal message and hit \"Submit\"' } );
	more.append( { type:'textarea', label:'Personal message', name:'reason', tooltip:'Perhaps a personal warm welcome' } );
	more.append( { type:'submit', label:'Submit' } );
	var result = form.render();
	Window.setContent( result );
	Window.display();
	result.main_group.root = result;

	// We must init the first choice (General Note);
	var evt = document.createEvent( "Event" );
	evt.initEvent( 'change', true, true );
	result.main_group.dispatchEvent( evt );

}

// This is all the messages that might be dispatched by the code
twinklewelcome.messages = {
	welcome: {
		"anon": { 
			label:"Welcomes and suggests getting username", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcome": { 
			label:"Plain text welcome", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcome2": { 
			label:"Welcome with graphic and orange background", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcomeg": { 
			label:"Welcome with blue background", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcomeq": { 
			label:"Like welcomeg but shorter", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcome-en": { 
			label:"Welcome from English Wikipedia", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcome-iw": { 
			label:"Welcome from another Wikipedia", 
			summary:"Welcome to the Simple English Wikipedia" 
		},
		"welcomevandal": { 
			label:"Welcome with information about vandalism", 
			summary:"Welcome to the Simple English Wikipedia" 
		}
	}
};


twinklewelcome.prev_block_timer = null;
twinklewelcome.prev_article = null;
(contracted; show full)	};
	Wikipedia.actionCompleted.redirect = wgPageName;
	Wikipedia.actionCompleted.notice = "Warning complete, reloading talk page in a few seconds";
	var wikipedia_wiki = new Wikipedia.wiki( 'User talk page modification', query, twinklewelcome.callbacks.main );
	wikipedia_wiki.params = params;
	wikipedia_wiki.followRedirect = true;
	wikipedia_wiki.get();
}