MediaWiki:Gadget-twinklewarn.js

//

(function($){

/* **************************************** *** twinklewarn.js: Warn module **************************************** * Mode of invocation:    Tab ("Warn") * Active on:             User (talk) pages and (deleted) Contributions * Config directives in:  TwinkleConfig */

Twinkle.warn = function twinklewarn { if( mw.config.get( 'wgRelevantUserName' ) ) { Twinkle.addPortletLink( Twinkle.warn.callback, "Warn", "tw-warn", "Warn/notify user" ); if (Twinkle.getPref('autoMenuAfterRollback') && mw.config.get('wgNamespaceNumber') === 3 && mw.util.getParamValue('vanarticle') && !mw.util.getParamValue('friendlywelcome')) { Twinkle.warn.callback; }	}

// Modify URL of talk page on rollback success pages, makes use of a	// custom message box in MediaWiki:Rollback-success if( mw.config.get('wgAction') === 'rollback' ) { var $vandalTalkLink = $("#mw-rollback-success").find(".mw-usertoollinks a").first; if ( $vandalTalkLink.length ) { $vandalTalkLink.css("font-weight", "bold"); $vandalTalkLink.wrapInner($(" ").attr("title", "If appropriate, you can use Twinkle to warn the user about their edits to this page."));

var extraParam = "vanarticle=" + mw.util.rawurlencode(Morebits.pageNameNorm); var href = $vandalTalkLink.attr("href"); if (href.indexOf("?") === -1) { $vandalTalkLink.attr("href", href + "?" + extraParam); } else { $vandalTalkLink.attr("href", href + "&" + extraParam); }		}	} };

Twinkle.warn.callback = function twinklewarnCallback { if( mw.config.get( 'wgRelevantUserName' ) === mw.config.get( 'wgUserName' ) &&			!confirm( 'You are about to warn yourself! Are you sure you want to proceed?' ) ) { return; }

var Window = new Morebits.simpleWindow( 600, 440 ); Window.setTitle( "Warn/notify user" ); Window.setScriptName( "Twinkle" ); Window.addFooterLink( "Choosing a warning level", "WP:UWUL#Levels" ); Window.addFooterLink( "Twinkle help", "WP:TW/DOC#warn" );

var form = new Morebits.quickForm( Twinkle.warn.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 issue.'		} );

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

var defaultGroup = parseInt(Twinkle.getPref('defaultWarningGroup'), 10); main_group.append( { type: 'option', label: '1: General note', value: 'level1', selected: ( defaultGroup === 1 || defaultGroup < 1 || ( Morebits.userIsInGroup( 'sysop' ) ? defaultGroup > 8 : defaultGroup > 7 ) ) } ); main_group.append( { type: 'option', label: '2: Caution', value: 'level2', selected: ( defaultGroup === 2 ) } ); main_group.append( { type: 'option', label: '3: Warning', value: 'level3', selected: ( defaultGroup === 3 ) } ); main_group.append( { type: 'option', label: '4: Final warning', value: 'level4', selected: ( defaultGroup === 4 ) } ); main_group.append( { type: 'option', label: '4im: Only warning', value: 'level4im', selected: ( defaultGroup === 5 ) } ); main_group.append( { type: 'option', label: 'Single-issue notices', value: 'singlenotice', selected: ( defaultGroup === 6 ) } ); main_group.append( { type: 'option', label: 'Single-issue warnings', value: 'singlewarn', selected: ( defaultGroup === 7 ) } ); if( Twinkle.getPref( 'customWarningList' ).length ) { main_group.append( { type: 'option', label: 'Custom warnings', value: 'custom', selected: ( defaultGroup === 9 ) } ); }

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

form.append( {			type: 'input',			name: 'article',			label: 'Linked article',			value:( Morebits.queryString.exists( 'vanarticle' ) ? Morebits.queryString.get( 'vanarticle' ) : '' ),			tooltip: 'An article can be linked within the notice, perhaps because 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', name: 'reasonGroup', label: 'Warning information' } ); more.append( { type: 'textarea', label: 'Optional message:', name: 'reason', tooltip: 'Perhaps a reason, or that a more detailed notice must be appended' } );

var previewlink = document.createElement( 'a' ); $(previewlink).click(function{		Twinkle.warn.callbacks.preview(result); // |result| is defined below	}); previewlink.style.cursor = "pointer"; previewlink.textContent = 'Preview'; more.append( { type: 'div', id: 'warningpreview', label: [ previewlink ] } ); more.append( { type: 'div', id: 'twinklewarn-previewbox', style: 'display: none' } );

more.append( { type: 'submit', label: 'Submit' } );

var result = form.render; Window.setContent( result ); Window.display; result.main_group.root = result; result.previewer = new Morebits.wiki.preview($(result).find('div#twinklewarn-previewbox').last[0]);

// 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 // Each of the individual templates require the following information: //  label (required): A short description displayed in the dialog //  summary (required): The edit summary used. If an article name is entered, the summary is postfixed with "on article", and it is always postfixed with ". $summaryAd" //  suppressArticleInSummary (optional): Set to true to suppress showing the article name in the edit summary. Useful if the warning relates to attack pages, or some such. Twinkle.warn.messages = { level1: { "Common warnings": { "uw-vandalism1": { label: "Vandalism", summary: "General note: Unconstructive editing" },			"uw-disruptive1": { label: "Disruptive editing", summary: "General note: Unconstructive editing" },			"uw-test1": { label: "Editing tests", summary: "General note: Editing tests" },			"uw-remove1": { label: "Removal of content, blanking", summary: "General note: Removal of content, blanking" }		},		"Behavior in articles": { "uw-cat1": { label: "Adding inappropriate categories", summary: "General note: Adding inappropriate categories" },			"uw-false1": { label: "Introducing deliberate factual errors", summary: "General note: Introducing incorrect information" },			"uw-fanoncanon1": { label: "Adding fanon to canon articles", summary: "General note: Adding fanon to canon articles" },			"uw-fanon1": { label: "Editing someone else's fanon", summary: "General note: Editing someone else's fanon" },		},		"Behavior towards other editors": { "uw-agf1": { label: "Not assuming good faith", summary: "General note: Not assuming good faith" },			"uw-npa1": { label: "Making personal attacks", summary: "General note: Personal attack directed at a specific editor" },		},		"Promotions and spam": { "uw-promo1": { label: "Using The Sims Wiki for advertising or promotion", summary: "General note: Using The Sims Wiki for advertising or promotion" },			"uw-spam1": { label: "Adding inappropriate external links", summary: "General note: Adding inappropriate external links" }		},		"Unaccepted practices": { "uw-move1": { label: "Moving pages inappropriately", summary: "General note: Moving pages against conventions or consensus" },			"uw-create1": { label: "Creating inappropriate pages", summary: "General note: Creating inappropriate pages" },			"uw-upload1": { label: "Uploading inappropriate files", summary: "General note: Uploading inappropriate files" },			"uw-comment1": { label: "Leaving inappropriate comments", summary: "General note: Leaving inappropriate comments" }		}	},

level2: { "Common warnings": { "uw-vandalism2": { label: "Vandalism", summary: "Caution: Unconstructive editing" },			"uw-disruptive2": { label: "Disruptive editing", summary: "Caution: Unconstructive editing" },			"uw-test2": { label: "Editing tests", summary: "Caution: Editing tests" },			"uw-remove2": { label: "Removal of content, blanking", summary: "Caution: Removal of content, blanking" }		},		"Behavior in articles": { "uw-cat2": { label: "Adding inappropriate categories", summary: "Caution: Adding inappropriate categories" },			"uw-false2": { label: "Introducing deliberate factual errors", summary: "Caution: Introducing incorrect information" },			"uw-fanoncanon2": { label: "Adding fanon to canon articles", summary: "Caution: Adding fanon to canon articles" },			"uw-fanon2": { label: "Editing someone else's fanon", summary: "Caution: Editing someone else's fanon" },		},		"Behavior towards other editors": { "uw-agf2": { label: "Not assuming good faith", summary: "Caution: Not assuming good faith" },			"uw-npa2": { label: "Making personal attacks", summary: "Caution: Personal attack directed at a specific editor" },		},		"Promotions and spam": { "uw-promo2": { label: "Using The Sims Wiki for advertising or promotion", summary: "Caution: Using The Sims Wiki for advertising or promotion" },			"uw-spam2": { label: "Adding inappropriate external links", summary: "Caution: Adding inappropriate external links" }		},		"Unaccepted practices": { "uw-move2": { label: "Moving pages inappropriately", summary: "Caution: Moving pages against conventions or consensus" },			"uw-create2": { label: "Creating inappropriate pages", summary: "Caution: Creating inappropriate pages" },			"uw-upload2": { label: "Uploading inappropriate files", summary: "Caution: Uploading inappropriate files" },			"uw-comment2": { label: "Leaving inappropriate comments", summary: "Caution: Leaving inappropriate comments" },			"uw-attempt2": { label: "Triggering the edit filter", summary: "Caution: Triggering the edit filter" }		}	},

level3: { "Common warnings": { "uw-vandalism3": { label: "Vandalism", summary: "Warning: Vandalism" },			"uw-disruptive3": { label: "Disruptive editing", summary: "Warning: Disruptive editing" },			"uw-test3": { label: "Editing tests", summary: "Warning: Editing tests" },			"uw-remove3": { label: "Removal of content, blanking", summary: "Warning: Removal of content, blanking" }		},		"Behavior in articles": { "uw-cat3": { label: "Adding inappropriate categories", summary: "Warning: Adding inappropriate categories" },			"uw-false3": { label: "Introducing deliberate factual errors", summary: "Warning: Introducing incorrect information" },			"uw-fanoncanon3": { label: "Adding fanon to canon articles", summary: "Warning: Adding fanon to canon articles" },			"uw-fanon3": { label: "Editing someone else's fanon", summary: "Warning: Editing someone else's fanon" },		},		"Behavior towards other editors": { "uw-agf3": { label: "Not assuming good faith", summary: "Warning: Failing to assume good faith" },			"uw-npa3": { label: "Making personal attacks", summary: "Warning: Making personal attacks" },		},		"Promotions and spam": { "uw-promo3": { label: "Using The Sims Wiki for advertising or promotion", summary: "Warning: Using The Sims Wiki for advertising or promotion" },			"uw-spam3": { label: "Adding inappropriate external links", summary: "Warning: Adding spam links" }		},		"Unaccepted practices": { "uw-move3": { label: "Moving pages inappropriately", summary: "Warning: Moving pages inappropriately" },			"uw-create3": { label: "Creating inappropriate pages", summary: "Warning: Creating inappropriate pages" },			"uw-upload3": { label: "Uploading inappropriate files", summary: "Warning: Uploading inappropriate files" },			"uw-comment3": { label: "Leaving inappropriate comments", summary: "Warning: Leaving inappropriate comments" },			"uw-attempt3": { label: "Triggering the edit filter", summary: "Warning: Triggering the edit filter" }		}	},

level4: { "Common warnings": { "uw-vandalism4": { label: "Vandalism", summary: "Final warning: Vandalism" },			"uw-generic4": { label: "Generic warning (for template series missing level 4)", summary: "Final warning notice" },			},			"uw-remove4": { label: "Removal of content, blanking", summary: "Final warning: Removal of content, blanking" }		},		"Behavior in articles": { "uw-cat4": { label: "Adding inappropriate categories", summary: "Final warning: Adding inappropriate categories" },			"uw-false4": { label: "Introducing deliberate factual errors", summary: "Warning: Introducing incorrect information" },			"uw-fanoncanon4": { label: "Adding fanon to canon articles", summary: "Final warning: Adding fanon to canon articles" },			"uw-fanon4": { label: "Editing someone else's fanon", summary: "Final warning: Editing someone else's fanon" },		},		"Behavior towards other editors": { "uw-npa4": { label: "Making personal attacks", summary: "Final warning: Making personal attacks" },		},		"Promotions and spam": { "uw-promo4": { label: "Using The Sims Wiki for advertising or promotion", summary: "Final warning: Using The Sims Wiki for advertising or promotion" },			"uw-spam4": { label: "Adding inappropriate external links", summary: "Final warning: Adding spam links" }		},		"Unaccepted practices": { "uw-move4": { label: "Moving pages inappropriately", summary: "Final warning: Moving pages inappropriately" },			"uw-create4": { label: "Creating inappropriate pages", summary: "Final warning: Creating inappropriate pages" },			"uw-upload4": { label: "Uploading inappropriate files", summary: "Final warning: Uploading inappropriate files" },			"uw-comment4": { label: "Leaving inappropriate comments", summary: "Final warning: Leaving inappropriate comments" },			"uw-attempt4": { label: "Triggering the edit filter", summary: "Final warning: Triggering the edit filter" }		}	},

level4im: { "Common warnings": { "uw-vandalism4im": { label: "Vandalism", summary: "Only warning: Vandalism" },		},		"Behavior towards other editors": { "uw-npa4im": { label: "Making personal attacks", summary: "Only warning: Making personal attacks" },		},		"Unaccepted practices": { "uw-move4im": { label: "Moving pages inappropriately", summary: "Only warning: Moving pages inappropriately" },			"uw-create4im": { label: "Creating inappropriate pages", summary: "Only warning: Creating inappropriate pages" },			"uw-upload4im": { label: "Uploading inappropriate files", summary: "Only warning: Uploading inappropriate files" },			"uw-comment4im": { label: "Leaving inappropriate comments", summary: "Only warning: Leaving inappropriate comments" },		}	},

singlenotice: { "selfrevert": { label: "Experimenting in articles and reverting self tests", summary: "Notice: Making and reverting self tests" },		"signplease": { label: "Not signing posts", summary: "Notice: Not signing posts" },		"notaddingproperty": { label: "Not adding tags", summary: "Notice: Not adding tags to fanon" }	},

singlewarn: { "uw-3rr": { label: "Violating the three-revert rule (softer wording)", summary: "Warning: Violating the three-revert rule" },		"uw-ew": { label: "Edit warring", summary: "Warning: Edit warring" },		"uw-sock-agf": { label: "Using multiple accounts (softer wording)", summary: "Warning: Using multiple accounts" }		"uw-sock": { label: "Sockpuppetry", summary: "Warning: Abusing multiple accounts" }	} };

Twinkle.warn.prev_article = null; Twinkle.warn.prev_reason = null;

Twinkle.warn.callback.change_category = function twinklewarnCallbackChangeCategory(e) { var value = e.target.value; var sub_group = e.target.root.sub_group; sub_group.main_group = value; var old_subvalue = sub_group.value; var old_subvalue_re; if( old_subvalue ) { old_subvalue = old_subvalue.replace(/\d*(im)?$/, '' ); old_subvalue_re = new RegExp( mw.RegExp.escape( old_subvalue ) + "(\\d*(?:im)?)$" ); }

while( sub_group.hasChildNodes ){ sub_group.removeChild( sub_group.firstChild ); }

// worker function to create the combo box entries var createEntries = function( contents, container, wrapInOptgroup ) { // due to an apparent iOS bug, we have to add an option-group to prevent truncation of text // (search WT:TW archives for "Problem selecting warnings on an iPhone") if ( wrapInOptgroup && $.client.profile.platform === "iphone" ) { var wrapperOptgroup = new Morebits.quickForm.element( {				type: 'optgroup',				label: 'Available templates'			} ); wrapperOptgroup = wrapperOptgroup.render; container.appendChild( wrapperOptgroup ); container = wrapperOptgroup; }

$.each( contents, function( itemKey, itemProperties ) {			var key = (typeof itemKey === "string") ? itemKey : itemProperties.value;

var selected = false; if( old_subvalue && old_subvalue_re.test( key ) ) { selected = true; }

// Slice out leading uw- from the menu display var elem = new Morebits.quickForm.element( {				type: 'option',				label: (value === 'custom' ? "" : key.slice(3)) + ": " + itemProperties.label,				value: key,				selected: selected			} ); var elemRendered = container.appendChild( elem.render ); $(elemRendered).data("messageData", itemProperties); } );	};

if( value === "singlenotice" || value === "singlewarn" ) { // no categories, just create the options right away createEntries( Twinkle.warn.messages[ value ], sub_group, true ); } else if( value === "custom" ) { createEntries( Twinkle.getPref("customWarningList"), sub_group, true ); } else { // create the option-groups $.each( Twinkle.warn.messages[ value ], function( groupLabel, groupContents ) {			var optgroup = new Morebits.quickForm.element( { type: 'optgroup', label: groupLabel } );			optgroup = optgroup.render;			sub_group.appendChild( optgroup );			// create the options			createEntries( groupContents, optgroup, false );		} ); }

// clear overridden label on article textbox Morebits.quickForm.setElementTooltipVisibility(e.target.root.article, true); Morebits.quickForm.resetElementLabel(e.target.root.article); // hide the big red notice $("#tw-warn-red-notice").remove; // add custom label.redWarning Twinkle.warn.callback.change_subcategory(e); };

Twinkle.warn.callback.change_subcategory = function twinklewarnCallbackChangeSubcategory(e) { var main_group = e.target.form.main_group.value; var value = e.target.form.sub_group.value;

// Tags that don't take a linked article, but something else (often a username). // The value of each tag is the label next to the input field var notLinkedArticle = { "uw-agf-sock": "Optional username of other account (without User:) ", "uw-bite": "Username of 'bitten' user (without User:) ", "uw-socksuspect": "Username of sock master, if known (without User:) ", "uw-username": "Username violates policy because... ", "uw-aiv": "Optional username that was reported (without User:) " };

if( main_group === 'singlenotice' || main_group === 'singlewarn' ) { if( notLinkedArticle[value] ) { if(Twinkle.warn.prev_article === null) { Twinkle.warn.prev_article = e.target.form.article.value; }			e.target.form.article.notArticle = true; e.target.form.article.value = '';

// change form labels according to the warning selected Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false); Morebits.quickForm.overrideElementLabel(e.target.form.article, notLinkedArticle[value]); } else if( e.target.form.article.notArticle ) { if(Twinkle.warn.prev_article !== null) { e.target.form.article.value = Twinkle.warn.prev_article; Twinkle.warn.prev_article = null; }			e.target.form.article.notArticle = false; Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, true); Morebits.quickForm.resetElementLabel(e.target.form.article); }	}

// add big red notice, warning users about how to use appropriately $("#tw-warn-red-notice").remove;

var $redWarning; if (value === "uw-username") { $redWarning = $(" should not be used for blatant username policy violations. " +			"Blatant violations should be reported directly to UAA (via Twinkle's ARV tab). " +			" should only be used in edge cases in order to engage in discussion with the user. "); $redWarning.insertAfter(Morebits.quickForm.getElementLabelObject(e.target.form.reasonGroup)); } else if (value === "uw-coi-username") { $redWarning = $(" should not be used for blatant username policy violations. " +			"Blatant violations should be reported directly to UAA (via Twinkle's ARV tab). " +			" should only be used in edge cases in order to engage in discussion with the user. "); $redWarning.insertAfter(Morebits.quickForm.getElementLabelObject(e.target.form.reasonGroup)); } };

Twinkle.warn.callbacks = { getWarningWikitext: function(templateName, article, reason, isCustom) { var text = "';

if (reason && isCustom) { // we assume that custom warnings lack a parameter text += " " + reason + ""; }

return text; },	preview: function(form) { var templatename = form.sub_group.value; var linkedarticle = form.article.value; var templatetext;

templatetext = Twinkle.warn.callbacks.getWarningWikitext(templatename, linkedarticle,			form.reason.value, form.main_group.value === 'custom');

form.previewer.beginRender(templatetext, 'WP:TW'); // Force wikitext },	main: function( pageobj ) { var text = pageobj.getPageText; var params = pageobj.getCallbackParameters; var messageData = params.messageData;

var history_re = /.*?(\d{1,2}:\d{1,2}, \d{1,2} \w+ \d{4}) \(UTC\)/g; var history = {}; var latest = { date: new Date( 0 ), type: '' }; var current;

while( ( current = history_re.exec( text ) ) ) { 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]; }		}

var date = new Date;

if( params.sub_group in history ) { var temp_time = new Date( history[ params.sub_group ] ); temp_time.setUTCHours( temp_time.getUTCHours + 24 );

if( temp_time > date ) { if( !confirm( "An identical " + params.sub_group + " has been issued in the last 24 hours. \nWould you still like to add this warning/notice?" ) ) {					pageobj.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 ) { if( !confirm( "A " + latest.type + " has been issued in the last minute. \nWould you still like to add this warning/notice?" ) ) {				pageobj.statelem.info( 'aborted per user request' ); return; }		}

var dateHeaderRegex = new RegExp( "^==+\\s*(?:" + date.getUTCMonthName + '|' + date.getUTCMonthNameAbbrev + ")\\s+" + date.getUTCFullYear + "\\s*==+", 'mg' ); var dateHeaderRegexLast, dateHeaderRegexResult; while ((dateHeaderRegexLast = dateHeaderRegex.exec( text )) !== null) { dateHeaderRegexResult = dateHeaderRegexLast; }		// If dateHeaderRegexResult is null then lastHeaderIndex is never checked. If it is not null but // \n== is not found, then the date header must be at the very start of the page. lastIndexOf // returns -1 in this case, so lastHeaderIndex gets set to 0 as desired. var lastHeaderIndex = text.lastIndexOf( "\n==" ) + 1;

if( text.length > 0 ) { text += "\n\n"; }

if( messageData.heading ) { text += "== " + messageData.heading + " ==\n"; } else if( !dateHeaderRegexResult || dateHeaderRegexResult.index !== lastHeaderIndex ) { Morebits.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 += Twinkle.warn.callbacks.getWarningWikitext(params.sub_group, params.article,			params.reason, params.main_group === 'custom') + " ~";

if ( Twinkle.getPref('showSharedIPNotice') && mw.util.isIPAddress( mw.config.get('wgTitle') ) ) { Morebits.status.info( 'Info', 'Adding a shared IP notice' ); text += "\n"; }

// build the edit summary var summary; if( params.main_group === 'custom' ) { switch( params.sub_group.substr( -1 ) ) { case "1": summary = "General note"; break; case "2": summary = "Caution"; break; case "3": summary = "Warning"; break; case "4": summary = "Final warning"; break; case "m": if( params.sub_group.substr( -3 ) === "4im" ) { summary = "Only warning"; break; }					summary = "Notice"; break; default: summary = "Notice"; break; }			summary += ": " + Morebits.string.toUpperCaseFirstChar(messageData.label); } else { summary = messageData.summary; if ( messageData.suppressArticleInSummary !== true && params.article ) { if ( params.sub_group === "uw-agf-sock" ||						params.sub_group === "uw-socksuspect" ||						params.sub_group === "uw-aiv" ) { // these templates require a username summary += " of User:" + params.article + ""; } else { summary += " on " + params.article + ""; }			}		}		summary += "." + Twinkle.getPref("summaryAd");

pageobj.setPageText( text ); pageobj.setEditSummary( summary ); pageobj.setWatchlist( Twinkle.getPref('watchWarnings') ); pageobj.save; } };

Twinkle.warn.callback.evaluate = function twinklewarnCallbackEvaluate(e) { var userTalkPage = 'User_talk:' + mw.config.get('wgRelevantUserName');

// First, check to make sure a reason was filled in if uw-username was selected

if(e.target.sub_group.value === 'uw-username' && e.target.article.value.trim === '') { alert("You must supply a reason for the template."); return; }

// Find the selected element so we can fetch the data structure var selectedEl = $(e.target.sub_group).find('option[value="' + $(e.target.sub_group).val + '"]');

// Then, grab all the values provided by the form var params = { reason: e.target.reason.value, main_group: e.target.main_group.value, sub_group: e.target.sub_group.value, article: e.target.article.value, // .replace( /^(Image|Category):/i, ':$1:' ),  -- apparently no longer needed... messageData: selectedEl.data("messageData") };

Morebits.simpleWindow.setButtonsEnabled( false ); Morebits.status.init( e.target );

Morebits.wiki.actionCompleted.redirect = userTalkPage; Morebits.wiki.actionCompleted.notice = "Warning complete, reloading talk page in a few seconds";

var wikipedia_page = new Morebits.wiki.page( userTalkPage, 'User talk page modification' ); wikipedia_page.setCallbackParameters( params ); wikipedia_page.setFollowRedirect( true ); wikipedia_page.load( Twinkle.warn.callbacks.main ); }; })(jQuery);

//