69
edits
(clean up) |
m (1 revision imported) |
||
(One intermediate revision by the same user not shown) | |||
Line 22: | Line 22: | ||
if( mw.config.get('wgAction') === 'rollback' ) { | if( mw.config.get('wgAction') === 'rollback' ) { | ||
var $vandalTalkLink = $("#mw-rollback-success").find(".mw-usertoollinks a").first(); | var $vandalTalkLink = $("#mw-rollback-success").find(".mw-usertoollinks a").first(); | ||
$vandalTalkLink.css("font-weight", "bold"); | if ( $vandalTalkLink.length ) { | ||
$vandalTalkLink.css("font-weight", "bold"); | |||
$vandalTalkLink.wrapInner($("<span/>").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); | |||
} | |||
} | } | ||
} | } | ||
Line 44: | Line 46: | ||
Window.setTitle( "Warn/notify user" ); | Window.setTitle( "Warn/notify user" ); | ||
Window.setScriptName( "Twinkle" ); | Window.setScriptName( "Twinkle" ); | ||
Window.addFooterLink( "Choosing a warning level", " | Window.addFooterLink( "Choosing a warning level", "WP:UWUL#Levels" ); | ||
Window.addFooterLink( "Twinkle help", " | Window.addFooterLink( "Twinkle help", "WP:TW/DOC#warn" ); | ||
var form = new Morebits.quickForm( Twinkle.warn.callback.evaluate ); | var form = new Morebits.quickForm( Twinkle.warn.callback.evaluate ); | ||
Line 391: | Line 393: | ||
}, | }, | ||
"Other": { | "Other": { | ||
"uw-attempt2": { | |||
label: "Triggering the edit filter", | |||
summary: "Caution: Triggering the edit filter" | |||
}, | |||
"uw-chat2": { | "uw-chat2": { | ||
label: "Using talk page as forum", | label: "Using talk page as forum", | ||
Line 424: | Line 430: | ||
label: "Uploading files missing copyright status", | label: "Uploading files missing copyright status", | ||
summary: "Caution: Uploading files missing copyright status" | summary: "Caution: Uploading files missing copyright status" | ||
} | } | ||
}*/ | }*/ | ||
Line 545: | Line 547: | ||
}, | }, | ||
"Other": { | "Other": { | ||
"uw-attempt3": { | |||
label: "Triggering the edit filter", | |||
summary: "Warning: Triggering the edit filter" | |||
}, | |||
"uw-chat3": { | "uw-chat3": { | ||
label: "Using talk page as forum", | label: "Using talk page as forum", | ||
Line 571: | Line 577: | ||
}/*, | }/*, | ||
"To be removed fomr Twinkle": { | "To be removed fomr Twinkle": { | ||
"uw-ics3": { | "uw-ics3": { | ||
label: "Uploading files missing copyright status", | label: "Uploading files missing copyright status", | ||
Line 589: | Line 591: | ||
level4: { | level4: { | ||
"Common warnings": { | "Common warnings": { | ||
"uw-vandalism4": { | |||
label: "Vandalism", | |||
summary: "Final warning: Vandalism" | |||
}, | |||
"uw-generic4": { | "uw-generic4": { | ||
label: "Generic warning (for template series missing level 4)", | label: "Generic warning (for template series missing level 4)", | ||
summary: "Final warning notice" | summary: "Final warning notice" | ||
}, | }, | ||
"uw-delete4": { | "uw-delete4": { | ||
Line 683: | Line 685: | ||
}, | }, | ||
"Other": { | "Other": { | ||
"uw-attempt4": { | |||
label: "Triggering the edit filter", | |||
summary: "Final warning: Triggering the edit filter" | |||
}, | |||
"uw-chat4": { | "uw-chat4": { | ||
label: "Using talk page as forum", | label: "Using talk page as forum", | ||
Line 716: | Line 722: | ||
label: "Uploading files missing copyright status", | label: "Uploading files missing copyright status", | ||
summary: "Final warning: Uploading files missing copyright status" | summary: "Final warning: Uploading files missing copyright status" | ||
} | } | ||
}*/ | }*/ | ||
Line 793: | Line 795: | ||
}/*, | }/*, | ||
"To be removed from Twinkle": { | "To be removed from Twinkle": { | ||
"uw-redirect4im": { | "uw-redirect4im": { | ||
label: "Creating malicious redirects", | label: "Creating malicious redirects", | ||
Line 809: | Line 807: | ||
label: "Creating double redirects through bad page moves", | label: "Creating double redirects through bad page moves", | ||
summary: "Notice: Creating double redirects through bad page moves" | summary: "Notice: Creating double redirects through bad page moves" | ||
}, | }, | ||
"uw-aiv": { | "uw-aiv": { | ||
Line 844: | Line 830: | ||
"uw-bite": { | "uw-bite": { | ||
label: "\"Biting\" newcomers", | label: "\"Biting\" newcomers", | ||
summary: "Notice: \"Biting\" newcomers" | summary: "Notice: \"Biting\" newcomers", | ||
suppressArticleInSummary: true // non-standard (user name, not article), and not necessary | |||
}, | }, | ||
"uw-coi": { | "uw-coi": { | ||
label: "Conflict of | label: "Conflict of interest", | ||
summary: "Notice: Conflict of | summary: "Notice: Conflict of interest", | ||
heading: "Managing a conflict of interest" | |||
}, | }, | ||
"uw-controversial": { | "uw-controversial": { | ||
Line 913: | Line 901: | ||
label: "Incomplete AFD", | label: "Incomplete AFD", | ||
summary: "Notice: Incomplete AFD" | summary: "Notice: Incomplete AFD" | ||
}, | |||
"uw-inline-el": { | |||
label: "Adding external links to the body of an article", | |||
summary: "Notice: Keep external links to External links sections at the bottom of an article" | |||
}, | }, | ||
"uw-italicize": { | "uw-italicize": { | ||
Line 920: | Line 912: | ||
"uw-lang": { | "uw-lang": { | ||
label: "Unnecessarily changing between British and American English", | label: "Unnecessarily changing between British and American English", | ||
summary: "Notice: Unnecessarily changing between British and American English" | summary: "Notice: Unnecessarily changing between British and American English", | ||
heading: "National varieties of English" | |||
}, | }, | ||
"uw-linking": { | "uw-linking": { | ||
Line 969: | Line 962: | ||
label: "Article is on probation", | label: "Article is on probation", | ||
summary: "Notice: Article is on probation" | summary: "Notice: Article is on probation" | ||
}, | |||
"uw-redlink": { | |||
label: "Indiscriminate removal of redlinks", | |||
summary: "Notice: Be careful when removing redlinks" | |||
}, | }, | ||
"uw-refimprove": { | "uw-refimprove": { | ||
Line 981: | Line 978: | ||
label: "Recreating material previously deleted via XfD process", | label: "Recreating material previously deleted via XfD process", | ||
summary: "Notice: Recreating previously deleted material" | summary: "Notice: Recreating previously deleted material" | ||
}, | }, | ||
"uw-samename": { | "uw-samename": { | ||
Line 1,023: | Line 1,016: | ||
}, | }, | ||
"uw-uaa": { | "uw-uaa": { | ||
label: "Reporting of username to | label: "Reporting of username to WP:UAA not accepted", | ||
summary: "Notice: Reporting of username to | summary: "Notice: Reporting of username to WP:UAA not accepted" | ||
}, | }, | ||
"uw-upincat": { | "uw-upincat": { | ||
Line 1,070: | Line 1,063: | ||
summary: "Warning: Creating attack pages", | summary: "Warning: Creating attack pages", | ||
suppressArticleInSummary: true | suppressArticleInSummary: true | ||
}, | }, | ||
"uw-bizlist": { | "uw-bizlist": { | ||
Line 1,097: | Line 1,086: | ||
"uw-copyright-new": { | "uw-copyright-new": { | ||
label: "Copyright violation (with explanation for new users)", | label: "Copyright violation (with explanation for new users)", | ||
summary: "Notice: Avoiding copyright problems" | summary: "Notice: Avoiding copyright problems", | ||
heading: "Wikipedia and copyright" | |||
}, | |||
"uw-dls": { | |||
label: "Replacing dead links with spam links", | |||
summary: "Warning: Replacing dead links with spam links" | |||
}, | }, | ||
"uw-copyright-remove": { | "uw-copyright-remove": { | ||
Line 1,138: | Line 1,132: | ||
label: "Personal info", | label: "Personal info", | ||
summary: "Warning: Personal info" | summary: "Warning: Personal info" | ||
}, | |||
"uw-salt": { | |||
label: "Recreating salted articles under a different title", | |||
summary: "Notice: Recreating creation-protected articles under a different title" | |||
}, | }, | ||
"uw-socksuspect": { | "uw-socksuspect": { | ||
label: "Sockpuppetry", | label: "Sockpuppetry", | ||
summary: "Warning: You are a suspected [[ | summary: "Warning: You are a suspected [[WP:SOCK|sockpuppet]]" // of User:... | ||
}, | }, | ||
"uw-upv": { | "uw-upv": { | ||
Line 1,154: | Line 1,152: | ||
"uw-coi-username": { | "uw-coi-username": { | ||
label: "Username is against policy, and conflict of interest", | label: "Username is against policy, and conflict of interest", | ||
summary: "Warning: Username and conflict of interest policy" | summary: "Warning: Username and conflict of interest policy", | ||
heading: "Your username" | |||
}, | }, | ||
"uw-userpage": { | "uw-userpage": { | ||
Line 1,198: | Line 1,197: | ||
"uw-vblock": { | "uw-vblock": { | ||
label: "Vandalism block", | label: "Vandalism block", | ||
summary: "You have been blocked from editing for persistent [[ | summary: "You have been blocked from editing for persistent [[WP:VAND|vandalism]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-voablock": { | "uw-voablock": { | ||
label: "Vandalism-only account block (indefinite)", | label: "Vandalism-only account block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your account is being [[ | summary: "You have been indefinitely blocked from editing because your account is being [[WP:VOA|used only for vandalism]]", | ||
indefinite: true, | indefinite: true, | ||
pageParam: true | pageParam: true | ||
Line 1,209: | Line 1,208: | ||
"uw-bioblock": { | "uw-bioblock": { | ||
label: "BLP violations block", | label: "BLP violations block", | ||
summary: "You have been blocked from editing for violations of Wikipedia's [[ | summary: "You have been blocked from editing for violations of Wikipedia's [[WP:BLP|biographies of living persons policy]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-sblock": { | "uw-sblock": { | ||
label: "Spam block", | label: "Spam block", | ||
summary: "You have been blocked from editing for using Wikipedia for [[ | summary: "You have been blocked from editing for using Wikipedia for [[WP:SPAM|spam]] purposes" | ||
}, | }, | ||
"uw-adblock": { | "uw-adblock": { | ||
label: "Advertising block", | label: "Advertising block", | ||
summary: "You have been blocked from editing for [[ | summary: "You have been blocked from editing for [[WP:SOAP|advertising or self-promotion]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-soablock": { | "uw-soablock": { | ||
label: "Spam/advertising-only account block (indefinite)", | label: "Spam/advertising-only account block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your account is being used only for [[ | summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:SPAM|spam, advertising, or promotion]]", | ||
indefinite: true, | indefinite: true, | ||
pageParam: true | pageParam: true | ||
}, | |||
"uw-nothereblock": { | |||
label: "WP:NOTHERE block (indefinite)", | |||
summary: "You have been indefinitely blocked from editing because it appears that you are not here to [[WP:NOTHERE|build an encyclopedia]]", | |||
indefinite: true | |||
}, | }, | ||
"uw-npblock": { | "uw-npblock": { | ||
label: "Creating nonsense pages block", | label: "Creating nonsense pages block", | ||
summary: "You have been blocked from editing for creating [[ | summary: "You have been blocked from editing for creating [[WP:PN|nonsense pages]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-copyrightblock": { | "uw-copyrightblock": { | ||
label: "Copyright violation block", | label: "Copyright violation block", | ||
summary: "You have been blocked from editing for continued [[ | summary: "You have been blocked from editing for continued [[WP:COPYVIO|copyright infringement]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-spoablock": { | "uw-spoablock": { | ||
label: "Sockpuppet account block (indefinite)", | label: "Sockpuppet account block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your account is being used only for [[ | summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:SOCK|sock puppetry]]", | ||
indefinite: true | indefinite: true | ||
}, | |||
"uw-ipevadeblock": { | |||
label: "Block-evasion block - IP address", | |||
summary: "Your IP address has been blocked from editing because it has been used to [[WP:EVADE|evade a previous block]]" | |||
}, | }, | ||
"uw-hblock": { | "uw-hblock": { | ||
label: "Harassment block", | label: "Harassment block", | ||
summary: "You have been blocked from editing for attempting to [[ | summary: "You have been blocked from editing for attempting to [[WP:HARASS|harass]] other users", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-ewblock": { | "uw-ewblock": { | ||
label: "Edit warring block", | label: "Edit warring block", | ||
summary: "You have been blocked from editing to prevent further [[ | summary: "You have been blocked from editing to prevent further [[WP:DE|disruption]] caused by your engagement in an [[WP:EW|edit war]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-3block": { | "uw-3block": { | ||
label: "Three-revert rule violation block", | label: "Three-revert rule violation block", | ||
summary: "You have been blocked from editing for violation of the [[ | summary: "You have been blocked from editing for violation of the [[WP:3RR|three-revert rule]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-disruptblock": { | "uw-disruptblock": { | ||
label: "Disruptive editing block", | label: "Disruptive editing block", | ||
summary: "You have been blocked from editing for [[ | summary: "You have been blocked from editing for [[WP:DE|disruptive editing]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-deoablock": { | "uw-deoablock": { | ||
label: "Disruption/trolling-only account block (indefinite)", | label: "Disruption/trolling-only account block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your account is being used only for [[ | summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:DE|trolling, disruption or harassment]]", | ||
indefinite: true, | indefinite: true, | ||
pageParam: true | pageParam: true | ||
Line 1,270: | Line 1,278: | ||
"uw-lblock": { | "uw-lblock": { | ||
label: "Legal threat block (indefinite)", | label: "Legal threat block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing for making [[ | summary: "You have been indefinitely blocked from editing for making [[WP:NLT|legal threats or taking legal action]]", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-aeblock": { | "uw-aeblock": { | ||
label: "Arbitration enforcement block", | label: "Arbitration enforcement block", | ||
summary: "You have been blocked from editing for violating an [[ | summary: "You have been blocked from editing for violating an [[WP:Arbitration|arbitration decision]] with your edits", | ||
pageParam: true, | pageParam: true, | ||
reasonParam: true | reasonParam: true | ||
Line 1,281: | Line 1,289: | ||
"uw-efblock": { | "uw-efblock": { | ||
label: "Edit filter-related block", | label: "Edit filter-related block", | ||
summary: "You have been blocked from editing for making disruptive edits that repeatedly triggered the [[ | summary: "You have been blocked from editing for making disruptive edits that repeatedly triggered the [[WP:EF|edit filter]]" | ||
}, | }, | ||
"uw-myblock": { | "uw-myblock": { | ||
label: "Social networking block", | label: "Social networking block", | ||
summary: "You have been blocked from editing for using user and/or article pages as a [[ | summary: "You have been blocked from editing for using user and/or article pages as a [[WP:NOTMYSPACE|blog, web host, social networking site or forum]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-dblock": { | "uw-dblock": { | ||
label: "Deletion/removal of content block", | label: "Deletion/removal of content block", | ||
summary: "You have been blocked from editing for continued [[ | summary: "You have been blocked from editing for continued [[WP:VAND|removal of material]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-compblock": { | "uw-compblock": { | ||
label: "Possible compromised account block (indefinite)", | label: "Possible compromised account block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because it is believed that your [[ | summary: "You have been indefinitely blocked from editing because it is believed that your [[WP:SECURE|account has been compromised]]", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-botblock": { | "uw-botblock": { | ||
label: "Unapproved bot block", | label: "Unapproved bot block", | ||
summary: "You have been blocked from editing because it appears you are running a [[ | summary: "You have been blocked from editing because it appears you are running a [[WP:BOT|bot script]] without [[WP:BRFA|approval]]", | ||
pageParam: true | pageParam: true | ||
}, | }, | ||
"uw-ublock": { | "uw-ublock": { | ||
label: "Username soft block (indefinite)", | label: "Username soft block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your username is a violation of the [[ | summary: "You have been indefinitely blocked from editing because your username is a violation of the [[WP:U|username policy]]", | ||
indefinite: true, | indefinite: true, | ||
reasonParam: true | reasonParam: true | ||
Line 1,311: | Line 1,319: | ||
"uw-uhblock": { | "uw-uhblock": { | ||
label: "Username hard block (indefinite)", | label: "Username hard block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your username is a blatant violation of the [[ | summary: "You have been indefinitely blocked from editing because your username is a blatant violation of the [[WP:U|username policy]]", | ||
indefinite: true, | indefinite: true, | ||
reasonParam: true | reasonParam: true | ||
Line 1,317: | Line 1,325: | ||
"uw-softerblock": { | "uw-softerblock": { | ||
label: "Promotional username soft block (indefinite)", | label: "Promotional username soft block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your [[ | summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] gives the impression that the account represents a group, organization or website", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-causeblock": { | "uw-causeblock": { | ||
label: "Promotional username soft block, for charitable causes (indefinite)", | label: "Promotional username soft block, for charitable causes (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your [[ | summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] gives the impression that the account represents a group, organization or website", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-botublock": { | "uw-botublock": { | ||
label: "Bot username soft block (indefinite)", | label: "Bot username soft block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your [[ | summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] indicates this is a [[WP:BOT|bot]] account, which is currently not approved", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-memorialblock": { | "uw-memorialblock": { | ||
label: "Memorial username soft block (indefinite)", | label: "Memorial username soft block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your [[ | summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] indicates this account may be used as a memorial or tribute to someone", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-ublock-famous": { | "uw-ublock-famous": { | ||
label: "Famous username soft block (indefinite)", | label: "Famous username soft block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your [[ | summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] matches the name of a well-known living individual", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-ublock-double": { | "uw-ublock-double": { | ||
label: "Similar username soft block (indefinite)", | label: "Similar username soft block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your [[ | summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] is too similar to the username of another Wikipedia user", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-uhblock-double": { | "uw-uhblock-double": { | ||
label: "Username impersonation hard block (indefinite)", | label: "Username impersonation hard block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your [[ | summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] appears to impersonate another established Wikipedia user", | ||
indefinite: true | indefinite: true | ||
}, | }, | ||
"uw-vaublock": { | "uw-vaublock": { | ||
label: "Vandalism-only account and username hard block (indefinite)", | label: "Vandalism-only account and username hard block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your account is being [[ | summary: "You have been indefinitely blocked from editing because your account is being [[WP:VOA|used only for vandalism]] and your username is a blatant violation of the [[WP:U|username policy]]", | ||
indefinite: true, | indefinite: true, | ||
pageParam: true | pageParam: true | ||
Line 1,358: | Line 1,366: | ||
"uw-spamublock": { | "uw-spamublock": { | ||
label: "Spam-only account and promotional username hard block (indefinite)", | label: "Spam-only account and promotional username hard block (indefinite)", | ||
summary: "You have been indefinitely blocked from editing because your account is being used only for [[ | summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:SPAM|spam or advertising]] and your username is a violation of the [[WP:U|username policy]]", | ||
indefinite: true | indefinite: true | ||
} | } | ||
Line 1,385: | Line 1,393: | ||
// worker function to create the combo box entries | // worker function to create the combo box entries | ||
var createEntries = function( contents, container ) { | 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 ) { | $.each( contents, function( itemKey, itemProperties ) { | ||
var key = (typeof itemKey === "string") ? itemKey : itemProperties.value; | var key = (typeof itemKey === "string") ? itemKey : itemProperties.value; | ||
Line 1,407: | Line 1,427: | ||
if( value === "singlenotice" || value === "singlewarn" || value === "block" ) { | if( value === "singlenotice" || value === "singlewarn" || value === "block" ) { | ||
// no categories, just create the options right away | // no categories, just create the options right away | ||
createEntries( Twinkle.warn.messages[ value ], sub_group ); | createEntries( Twinkle.warn.messages[ value ], sub_group, true ); | ||
} else if( value === "custom" ) { | } else if( value === "custom" ) { | ||
createEntries( Twinkle.getPref("customWarningList"), sub_group ); | createEntries( Twinkle.getPref("customWarningList"), sub_group, true ); | ||
} else { | } else { | ||
// create the option-groups | // create the option-groups | ||
Line 1,420: | Line 1,440: | ||
sub_group.appendChild( optgroup ); | sub_group.appendChild( optgroup ); | ||
// create the options | // create the options | ||
createEntries( groupContents, optgroup ); | createEntries( groupContents, optgroup, false ); | ||
} ); | } ); | ||
} | } | ||
Line 1,584: | Line 1,604: | ||
Twinkle.warn.callbacks = { | Twinkle.warn.callbacks = { | ||
getWarningWikitext: function(templateName, article, reason) { | getWarningWikitext: function(templateName, article, reason, isCustom) { | ||
var text = "{{subst:" + templateName; | var text = "{{subst:" + templateName; | ||
Line 1,590: | Line 1,610: | ||
// add linked article for user warnings (non-block templates) | // add linked article for user warnings (non-block templates) | ||
text += '|1=' + article; | text += '|1=' + article; | ||
} | |||
if (reason && !isCustom) { | |||
// add extra message for non-block templates | |||
if (templateName === 'uw-csd' || templateName === 'uw-probation' || | |||
templateName === 'uw-userspacenoindex' || templateName === 'uw-userpage') { | |||
text += "|3=''" + reason + "''"; | |||
} else { | |||
text += "|2=''" + reason + "''"; | |||
} | |||
} | } | ||
text += '}}'; | text += '}}'; | ||
if (reason && isCustom) { | |||
if (reason) { | // we assume that custom warnings lack a {{{2}}} parameter | ||
text += " ''" + reason + "''"; | text += " ''" + reason + "''"; | ||
} | } | ||
Line 1,631: | Line 1,660: | ||
form.block_reason.value, Twinkle.warn.messages.block[templatename].indefinite); | form.block_reason.value, Twinkle.warn.messages.block[templatename].indefinite); | ||
} else { | } else { | ||
templatetext = Twinkle.warn.callbacks.getWarningWikitext(templatename, linkedarticle, form.reason.value); | templatetext = Twinkle.warn.callbacks.getWarningWikitext(templatename, linkedarticle, | ||
form.reason.value, form.main_group.value === 'custom'); | |||
} | } | ||
Line 1,680: | Line 1,710: | ||
} | } | ||
var | 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 ) { | if( text.length > 0 ) { | ||
Line 1,690: | Line 1,729: | ||
Morebits.status.info( 'Info', 'Blanking talk page per preferences and creating a new level 2 heading for the date' ); | Morebits.status.info( 'Info', 'Blanking talk page per preferences and creating a new level 2 heading for the date' ); | ||
text = "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n"; | text = "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n"; | ||
} else if( ! | } 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' ); | 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 += "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n"; | ||
Line 1,697: | Line 1,736: | ||
text += Twinkle.warn.callbacks.getBlockNoticeWikitext(params.sub_group, params.article, params.block_timer, params.reason, messageData.indefinite); | text += Twinkle.warn.callbacks.getBlockNoticeWikitext(params.sub_group, params.article, params.block_timer, params.reason, messageData.indefinite); | ||
} else { | } else { | ||
if( ! | 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' ); | 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 += "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n"; | ||
} | } | ||
text += Twinkle.warn.callbacks.getWarningWikitext(params.sub_group, params.article, params.reason) + " ~~~~"; | text += Twinkle.warn.callbacks.getWarningWikitext(params.sub_group, params.article, | ||
params.reason, params.main_group === 'custom') + " ~~~~"; | |||
} | } | ||