မီႇတီႇယႃႇဝီႇၶီႇ:Gadget-twinklewarn.js

လုၵ်ႉတီႈ ဝီႇၶီႇပပ်ႉ မႃး
မၢႆတွင်း: ဝၢႆးသေသိမ်းပၼ်ယဝ်ႉ၊ တွၼ်ႈတႃႇ ၸဝ်ႈၵဝ်ႇ တေႁၼ်လႆႈ လွင်ႈလႅၵ်ႈလၢႆႈၼၼ်ႉ ၸဝ်ႈၵဝ်ႇတေၸၢင်ႈလႆႈလတ်းၶၢမ်ႈ ၶႅတ်ႉၶျ် တူဝ်ပိုတ်ႇဝႅပ်ႉၸဝ်ႈၵဝ်ႇယဝ်ႉ။
  • ၽွင်းမိူဝ်ႈတိုၵ်ႉၼဵၵ်း Reload တီႈ Firefox / Safari: ၼၼ်ႉ ၼဵၵ်းဝႆႉပႃး Shift ၊ဢမ်ႇၼၼ် ၼဵၵ်းပၼ် Ctrl-F5 ဢမ်ႇၼၼ် Ctrl-R (တီႈၼႂ်း Mac ၼႆ ၼဵၵ်းပၼ်⌘-R)
  • တီႈၼႂ်း Google Chrome: ၼဵၵ်းပၼ် Ctrl-Shift-R (တီႈၼႂ်း Mac ၼႆႉ ၼဵၵ်းပၼ်⌘-Shift-R )
  • ၽွင်းမိူဝ်ႈ တိုၵ်ႉၼဵၵ်း Refreshတီႈ Internet Explorer/ Edge: ၼဵၵ်းဝႆႉပၼ် Ctrl ဢမ်ႇၼၼ် ၼဵၵ်းပၼ် Ctrl-F5
  • တီႈၼႂ်း Opera: ၵႂႃႇၸူးတီႈ Menu → Settings (ပေႃးပဵၼ်တီႈၼႂ်း Mac ၸိုင် Opera → Preferences ) သေ သိုပ်ႇၵႂႃႇ Privacy & security → Clear browsing data → Cached images and files ၼၼ်ႉလႄႈ။
// If TwinkleConfig doesn't exist.
if ( window.TwinkleConfig == undefined ) {
	window.TwinkleConfig = {};
}

// what is the default main group selected when the dialog opens?
if ( TwinkleConfig.defaultWarningGroup == undefined ) {
	TwinkleConfig.defaultWarningGroup = 1;
}

// watch pages for warning and notice messages?
if ( TwinkleConfig.watchWarnings == undefined ) {
	TwinkleConfig.watchWarnings = false;
}

// blank user talk page before issuing indef block notice?
if ( TwinkleConfig.blankTalkpageOnIndefBlock == undefined ) {
	TwinkleConfig.blankTalkpageOnIndefBlock = false;
}

// append text to edit summary, "" means do nothing
if ( TwinkleConfig.summaryAd == undefined ) {
	TwinkleConfig.summaryAd = "";
}

function twinklewarn() {
	if ( mw.config.get('wgNamespaceNumber') === 3 || mw.config.get('wgCanonicalSpecialPageName') === "Contributions") {
		twAddPortletLink( twinklewarn.callback, "Warn", "tw-warn", "Warn/Notify user");
	}
}
 
if ( window.twinkleConfigExists ) {
	window.TwinkleInit = ( window.TwinkleInit || []).concat( twinklewarn ); //schedule initializer
}
 
twinklewarn.callback = function twinklewarnCallback() {
	var	Window = new SimpleWindow( 400, 225 ),
		form = new QuickForm( twinklewarn.callback.evaluate ),
		main_select, main_group, $result,
		defaultGroup = TwinkleConfig.defaultWarningGroup;

	Window.title( "Warn/Notify user" );

	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 issue.'
	});

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

	main_group.append({ type:'option', label:'Vandalism/Spam', value:'vandalism', selected: ( defaultGroup === 1 || defaultGroup < 1 || ( userIsInGroup( 'sysop' ) ? defaultGroup > 7 : defaultGroup > 6 ) ) } );
	main_group.append({ type:'option', label:'Attacks', value:'attacks', selected: ( defaultGroup === 2 ) });
	main_group.append({ type:'option', label:'Content issues', value:'content', selected: ( defaultGroup === 3 ) });
	main_group.append({ type:'option', label:'Ignoring process', value:'process', selected: ( defaultGroup === 4 ) });
	main_group.append({ type:'option', label:'Structural mistakes', value:'structure', selected: ( defaultGroup === 5 ) });
	main_group.append({ type:'option', label:'Etiquette', value:'etiquette', selected: ( defaultGroup === 6 ) });

	if ( userIsInGroup( 'sysop' ) ) {
		main_group.append({ type:'option', label:'Blocking', value:'block', selected: ( defaultGroup === 7 ) });
	}

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

	form.append({
		type:'input',
		name:'article',
		label:'Linked page',
		value:( QueryString.exists( 'vanarticle' ) ? QueryString.get( 'vanarticle' ) : '' ),
		tooltip: 'A page may be linked to this notice. Leave empty for no page to be linked.'
	});

	form.append({ type:'submit', label:'Submit' });
	$result = form.render();
	Window.content( $result ).display();
	$result.find( 'select' ).filter( '[name="main_group"]' ).change();
};

// This is all the messages that might be dispatched by the code
twinklewarn.messages = {
	vandalism: {
		"gvandalism": {
			label:"General vandalism",
			summary:"Please be constructive",
			reason:"Please be aware that some edits can be considered [[Wikibooks:Vandalism|vandalism]], use the [[Wikibooks:Sandbox|sandbox]] for any test edits you would like to make, and read the [[Wikibooks:Welcome|welcome page]] to learn more about contributing constructively to this project. Thank you."
		},
		"test": {
			label:"Editing tests",
			summary:"Please use the sandbox to test",
			reason:"Please take a look at the [[Wikibooks:Welcome|welcome page]] to learn more about contributing to this project. If you would like to experiment further, please use the [[Wikibooks:Sandbox|sandbox]] instead. Thank you."
		},
		"blanking": {
			label:"Page blanking, removal of content",
			summary:"Please add to content rather than remove it",
			reason:"It might not have been your intention, but your recent edit removed content from Wikibooks. When removing text, please specify a reason in the edit summary and discuss edits that are likely to be controversial on the page's talk page. If this was a mistake, don't worry; the text has been restored, as you can see from the page history. Take a look at the [[Wikibooks:Welcome|welcome page]] to learn more about contributing to this project, and if you would like to experiment, please use the [[Wikibooks:Sandbox|sandbox]]. Thank you."
		},
		"create": { 
			label:"Creating inappropriate pages", 
			summary:"Please create appropriate pages",
			reason:"A page you recently created may not conform to some of Wikibooks' [[Wikibooks:Policies and guidelines|guidelines]] for new pages, so it will shortly be [[Wikibooks:Deletion policy|removed]] (if it hasn't been already). Please use the [[Wikibooks:Sandbox|sandbox]] for any tests. For more information about creating books, you may want to read [[Using Wikibooks]].  Thank you."
		},
		"error": { 
			label:"Introducing deliberate factual errors", 
			summary:"Please verify the information you add",
			reason:"Your recent edit appears to have added incorrect information and has been reverted or removed. All information in this project should be verifiable in a reliable, published source. If you believe the information that you added was correct, please cite the references or sources or before making the changes, discuss them on the page's talk page. Please use the [[Wikibooks:Sandbox|sandbox]] for any tests that you wish to make. Do take a look at the [[Wikibooks:Welcome|welcome]] page if you would like to learn more about contributing to our project. Thank you."
		},
		"image": { 
			label:"Image-related vandalism", 
			summary:"Please use images appropriate in context",
			reason:"Your image was inserted successfully and has been reverted or removed. Please use the [[Wikibooks:Sandbox|sandbox]] for any other tests you want to do. Take a look at the [[Wikibooks:Welcome|welcome page]] if you would like to learn more about contributing to our project. Thank you." 
		},
		"user": { 
			label:"User page vandalism", 
			summary:"Please respect others' personal pages",
			reason:"Your recent edit to the userpage of another user may be considered vandalism. In general, it is considered polite to avoid substantially editing others' userpages without their permission. Instead, please bring the matter to their talk page and let them edit their user page themselves if they agree on a need to do so. Thank you."
		},
		"advert": { 
			label:"Using Wikibooks for advertising or promotion", 
			summary:"Please use Wikibooks to educate rather than advertise",
			reason:"Wikibooks is not a collection of links; nor should it be used as a platform for advertising or promotion, and doing so is contrary to the goals of this project. Because Wikibooks uses nofollow tags, external links do not alter search engine rankings. If you feel a link or content should be added to a page, please discuss it on the page's talk page before reinserting it. Please take a look at the [[Wikibooks:Welcome|welcome]] page to learn more about contributing to this project. Thank you."
		}
	},

	attacks: {
		"attack": { 
			label:"Personal attack directed at a specific editor", 
			summary:"Please respect others' feelings",
			reason:"We would like to remind you not to attack other editors. Please comment on the contributions and not the contributors. Take a look at the [[Wikibooks:Welcome|welcome page]] to learn more about contributing to this project. You are welcome to rephrase your comment as a [[Wikibooks:Be civil|civil criticism]] of the page or issue in question. Thank you."
		},
		"bite": { 
			label:"\"Biting\" newcomers", 
			summary:"Please be considerate of new editors",
			reason:"I noticed the message you recently left to a newcomer. Please remember: [[Wikibooks:Please do not bite the newcomers|do not bite the newcomers]]. If you see someone make a common mistake, try to politely point out what they did wrong and how to correct it. Thank you."
		},
		"agf": { 
			label:"Not assuming good faith", 
			summary:"Please assume good faith",
			reason:"Take a look at the [[Wikibooks:Welcome|welcome page]] to learn more about contributing to this project. Thank you."
		},
		"pinfo": { 
			label:"Posting others' personal information", 
			summary:"Please respect others' privacy",
			reason:"Wikibooks operates on the principle that every contributor has a right if they wish to remain completely anonymous. Posting private information about a user with the intent to annoy, threaten, or harass, specifically their (alleged) name and/or personal details, is strictly prohibited as harassment, and users who do that are often immediately blocked from editing Wikibooks. Such posting can cause offense or embarrassment to the victim of the posting, not least because it means that their name, and any personal criticism or allegations made against them can then appear on web searches. If you have posted such information, please remove it '''immediately'''. Please then follow the link to [[w:WP:RFO|this]] page and follow the instructions there, including emailing [mailto:oversight-l@lists.wikimedia.org this address]. It will then be removed from the archives of Wikibooks. ''Remember: Wikibooks' privacy policy is there to protect the privacy of every user, including'' '''you'''."
		}
	},

	content: {
		"npov": { 
			label:"Not adhering to neutral point of view", 
			summary:"Please adhere to a neutral point of view",
			reason:"One of the core policies of Wikibooks is that books should always be written from a [[Wikibooks:Neutral point of view|neutral point of view]]. Please remember to observe this important core policy. Thank you."
		},
		"nor": { 
			label:"Adding original research", 
			summary:"Please add verifiable information to books",
			reason:"We cannot accept [[WB:OR|original research]]. Original research also encompasses novel, unpublished syntheses of previously published material. Please be prepared to cite a reliable source for your information. Thank you."
		},
		"censor": { 
			label:"Censorship of material", 
			summary:"Please leave censorship to others' discretion",
			reason:"Wikibooks is [[WB:CENSOR|not censored]] to remove content that might be considered objectionable. Please do not remove or censor information that is relevant to a book. You have the option to configure Wikibooks to hide images that you may find offensive. Take a look at the [[Wikibooks:Welcome|welcome page]] to learn more about contributing to this project. Thank you."
		},
		"textbook": { 
			label:"Adding non-textbook material", 
			summary:"Please add only textbook material",
			reason:"Wikibooks is a collection of open-content textbooks.  Recent content you have added or created is not considered within the scope of the project. Please see [[WB:WIW|What is Wikibooks?]] to learn more about the kinds of materials that are acceptable at Wikibooks.  Thank you."
		},
		"english": { 
			label:"Unnecessarily changing between varieties of English", 
			summary:"Please maintain consistency",
			reason:" In a recent edit, you changed one or more words from one international variety of English to another. Because Wikibooks has readers from all over the world, our policy is to respect national varieties of English in books. For subjects exclusively related to Britain, use British English. For something related to the United States in the same way, use American English. For something related to other English-speaking countries, such as Canada, Australia, or New Zealand, use the appropriate variety of English used there. If it is an international topic, use the same form of English the original author used. In view of that, please don't change pages from one version of English to the other, even if you don't normally use the version the page is written in. Respect other people's versions of English. They in turn should respect yours. Other general guidelines on how Wikibooks books are written can be found in the [[Wikibooks:Manual of Style]]. Thank you."
		},
		"free": { 
			label:"Uploading replaceable non-free images", 
			summary:"Please use free images when available",
			reason:"We always appreciate when users upload new images, however, it appears that one or more of the images you have recently uploaded or added to an page may fail our non-free image policy. For possible reasons, please read up on our [[WB:FU|non-free image criteria]]. Please note that we take very seriously our criteria on non-free image uploads and users who repeatedly upload or misuse non-free images may be blocked from editing."
		}
	},

	process: {
		"deleted": { 
			label:"Recreating deleted pages", 
			summary:"Please respect deletion decisions",
			reason:"A tag has been placed on a page you created requesting that it be [[WB:SPEEDY|speedily deleted]] from Wikibooks, because it appears to be a repost of material that was previously deleted following a [[WB:DP|deletion process]]. If you can indicate how it is different from the previously posted material, put a note on the page's discussion page saying why this page should stay. Administrators will look at your reasoning before deciding what to do with the page. If you believe the original discussion was unjustified, please contact the administrator who deleted the page or use [[WB:RFP|request undeletion]] instead of continuing to recreate the page. Thank you."
		},
		"refactor": { 
			label:"Refactoring others' talk page comments", 
			summary:"Please respect others' comments",
			reason:"Everyone is welcome to contribute constructively to Wikibooks. However, talk pages are meant to be a record of a discussion; deleting or editing legitimate comments is considered bad practice, even if you meant well. Take a look at the [[Wikibooks:Welcome|welcome page]] to learn more about contributing to this project. Thank you."
		},
		"rmrfd": { 
			label:"Removing RFD templates or refactoring RFD discussion", 
			summary:"Please debate the merits of a book",
			reason:"Please do not remove [[Template:Rfd|requests for deletion notices]] from pages, or remove other people's comments in [[WB:RFD|requests for deletion debates]]. Otherwise, it may be difficult to create consensus. If you oppose the deletion of a page, please comment at the respective page instead. Thank you."
		},
		"rmspeedy": { 
			label:"Removing speedy deletion templates", 
			summary:"Please discuss possible deletion on the talk page",
			reason:"It might not have been your intention, but you removed a [[WB:SPEEDY|speedy deletion]] tag from a page you have created yourself. If you do not believe the page should be deleted, you can make your case on the page's talk page. Administrators will look at your reasoning before deciding what to do with the page. Thank you."
		},
		"rmmaint": { 
			label:"Removal of maintenance templates", 
			summary:"Please discuss issues on talk pages",
			reason:" It might not have been your intention, but your recent edit removed maintenance templates from Wikibooks. When removing maintenance templates, please be sure to either resolve the problem that the template refers to, or give a valid reason for the removal in the edit summary. If this was a mistake, don't worry, as your removal of this template has been reverted. Take a look at the [[Wikibooks:Welcome|welcome page]] to learn more about contributing to this project, and if you would like to experiment, please use the [[Wikibooks:Sandbox|sandbox]]. Thank you."
		},
		"consensus": { 
			label:"We use consensus, not voting", 
			summary:"Please provide an explanation of your position",
			reason:"Thank you for your comments. Please note that on Wikibooks, consensus is determined by discussion, not voting, and it is the quality of arguments that counts, not the number of people supporting a position. Consider reading about the [[WB:DP|deletion policy]] for a brief overview for the deletion process, and how we decide what to keep and what to delete. We hope you decide to stay and contribute even more. Thank you."
		},
		"warring": { 
			label:"Edit warring", 
			summary:"Please find consensus on changes",
			reason:"You currently appear to be engaged in an edit war. Users who perform several reversions in content disputes may be blocked for edit warring. When in dispute with another editor you should first try to discuss controversial changes to work towards wording and content that gains a consensus among editors. Should that prove unsuccessful, you are encouraged to seek [[Wikibooks:Resolving disputes|dispute resolution]], and in some cases it may be appropriate to [[WB:AA|request page protection]]. If the edit warring continues, you may be [[Wikibooks:Blocking policy|blocked]] from editing without further notice."
		}
	},

	structure: {
		"naming": { 
			label:"Naming policy", 
			summary:"Please follow the naming policy",
			reason:"When creating new pages, please be sure that they conform to Wikibooks' [[Wikibooks:Naming policy|naming policy]].  Doing so makes navigation within and addition to a book easier for other contributors.  Thank you."
		},
		"paste": { 
			label:"Cut and paste moves", 
			summary:"Please move pages correctly",
			reason:" It appears that you recently tried to give a page a different title by copying its content and pasting either the same content, or an edited version of it, into another page with a different name. This is known as a \"cut and paste move\", and it is undesirable because it splits the [[Help:Tracking changes#Page history|page history]], which is needed for attribution and various other purposes. Instead, the software used by Wikibooks has a feature that allows pages to be moved to a new title together with their edit history. In most cases, once your account is four days old, you should be able to move a page yourself using the \"Move\" tab at the top of the page. This both preserves the page history intact and automatically creates a redirect from the old title to the new. If you cannot perform a particular page move yourself this way (e.g. because a page already exists at the target title), please [[WB:AA|request assistance from an administrator]] in doing so. Thank you."
		},
		"2redirect": { 
			label:"Creating double redirects through page moves", 
			summary:"Please correct double redirects",
			reason:"When moving pages, please remember to fix any double redirects. These can create slow, unpleasant experiences for the reader, waste server resources, and make the navigational structure of the site confusing. Thank you."
		},
		"categories": { 
			label:"Adding incorrect categories", 
			summary:"Please file books properly",
			reason:"Before adding a category to a book, please make sure that the subject of the book really belongs in the category that you specified according to Wikibooks' [[Wikibooks:Categories|categorization guidelines]]. Categories may be removed if they are deemed incorrect for the subject matter. Thank you."
		}
	},

	etiquette: {
		"own": { 
			label:"Owning books", 
			summary:"Please collaborate with others",
			reason:"Everyone is welcome to contribute constructively to Wikibooks. However, please know that editors do not own books and should respect the work of their fellow contributors. If you create or edit an page, know that others are free to change its content. Take a look at the [[Wikibooks:Welcome|welcome page]] to learn more about contributing to this project. Thank you."
		},
		"booktalk": { 
			label:"Talk in book", 
			summary:"Please use talk pages for discussion",
			reason:"I noticed that you recently added commentary to a page. While Wikibooks welcomes editors' opinions on a page and how it could be changed, these comments are more appropriate for the book's accompanying talk pages. If you post your comments there, other editors working on the same book will notice and respond to them and your comments will not disrupt the flow of the content. However, keep in mind that even on talk pages of a book, you should limit your discussion to improving the content. Book talk pages are not the place to discuss opinions of the subject matter, nor are such pages a forum. Thank you."
		},
		"booksig": { 
			label:"Adding signatures to book content", 
			summary:"Please note that your contributions are recorded",
			reason:"I've noticed that you have been adding your signature to some of your book contributions. This is a simple mistake to make and is easy to correct. For future reference, the need to associate edits with users is taken care of by an page's [[Help:Tracking changes#Page history|edit history]]. Therefore, you should use your signature only when contributing to talk pages, the [[Wikibooks:Reading room|reading room]], or other such discussion pages. Again, thank you for contributing, and enjoy your Wikibooks experience! Thank you."
		},
		"foreign": { 
			label:"Not communicating in English", 
			summary:"Please communicate in English",
			reason:"I noticed that you have posted comments in a language other than English. When on the English-language Wikibooks, please always use English, no matter to whom you address your comments. This is so that comments may be comprehensible to the community at large. If the use of another language is unavoidable, please provide a translation of the comments. Thank you."
		},
		"canvass": { 
			label:"Canvassing", 
			summary:"Please seek support in the proper forum",
			reason:"It appears that you have been canvassing—leaving messages on others' talk pages to notify them of an ongoing community decision, debate, or vote. While friendly notices are allowed, they should be limited and nonpartisan in distribution and should reflect a [[WB:NPOV|neutral point of view]]. Please do not post notices which are indiscriminately cross-posted, which espouse a certain point of view or side of a debate, or which are selectively sent only to those who are believed to hold the same opinion as you. Remember to respect Wikibooks' principle of consensus-building by allowing decisions to reflect the prevailing opinion among the community at large. Thank you."
		},
		"preview": { 
			label:"Use preview button to avoid mistakes", 
			summary:"Please preview your contributions",
			reason:"In the future, it is recommended that you use the [[Help:Show preview|preview]] button before you save; this helps you find any errors you have made, reduces edit conflicts, and prevents clogging up recent changes and the page history. Thank you."
		},
		"minor": { 
			label:"Incorrect use of minor edits check box", 
			summary:"Please only mark minor edits as minor",
			reason:"Please remember to mark your edits as \"minor\" only if they truly are [[Help:Editing#Minor_edit|minor edits]]. A minor edit is one that the editor believes requires no review and could never be the subject of a dispute. Minor edits consist of things such as typographical corrections, formatting changes, or rearrangement of text without modification of content. Additionally, the reversion of clear-cut [[Wikibooks:Vandalism|vandalism]] and test edits may be labeled \"minor\". Thank you."
		},
		"summary": { 
			label:"Not using edit summary", 
			summary:"Please provide summaries of changes",
			reason:"When you make a change to a page, please provide an [[Help:Editing#Edit summary|edit summary]] for your edits. Doing so helps everyone to understand the intention of your edit. It is also helpful to users reading the edit history of the page. Thank you."
		},
		"bsummary": { 
			label:"Using inaccurate or inappropriate edit summaries", 
			summary:"Please use accurate edit summaries",
			reason:"Constructive contributions to Wikibooks are appreciated, but a recent edit of yours has an [[Help:Editing#Edit summary|edit summary]] that appears to be inaccurate or inappropriate. Please use edit summaries that accurately tell other editors what you did, and feel free to use the [[Wikibooks:Sandbox|sandbox]] for any tests you may want to do. Thank you."
		},
		"subst": { 
			label:"Not substituting talk page templates", 
			summary:"Please subst: talk page templates",
			reason:"When using certain templates on talk pages, don't forget to substitute with text by adding '''subst:''' to the template tag. For example, use <nowiki>{{subst:bigwelcome}}</nowiki> instead of <nowiki>{{bigwelcome}}</nowiki>. This reduces server load and prevents accidental blanking of the template. Thank you"
		},
		"tempabuse": { 
			label:"Improper use of warning or blocking template", 
			summary:"Please use notification templates correctly",
			reason:"A recent edit that you made has been reverted or removed because it was a misuse of a warning or blocking template. Please use the [[Template:Template sandbox|template sandbox]] for any tests you may want to do, or take a look at our [[Wikibooks:Welcome|welcome page]] to learn more about contributing to the project. Thank you."
		}
	},

	block: {
		"vandal": {
			label:"Vandalism",
			summary:"You have been blocked from editing for persistent vandalism",
			reason:"your persistent vandalism"
		},
		"blanker": {
			label:"Page/section blanking",
			summary:"You have been blocked from editing for continued removal of material",
			reason:"your continued removal of material from pages"
		},
		"creator": {
			label:"Creating inappropriate pages",
			summary:"You have been blocked from editing for creating inappropriate pages",
			reason:"your creation of inappropriate pages"
		},
		"harasser": {
			label:"Harassment",
			summary:"You have been blocked from editing for attempting to harass other users",
			reason:"attempts to troll, disrupt, or harass other users"
		},
		"soldier": {
			label:"Edit warring",
			summary:"You have been blocked from editing to prevent further disruption caused by your engagement in an edit war",
			reason:"disruption caused by your engagement in an edit war"
		},
		"spammer": {
			label:"Spam/Advertising",
			summary:"You have been blocked from editing for advertising or self-promotion",
			reason:"your addition of spam links, self-promotion, or advertising"
		},
		"zombie": {
			label:"Open proxy/zombie",
			summary:"You have been blocked from editing because your computer has been compromised",
			reason:"editing that suggests your computer is infected with malware or a scan that shows this [[w:IP address|IP address]] is an [[w:proxy server|open proxy]]"
		},
		"checkuser": {
			label:"CheckUser",
			summary:"You have been blocked from editing due to [[m:CheckUser policy|CheckUser]] evidence"
		}
	}
};
 
twinklewarn.prev_block_timer = null;
twinklewarn.prev_article = null;
 
twinklewarn.callback.change_category = function twinklewarnCallbackChangeCategory(e) {
	var	$select = $( e.target ),
		value = $select.val(),
		$form = e.target.form ? $( e.target.form ) : $select.closest( 'form' ),
		$subgroup = $form.find( 'select' ).filter( '[name="sub_group"]' ),
		$block, $page,
		messages = twinklewarn.messages[ value ];

	$subgroup.empty();
	$subgroup.data( 'main_group', value );

	for ( var i in messages ) {
		$subgroup.append( QuickForm.element({ type: 'option', label: messages[i].label, value: i }).render() );
	}
 
	if ( value === 'block' ) {
		var more = new QuickForm.element( {
			type: 'input',
			name: 'block_timer',
			label: 'Period of blocking: ',
			tooltip: 'The period the blocking is due for, for example 24 hours, 2 weeks, indefinite etc...'
		});

		$form.append( more.render() );
		$block = $form.find( 'input' ).filter( '[name="block_timer"]' );

		if ( twinklewarn.prev_block_timer !== null ) {
			$block.val( twinklewarn.prev_block_timer );
			twinklewarn.prev_block_timer = null;
		}		
		if ( twinklewarn.prev_article === null ) {
			twinklewarn.prev_article = $form.find( '[name="article"]' ).val();
		}

		$form.find( 'input' ).filter( '[name="article"]' ).prop( 'disabled', true ).val( '' );
	} else {
		$block = $form.find( 'input' ).filter( '[name="block_timer"]' );

		if ( !$block.length ) {
			return;
		}

		if ( !$block.prop( 'disabled' ) && twinklewarn.prev_block_timer === null ) {
			twinklewarn.prev_block_timer = $block.val();
		}

		$block.parent().remove();
		$page = $form.find( 'input' ).filter( '[name="article"]' );

		if ( $page.prop( 'disabled' ) && twinklewarn.prev_article !== null ) {
			$page.val( twinklewarn.prev_article );
			twinklewarn.prev_article = null;
		}

		$page.prop( 'disabled', false );
	}
};

twinklewarn.callback.change_subcategory = function twinklewarnCallbackChangeSubcategory(e) {
	var	$sub_group = $( e.target ),
		main_group = $sub_group.data( 'main_group' ),
		value = $sub_group.val(),
		$block = $sub_group.closest( 'form' ).find( 'input' ).filter( '[name="block_timer"]' );

	if ( main_group === 'block' ) {
		if ( value === 'checkuser' ) {
			if ( twinklewarn.prev_block_timer === null ) {
				twinklewarn.prev_block_timer = $block.val();
			}
			$block.prop( 'disabled', true );
		} else if ( $block.prop( 'disabled' ) ) {
			if ( twinklewarn.prev_block_timer !== null ) {
				$block.val( twinklewarn.prev_block_timer );
				twinklewarn.prev_block_timer = null;
			}
			$block.prop( 'disabled', false );
		}
	}
};

twinklewarn.callbacks = {
	main: function( self ) {
		var	form = self.responseXML.getElementById( 'editform' ),
			text = form.wpTextbox1.value,
			history_re = /\<\!\-\-\ Template\:(please\ .*?)\ \-\-\>.*?(\d{1,2}:\d{1,2}, \d{1,2} \w+ \d{4}) \(UTC\)/g,
			history = {},
			latest = { date:new Date( 0 ), type:'' },
			date = new Date(),
			current;
 
		while ( ( current = history_re.exec( text ) ) != undefined ) {
			var current_date = new Date( current[2] + ' UTC' );
			if ( !( current[1] in history ) ||  history[ current[1] ] < current_date ) {
				history[ current[1] ] = current_date;
			}
			if ( current_date > latest.date ) {
				latest.date = current_date;
				latest.type = current[1];
			}
		}
 
		if ( self.params.sub_group in history ) {
			var temp_time = new Date( history[ self.params.sub_group ] );
			temp_time.setUTCHours( temp_time.getUTCHours() + 24 );
 
			if ( temp_time > date ) {
				Status.info( 'Info', "an identical " + self.params.sub_group + " has been issued in the last 24 hours" );
				if ( !confirm( "Would you still like to add a warning/notice?" ) ) {
					self.statelem.info( 'aborted per user request' );
					return;
				}
			}
		}
 
		latest.date.setUTCMinutes( latest.date.getUTCMinutes() + 1 ); // after long debate, one minute is max
 
		if ( latest.date > date ) {
			Status.info('Info', "a " + latest.type + " has been issued in the last minute" );
			if ( !confirm( "Would you still like to add a warning/notice?" ) ) {
				self.statelem.info( 'aborted per user request' );
				return;
			}
		}
 
		var mainheaderRe = /==+\\s*Warnings\\s*==+/;
		var headerRe = new RegExp( "^==+\\s*(?:" + date.getUTCMonthName() + '|' + date.getUTCMonthNameAbbrev() +  ")\\s+" + 
			date.getUTCFullYear() + "\\s*==+", 'm' );
 
		if ( text.length > 0 ) {
			text += "\n";
		}
 
		switch ( self.params.main_group ) {
			case 'block': {
				var article = '', time = null;
				if ( TwinkleConfig.blankTalkpageOnIndefBlock && ( /indef|\*|max/.exec( self.params.block_timer ) ) ) {
					Status.info( 'Info', 'Blanking talk page per preferences and creating a new level 2 heading for the date' );
					text = "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n";
				} else if ( !headerRe.exec( text ) ) {
					Status.info( 'Info', 'Will create a new level 2 heading for the date, as none was found for this month' );
					text += "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n";
				}
 
				if ( /indef|\*|max/.exec( self.params.block_timer ) ) {
					time = '';
				} else {
					time = '|time=' + self.params.block_timer;
				}
 
				if ( self.params.sub_group == 'checkuser' ) {
					text += "\{\{checkuserblock|sig=\~\~\~\~\}\}";				
				} else {
					text += "\{\{subst:blocked" + time + '|reason=' + self.params.reason + "|sig=true\}\}";
				}
				break;
			}
			case 'vandalism': {
				if ( !headerRe.exec( text ) ) {
					Status.info( 'Info', 'Will create a new level 2 heading for the date, as none was found for this month' );
					text += "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n";
				}
				text += "\{\{subst:please help" + ( self.params.article ? '|1=' + self.params.article : '' ) + "\}\} " + self.params.reason + " \~\~\~\~";
				break;
			}
			case 'attacks': {
				if ( !headerRe.exec( text ) ) {
					Status.info( 'Info', 'Will create a new level 2 heading for the date, as none was found for this month' );
					text += "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n";
				}
				text += "\{\{subst:please agf" + ( self.params.article ? '|1=' + self.params.article : '' ) + "\}\} " + self.params.reason + " \~\~\~\~";
				break;
			}
			default: {
				if ( !headerRe.exec( text ) ) {
					Status.info( 'Info', 'Will create a new level 2 heading for the date, as none was found for this month' );
					text += "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n";
				}
				text += "\{\{subst:please learn" + ( self.params.article ? '|1=' + self.params.article : '' ) + "\}\} " + self.params.reason + " \~\~\~\~";
				break;
			}
		}
 
		var postData = {
			'wpMinoredit': form.wpMinoredit.checked ? 1 : undefined,
			'wpWatchthis': (form.wpWatchthis.checked || TwinkleConfig.watchWarnings) ? 1 : undefined,
			'wpStarttime': form.wpStarttime.value,
			'wpEdittime': form.wpEdittime.value,
			'wpAutoSummary': form.wpAutoSummary.value,
			'wpEditToken': form.wpEditToken.value,
			'wpSection': '',
			'wpSummary': twinklewarn.messages[self.params.main_group][self.params.sub_group].summary + ( self.params.article ? ' on [[' + self.params.article + ']]'  : '' ) + '. ' + TwinkleConfig.summaryAd,
			'wpTextbox1': text
		};
 
		self.post( postData );
	}
};

twinklewarn.callback.evaluate = function twinklewarnCallbackEvaluate(e) {
	// Grab all the values provided by the form
 
	var params = {
		reason: twinklewarn.messages[e.target.form.main_group.value][e.target.form.sub_group.value].reason,
		main_group: e.target.form.main_group.value,
		sub_group: e.target.form.sub_group.value,
		article: e.target.form.article.value.replace( /^(File|Category):/i, ':$1:' ),
		block_timer: e.target.form.block_timer ? e.target.block_timer.value : null
	},

	pagename = mw.config.get( 'wgPageName' ),
	query;

	Status.init( e.target );

	if ( pagename === "Special:Contributions" ) {
		pagename = $( 'input' ).filter( '[name="target"]' ).val();
		if ( !pagename ) {
			return;
		}
		pagename = "User talk:" + pagename;
	}

	query = { 
		'title': pagename, 
		'action': 'submit'
	};

	Wikipedia.actionCompleted.redirect = pagename;
	Wikipedia.actionCompleted.notice = "Warning complete, reloading talk page in a few seconds";
	var wikipedia_wiki = new Wikipedia.wiki( 'User talk page modification', query, twinklewarn.callbacks.main );
	wikipedia_wiki.params = params;
	wikipedia_wiki.followRedirect = true;
	wikipedia_wiki.get();
};