MediaWiki:Gadget-twinklewarn.js: Difference between revisions
Jump to navigation
Jump to search
Content deleted Content added
Repo at e6e05d9: hideReason=true for Uw-blar and Uw-articletodraft (#1850); fix hideReason not working when used without hideLinkedPage (#1851) |
+ |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
// |
//<nowiki> |
||
(function($) |
(function($){ |
||
Line 10: | Line 10: | ||
**************************************** |
**************************************** |
||
* Mode of invocation: Tab ("Warn") |
* Mode of invocation: Tab ("Warn") |
||
* Active on: |
* Active on: User talk pages |
||
* Config directives in: TwinkleConfig |
|||
* etc.) (not IP ranges), as well as the rollback success page |
|||
*/ |
*/ |
||
Twinkle.warn = function twinklewarn() { |
Twinkle.warn = function twinklewarn() { |
||
if( mw.config.get('wgNamespaceNumber') === 3 ) { |
|||
Twinkle.addPortletLink( Twinkle.warn.callback, "Warn", "tw-warn", "Warn/notify user" ); |
|||
// Users and IPs but not IP ranges |
|||
if (mw.config.exists('wgRelevantUserName') && !Morebits.ip.isRange(mw.config.get('wgRelevantUserName'))) { |
|||
Twinkle.addPortletLink(Twinkle.warn.callback, 'Warn', 'tw-warn', 'Warn/notify user'); |
|||
if (Twinkle.getPref('autoMenuAfterRollback') && |
|||
mw.config.get('wgNamespaceNumber') === 3 && |
|||
Twinkle.getPrefill('vanarticle') && |
|||
!Twinkle.getPrefill('friendlywelcome') && |
|||
!Twinkle.getPrefill('noautowarn')) { |
|||
Twinkle.warn.callback(); |
|||
} |
|||
} |
} |
||
// |
// modify URL of talk page on rollback success pages |
||
if( mw.config.get('wgAction') === 'rollback' ) { |
|||
// custom message box in [[MediaWiki:Rollback-success]] |
|||
var $vandalTalkLink = $("#mw-rollback-success").find(".mw-usertoollinks a").first(); |
|||
if (mw.config.get('wgAction') === 'rollback') { |
|||
$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.")); |
|||
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); |
|||
// Can't provide vanarticlerevid as only wgCurRevisionId is provided |
|||
var href = $vandalTalkLink.attr("href"); |
|||
var extraParam = 'vanarticle=' + mw.util.rawurlencode(Morebits.pageNameNorm); |
|||
if (href.indexOf("?") === -1) { |
|||
var href = $vandalTalkLink.attr('href'); |
|||
$vandalTalkLink.attr("href", href + "?" + extraParam); |
|||
if (href.indexOf('?') === -1) { |
|||
} else { |
|||
$vandalTalkLink.attr('href', href + '?' + extraParam); |
|||
$vandalTalkLink.attr("href", href + "&" + extraParam); |
|||
} else { |
|||
$vandalTalkLink.attr('href', href + '&' + extraParam); |
|||
} |
|||
} |
} |
||
} |
} |
||
}; |
}; |
||
// Used to close window when switching to ARV in autolevel |
|||
Twinkle.warn.dialog = null; |
|||
Twinkle.warn.callback = function twinklewarnCallback() { |
Twinkle.warn.callback = function twinklewarnCallback() { |
||
if |
if( mw.config.get('wgTitle').split( '/' )[0] === mw.config.get('wgUserName') && |
||
!confirm('You are about to warn yourself! Are you sure you want to proceed?')) { |
!confirm( 'You are about to warn yourself! Are you sure you want to proceed?' ) ) { |
||
return; |
return; |
||
} |
} |
||
var Window = new Morebits.simpleWindow( 600, 440 ); |
|||
var dialog; |
|||
Window.setTitle( "Warn/notify user" ); |
|||
Twinkle.warn.dialog = new Morebits.simpleWindow(600, 440); |
|||
Window.setScriptName( "Twinkle" ); |
|||
dialog = Twinkle.warn.dialog; |
|||
Window.addFooterLink( "Choosing a warning level", "WP:UWUL#Levels" ); |
|||
dialog.setTitle('Warn/notify user'); |
|||
Window.addFooterLink( "Twinkle help", "WP:TW/DOC#warn" ); |
|||
dialog.addFooterLink('Choosing a warning level', 'WP:UWUL#Levels'); |
|||
dialog.addFooterLink('Warn prefs', 'WP:TW/PREF#warn'); |
|||
dialog.addFooterLink('Twinkle help', 'WP:TW/DOC#warn'); |
|||
dialog.addFooterLink('Give feedback', 'WT:TW'); |
|||
var form = new Morebits.quickForm(Twinkle.warn.callback.evaluate); |
var form = new Morebits.quickForm( Twinkle.warn.callback.evaluate ); |
||
var main_select = form.append({ |
var main_select = form.append( { |
||
type: 'field', |
type: 'field', |
||
label: 'Choose type of warning/notice to issue', |
label: 'Choose type of warning/notice to issue', |
||
tooltip: 'First choose a main warning group, then the specific warning to issue.' |
tooltip: 'First choose a main warning group, then the specific warning to issue.' |
||
} ); |
|||
var main_group = main_select.append({ |
var main_group = main_select.append( { |
||
type: 'select', |
type: 'select', |
||
name: 'main_group', |
name: 'main_group', |
||
event:Twinkle.warn.callback.change_category |
|||
tooltip: 'You can customize the default selection in your Twinkle preferences', |
|||
} ); |
|||
event: Twinkle.warn.callback.change_category |
|||
}); |
|||
var defaultGroup = parseInt(Twinkle.getPref('defaultWarningGroup'), 10); |
var defaultGroup = parseInt(Twinkle.getPref('defaultWarningGroup'), 10); |
||
main_group.append({ type: 'option', label: ' |
main_group.append( { type: 'option', label: 'General note (1)', value: 'level1', selected: ( defaultGroup === 1 || defaultGroup < 1 || ( Morebits.userIsInGroup( 'sysop' ) ? defaultGroup > 8 : defaultGroup > 7 ) ) } ); |
||
main_group.append({ type: 'option', label: ' |
main_group.append( { type: 'option', label: 'Caution (2)', value: 'level2', selected: ( defaultGroup === 2 ) } ); |
||
main_group.append({ type: 'option', label: ' |
main_group.append( { type: 'option', label: 'Warning (3)', value: 'level3', selected: ( defaultGroup === 3 ) } ); |
||
main_group.append({ type: 'option', label: ' |
main_group.append( { type: 'option', label: 'Final warning (4)', value: 'level4', selected: ( defaultGroup === 4 ) } ); |
||
main_group.append({ type: 'option', label: ' |
main_group.append( { type: 'option', label: 'Only warning (4im)', value: 'level4im', selected: ( defaultGroup === 5 ) } ); |
||
main_group.append({ type: 'option', label: ' |
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('combinedSingletMenus')) { |
|||
if( Twinkle.getPref( 'customWarningList' ).length ) { |
|||
main_group.append({ type: 'option', label: 'Single-issue messages', value: 'singlecombined', selected: defaultGroup === 6 || defaultGroup === 7 }); |
|||
main_group.append( { type: 'option', label: 'Custom warnings', value: 'custom', selected: ( defaultGroup === 9 ) } ); |
|||
} else { |
|||
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( Morebits.userIsInGroup( 'sysop' ) ) { |
|||
if (Twinkle.getPref('customWarningList').length) { |
|||
main_group.append({ type: 'option', label: ' |
main_group.append( { type: 'option', label: 'Blocking', value: 'block', selected: ( defaultGroup === 8 ) } ); |
||
} |
} |
||
main_group.append({ type: 'option', label: 'All warning templates', value: 'kitchensink', selected: defaultGroup === 10 }); |
|||
main_select.append({ type: 'select', name: 'sub_group', event: |
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 page', |
|||
value: Twinkle.getPrefill('vanarticle') || '', |
|||
tooltip: 'A page can be linked within the notice, perhaps because it was a revert to said page that dispatched this notice. Leave empty for no page to be linked.' |
|||
}); |
|||
form.append({ |
|||
type: 'div', |
|||
label: '', |
|||
style: 'color: red', |
|||
id: 'twinkle-warn-warning-messages' |
|||
}); |
|||
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' }); |
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' }); |
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'); |
var previewlink = document.createElement( 'a' ); |
||
$(previewlink).click(function() |
$(previewlink).click(function(){ |
||
Twinkle.warn.callbacks.preview(result); // |result| is defined below |
Twinkle.warn.callbacks.preview(result); // |result| is defined below |
||
}); |
}); |
||
previewlink.style.cursor = |
previewlink.style.cursor = "pointer"; |
||
previewlink.textContent = 'Preview'; |
previewlink.textContent = 'Preview'; |
||
more.append({ type: 'div', id: 'warningpreview', label: [ previewlink ] }); |
more.append( { type: 'div', id: 'warningpreview', label: [ previewlink ] } ); |
||
more.append({ type: 'div', id: 'twinklewarn-previewbox', style: 'display: none' }); |
more.append( { type: 'div', id: 'twinklewarn-previewbox', style: 'display: none' } ); |
||
more.append({ type: 'submit', label: 'Submit' }); |
more.append( { type: 'submit', label: 'Submit' } ); |
||
var result = form.render(); |
var result = form.render(); |
||
Window.setContent( result ); |
|||
Window.display(); |
|||
result.main_group.root = result; |
result.main_group.root = result; |
||
result.previewer = new Morebits.wiki.preview($(result).find('div#twinklewarn-previewbox').last()[0]); |
result.previewer = new Morebits.wiki.preview($(result).find('div#twinklewarn-previewbox').last()[0]); |
||
// Potential notices for staleness and missed reverts |
|||
var vanrevid = Twinkle.getPrefill('vanarticlerevid'); |
|||
if (vanrevid) { |
|||
var message = ''; |
|||
var query = {}; |
|||
// If you tried reverting, check if *you* actually reverted |
|||
if (!Twinkle.getPrefill('noautowarn') && Twinkle.getPrefill('vanarticle')) { // Via fluff link |
|||
query = { |
|||
action: 'query', |
|||
titles: Twinkle.getPrefill('vanarticle'), |
|||
prop: 'revisions', |
|||
rvstartid: vanrevid, |
|||
rvlimit: 2, |
|||
rvdir: 'newer', |
|||
rvprop: 'user', |
|||
format: 'json' |
|||
}; |
|||
new Morebits.wiki.api('Checking if you successfully reverted the page', query, function(apiobj) { |
|||
var rev = apiobj.getResponse().query.pages[0].revisions; |
|||
var revertUser = rev && rev[1].user; |
|||
if (revertUser && revertUser !== mw.config.get('wgUserName')) { |
|||
message += ' Someone else reverted the page and may have already warned the user.'; |
|||
$('#twinkle-warn-warning-messages').text('Note:' + message); |
|||
} |
|||
}).post(); |
|||
} |
|||
// Confirm edit wasn't too old for a warning |
|||
var checkStale = function(vantimestamp) { |
|||
var revDate = new Morebits.date(vantimestamp); |
|||
if (vantimestamp && revDate.isValid()) { |
|||
if (revDate.add(24, 'hours').isBefore(new Date())) { |
|||
message += ' This edit was made more than 24 hours ago so a warning may be stale.'; |
|||
$('#twinkle-warn-warning-messages').text('Note:' + message); |
|||
} |
|||
} |
|||
}; |
|||
var vantimestamp = Twinkle.getPrefill('vantimestamp'); |
|||
// Provided from a fluff module-based revert, no API lookup necessary |
|||
if (vantimestamp) { |
|||
checkStale(vantimestamp); |
|||
} else { |
|||
query = { |
|||
action: 'query', |
|||
prop: 'revisions', |
|||
rvprop: 'timestamp', |
|||
revids: vanrevid, |
|||
format: 'json' |
|||
}; |
|||
new Morebits.wiki.api('Grabbing the revision timestamps', query, function(apiobj) { |
|||
var rev = apiobj.getResponse().query.pages[0].revisions; |
|||
vantimestamp = rev && rev[0].timestamp; |
|||
checkStale(vantimestamp); |
|||
}).post(); |
|||
} |
|||
} |
|||
// We must init the first choice (General Note); |
// We must init the first choice (General Note); |
||
var evt = document.createEvent( |
var evt = document.createEvent( "Event" ); |
||
evt.initEvent('change', true, true); |
evt.initEvent( 'change', true, true ); |
||
result.main_group.dispatchEvent(evt); |
result.main_group.dispatchEvent( evt ); |
||
}; |
}; |
||
Line 207: | Line 114: | ||
// Each of the individual templates require the following information: |
// Each of the individual templates require the following information: |
||
// label (required): A short description displayed in the dialog |
// 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 "." |
// 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. |
// 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. |
||
// hideLinkedPage (optional): Set to true to hide the "Linked page" text box. Some warning templates do not have a linked article parameter. |
|||
// hideReason (optional): Set to true to hide the "Optional message" text box. Some warning templates do not have a reason parameter. |
|||
Twinkle.warn.messages = { |
Twinkle.warn.messages = { |
||
level1: { |
|||
"Common warnings": { |
|||
"uw-vandalism1": { |
|||
label: "Vandalism", |
|||
summary: "General note: Unconstructive editing" |
|||
label: 'Vandalism', |
|||
summary: 'General note: Unconstructive editing' |
|||
}, |
|||
level2: { |
|||
label: 'Vandalism', |
|||
summary: 'Caution: Unconstructive editing' |
|||
}, |
|||
level3: { |
|||
label: 'Vandalism', |
|||
summary: 'Warning: Vandalism' |
|||
}, |
|||
level4: { |
|||
label: 'Vandalism', |
|||
summary: 'Final warning: Vandalism' |
|||
}, |
|||
level4im: { |
|||
label: 'Vandalism', |
|||
summary: 'Only warning: Vandalism' |
|||
} |
|||
}, |
}, |
||
"uw-test1": { |
|||
label: "Editing tests", |
|||
summary: "General note: Editing tests" |
|||
label: 'Disruptive editing', |
|||
summary: 'General note: Unconstructive editing' |
|||
}, |
|||
level2: { |
|||
label: 'Disruptive editing', |
|||
summary: 'Caution: Unconstructive editing' |
|||
}, |
|||
level3: { |
|||
label: 'Disruptive editing', |
|||
summary: 'Warning: Disruptive editing' |
|||
} |
|||
}, |
}, |
||
}, |
|||
'uw-test': { |
|||
"Promotions and spam": { |
|||
level1: { |
|||
"uw-advert1": { |
|||
label: 'Editing tests', |
|||
label: "Using Meta for advertising or promotion", |
|||
summary: 'General note: Editing tests' |
|||
summary: "General note: Using Meta for advertising or promotion" |
|||
}, |
|||
level2: { |
|||
label: 'Editing tests', |
|||
summary: 'Caution: Editing tests' |
|||
}, |
|||
level3: { |
|||
label: 'Editing tests', |
|||
summary: 'Warning: Editing tests' |
|||
} |
|||
}, |
}, |
||
"uw-spam1": { |
|||
label: "Adding spam links", |
|||
level1: { |
|||
summary: "General note: Adding spam links" |
|||
label: 'Removal of content, blanking', |
|||
summary: 'General note: Removal of content, blanking' |
|||
}, |
|||
level2: { |
|||
label: 'Removal of content, blanking', |
|||
summary: 'Caution: Removal of content, blanking' |
|||
}, |
|||
level3: { |
|||
label: 'Removal of content, blanking', |
|||
summary: 'Warning: Removal of content, blanking' |
|||
}, |
|||
level4: { |
|||
label: 'Removal of content, blanking', |
|||
summary: 'Final warning: Removal of content, blanking' |
|||
}, |
|||
level4im: { |
|||
label: 'Removal of content, blanking', |
|||
summary: 'Only warning: Removal of content, blanking' |
|||
} |
|||
}, |
|||
'uw-generic': { |
|||
level4: { |
|||
label: 'Generic warning (for template series missing level 4)', |
|||
summary: 'Final warning notice' |
|||
} |
|||
} |
} |
||
}, |
}, |
||
"Behavior towards other editors": { |
|||
"uw-agf1": { |
|||
label: "Not assuming good faith", |
|||
level1: { |
|||
summary: "General note: Not assuming good faith" |
|||
label: 'Adding unreferenced controversial information about living persons', |
|||
summary: 'General note: Adding unreferenced controversial information about living persons' |
|||
}, |
|||
level2: { |
|||
label: 'Adding unreferenced controversial information about living persons', |
|||
summary: 'Caution: Adding unreferenced controversial information about living persons' |
|||
}, |
|||
level3: { |
|||
label: 'Adding unreferenced controversial/defamatory information about living persons', |
|||
summary: 'Warning: Adding unreferenced controversial information about living persons' |
|||
}, |
|||
level4: { |
|||
label: 'Adding unreferenced defamatory information about living persons', |
|||
summary: 'Final warning: Adding unreferenced controversial information about living persons' |
|||
}, |
|||
level4im: { |
|||
label: 'Adding unreferenced defamatory information about living persons', |
|||
summary: 'Only warning: Adding unreferenced controversial information about living persons' |
|||
} |
|||
}, |
}, |
||
"uw-harass1": { |
|||
label: "Harassment of other users", |
|||
level1: { |
|||
summary: "General note: Harassment of other users" |
|||
label: 'Addition of defamatory content', |
|||
summary: 'General note: Addition of defamatory content' |
|||
}, |
|||
level2: { |
|||
label: 'Addition of defamatory content', |
|||
summary: 'Caution: Addition of defamatory content' |
|||
}, |
|||
level3: { |
|||
label: 'Addition of defamatory content', |
|||
summary: 'Warning: Addition of defamatory content' |
|||
}, |
|||
level4: { |
|||
label: 'Addition of defamatory content', |
|||
summary: 'Final warning: Addition of defamatory content' |
|||
}, |
|||
level4im: { |
|||
label: 'Addition of defamatory content', |
|||
summary: 'Only warning: Addition of defamatory content' |
|||
} |
|||
}, |
}, |
||
"uw-pa1": { |
|||
label: "Personal attack directed at a specific editor", |
|||
level1: { |
|||
summary: "General note: Personal attack directed at a specific editor" |
|||
label: 'Introducing deliberate factual errors', |
|||
summary: 'General note: Introducing factual errors' |
|||
}, |
|||
level2: { |
|||
label: 'Introducing deliberate factual errors', |
|||
summary: 'Caution: Introducing factual errors' |
|||
}, |
|||
level3: { |
|||
label: 'Introducing deliberate factual errors', |
|||
summary: 'Warning: Introducing deliberate factual errors' |
|||
}, |
|||
level4: { |
|||
label: 'Introducing deliberate factual errors', |
|||
summary: 'Final warning: Introducing deliberate factual errors' |
|||
} |
|||
}, |
}, |
||
"uw-tempabuse1": { |
|||
label: "Improper use of warning or blocking template", |
|||
level1: { |
|||
summary: "General note: Improper use of warning or blocking template" |
|||
label: 'Introducing fringe theories', |
|||
} |
|||
summary: 'General note: Introducing fringe theories' |
|||
}, |
|||
}, |
|||
level2: { |
|||
label: 'Introducing fringe theories', |
|||
level2: { |
|||
summary: 'Caution: Introducing fringe theories' |
|||
"Common warnings": { |
|||
}, |
|||
"uw-vandalism2": { |
|||
label: "Vandalism", |
|||
summary: "Caution: Unconstructive editing" |
|||
} |
|||
}, |
}, |
||
"uw-test2": { |
|||
label: "Editing tests", |
|||
summary: "Caution: Editing tests" |
|||
label: 'Frequent or mass changes to genres without consensus or references', |
|||
summary: 'General note: Frequent or mass changes to genres without consensus or references' |
|||
}, |
|||
level2: { |
|||
label: 'Frequent or mass changes to genres without consensus or references', |
|||
summary: 'Caution: Frequent or mass changes to genres without consensus or references' |
|||
}, |
|||
level3: { |
|||
label: 'Frequent or mass changes to genres without consensus or reference', |
|||
summary: 'Warning: Frequent or mass changes to genres without consensus or reference' |
|||
}, |
|||
level4: { |
|||
label: 'Frequent or mass changes to genres without consensus or reference', |
|||
summary: 'Final warning: Frequent or mass changes to genres without consensus or reference' |
|||
} |
|||
}, |
}, |
||
}, |
|||
'uw-image': { |
|||
"Promotions and spam": { |
|||
level1: { |
|||
"uw-advert2": { |
|||
label: 'Image-related vandalism in articles', |
|||
label: "Using Meta for advertising or promotion", |
|||
summary: 'General note: Image-related vandalism in articles' |
|||
summary: "Caution: Using Meta for advertising or promotion" |
|||
}, |
|||
level2: { |
|||
label: 'Image-related vandalism in articles', |
|||
summary: 'Caution: Image-related vandalism in articles' |
|||
}, |
|||
level3: { |
|||
label: 'Image-related vandalism in articles', |
|||
summary: 'Warning: Image-related vandalism in articles' |
|||
}, |
|||
level4: { |
|||
label: 'Image-related vandalism in articles', |
|||
summary: 'Final warning: Image-related vandalism in articles' |
|||
}, |
|||
level4im: { |
|||
label: 'Image-related vandalism', |
|||
summary: 'Only warning: Image-related vandalism' |
|||
} |
|||
}, |
}, |
||
"uw-spam2": { |
|||
label: "Adding spam links", |
|||
level1: { |
|||
summary: "Caution: Adding spam links" |
|||
label: 'Using improper humor in articles', |
|||
} |
|||
summary: 'General note: Using improper humor in articles' |
|||
}, |
|||
"Behavior towards other editors": { |
|||
level2: { |
|||
"uw-agf2": { |
|||
label: 'Using improper humor in articles', |
|||
label: "Not assuming good faith", |
|||
summary: 'Caution: Using improper humor in articles' |
|||
summary: "Caution: Not assuming good faith" |
|||
}, |
|||
level3: { |
|||
label: 'Using improper humor in articles', |
|||
summary: 'Warning: Using improper humor in articles' |
|||
}, |
|||
level4: { |
|||
label: 'Using improper humor in articles', |
|||
summary: 'Final warning: Using improper humor in articles' |
|||
}, |
|||
level4im: { |
|||
label: 'Using improper humor', |
|||
summary: 'Only warning: Using improper humor' |
|||
} |
|||
}, |
}, |
||
"uw-harass2": { |
|||
label: "Harassment of other users", |
|||
level1: { |
|||
summary: "Caution: Harassment of other users" |
|||
label: 'Adding original research', |
|||
summary: 'General note: Adding original research' |
|||
}, |
|||
level2: { |
|||
label: 'Adding original research', |
|||
summary: 'Caution: Adding original research' |
|||
}, |
|||
level3: { |
|||
label: 'Adding original research', |
|||
summary: 'Warning: Adding original research' |
|||
}, |
|||
level4: { |
|||
label: 'Adding original research', |
|||
summary: 'Final warning: Adding original research' |
|||
} |
|||
}, |
}, |
||
"uw-pa2": { |
|||
label: "Personal attack directed at a specific editor", |
|||
level1: { |
|||
summary: "Caution: Personal attack directed at a specific editor" |
|||
label: 'Censorship of material', |
|||
summary: 'General note: Censorship of material' |
|||
}, |
|||
level2: { |
|||
label: 'Censorship of material', |
|||
summary: 'Caution: Censorship of material' |
|||
}, |
|||
level3: { |
|||
label: 'Censorship of material', |
|||
summary: 'Warning: Censorship of material' |
|||
} |
|||
}, |
}, |
||
"uw-tempabuse2": { |
|||
label: "Improper use of warning or blocking template", |
|||
level1: { |
|||
summary: "Caution: Improper use of warning or blocking template" |
|||
label: 'Ownership of articles', |
|||
} |
|||
summary: 'General note: Ownership of articles' |
|||
}, |
|||
}, |
|||
level2: { |
|||
label: 'Ownership of articles', |
|||
summary: 'Caution: Ownership of articles' |
|||
level3: { |
|||
}, |
|||
"Common warnings": { |
|||
"uw-vandalism3": { |
|||
label: 'Ownership of articles', |
|||
label: "Vandalism", |
|||
summary: 'Warning: Ownership of articles' |
|||
summary: "Warning: Vandalism" |
|||
}, |
|||
level4: { |
|||
label: 'Ownership of articles', |
|||
summary: 'Final warning: Ownership of articles' |
|||
}, |
|||
level4im: { |
|||
label: 'Ownership of articles', |
|||
summary: 'Only warning: Ownership of articles' |
|||
} |
|||
}, |
}, |
||
"uw-disruptive3": { |
|||
label: "Disruptive editing", |
|||
level1: { |
|||
summary: "Warning: Disruptive editing" |
|||
label: 'Subtle vandalism', |
|||
summary: 'General note: Possible unconstructive editing' |
|||
}, |
|||
level2: { |
|||
label: 'Subtle vandalism', |
|||
summary: 'Caution: Likely unconstructive editing' |
|||
}, |
|||
level3: { |
|||
label: 'Subtle vandalism', |
|||
summary: 'Warning: Subtle vandalism' |
|||
}, |
|||
level4: { |
|||
label: 'Subtle vandalism', |
|||
summary: 'Final warning: Subtle vandalism' |
|||
} |
|||
}, |
}, |
||
"uw-test3": { |
|||
label: "Editing tests", |
|||
summary: "Warning: Editing tests" |
|||
label: 'Removal of maintenance templates', |
|||
summary: 'General note: Removal of maintenance templates' |
|||
}, |
|||
level2: { |
|||
label: 'Removal of maintenance templates', |
|||
summary: 'Caution: Removal of maintenance templates' |
|||
}, |
|||
level3: { |
|||
label: 'Removal of maintenance templates', |
|||
summary: 'Warning: Removal of maintenance templates' |
|||
}, |
|||
level4: { |
|||
label: 'Removal of maintenance templates', |
|||
summary: 'Final warning: Removal of maintenance templates' |
|||
} |
|||
}, |
}, |
||
}, |
|||
'uw-unsourced': { |
|||
level1: { |
|||
"Promotions and spam": { |
|||
label: 'Addition of unsourced or improperly cited material', |
|||
"uw-advert3": { |
|||
summary: 'General note: Addition of unsourced or improperly cited material' |
|||
label: "Using Meta for advertising or promotion", |
|||
}, |
|||
summary: "Warning: Using Meta for advertising or promotion" |
|||
level2: { |
|||
}, |
|||
label: 'Addition of unsourced or improperly cited material', |
|||
"uw-spam3": { |
|||
summary: 'Caution: Addition of unsourced or improperly cited material' |
|||
label: "Adding spam links", |
|||
}, |
|||
summary: "Warning: Adding spam links" |
|||
level3: { |
|||
label: 'Addition of unsourced or improperly cited material', |
|||
summary: 'Warning: Addition of unsourced or improperly cited material' |
|||
}, |
|||
level4: { |
|||
label: 'Addition of unsourced or improperly cited material', |
|||
summary: 'Final warning: Addition of unsourced or improperly cited material' |
|||
} |
|||
} |
} |
||
}, |
}, |
||
"Behavior towards other users": { |
|||
'Promotions and spam': { |
|||
"uw-agf3": { |
|||
label: "Not assuming good faith", |
|||
level1: { |
|||
summary: "Warning: Not assuming good faith" |
|||
label: 'Using Wikipedia for advertising or promotion', |
|||
summary: 'General note: Using Wikipedia for advertising or promotion' |
|||
}, |
|||
level2: { |
|||
label: 'Using Wikipedia for advertising or promotion', |
|||
summary: 'Caution: Using Wikipedia for advertising or promotion' |
|||
}, |
|||
level3: { |
|||
label: 'Using Wikipedia for advertising or promotion', |
|||
summary: 'Warning: Using Wikipedia for advertising or promotion' |
|||
}, |
|||
level4: { |
|||
label: 'Using Wikipedia for advertising or promotion', |
|||
summary: 'Final warning: Using Wikipedia for advertising or promotion' |
|||
}, |
|||
level4im: { |
|||
label: 'Using Wikipedia for advertising or promotion', |
|||
summary: 'Only warning: Using Wikipedia for advertising or promotion' |
|||
} |
|||
}, |
}, |
||
"uw-harass3": { |
|||
label: "Harassment of other users", |
|||
level1: { |
|||
summary: "Warning: Harassment of other users" |
|||
label: 'Not adhering to neutral point of view', |
|||
summary: 'General note: Not adhering to neutral point of view' |
|||
}, |
|||
level2: { |
|||
label: 'Not adhering to neutral point of view', |
|||
summary: 'Caution: Not adhering to neutral point of view' |
|||
}, |
|||
level3: { |
|||
label: 'Not adhering to neutral point of view', |
|||
summary: 'Warning: Not adhering to neutral point of view' |
|||
}, |
|||
level4: { |
|||
label: 'Not adhering to neutral point of view', |
|||
summary: 'Final warning: Not adhering to neutral point of view' |
|||
} |
|||
}, |
}, |
||
"uw-pa3": { |
|||
label: "Personal attack directed at a specific editor", |
|||
level1: { |
|||
summary: "Warning: Personal attack directed at a specific editor" |
|||
label: 'Paid editing without disclosure under the Wikimedia Terms of Use', |
|||
summary: 'General note: Disclosure requirements for paid editing under the Wikimedia Terms of Use' |
|||
}, |
|||
level2: { |
|||
label: 'Paid editing without disclosure under the Wikimedia Terms of Use', |
|||
summary: 'Caution: Disclosure requirements for paid editing under the Wikimedia Terms of Use' |
|||
}, |
|||
level3: { |
|||
label: 'Paid editing without disclosure under the Wikimedia Terms of Use', |
|||
summary: 'Warning: Disclosure requirements for paid editing under the Wikimedia Terms of Use' |
|||
}, |
|||
level4: { |
|||
label: 'Paid editing without disclosure under the Wikimedia Terms of Use', |
|||
summary: 'Final warning: Disclosure requirements for paid editing under the Wikimedia Terms of Use' |
|||
} |
|||
}, |
|||
'uw-spam': { |
|||
level1: { |
|||
label: 'Adding inappropriate external links', |
|||
summary: 'General note: Adding inappropriate external links' |
|||
}, |
|||
level2: { |
|||
label: 'Adding spam links', |
|||
summary: 'Caution: Adding spam links' |
|||
}, |
|||
level3: { |
|||
label: 'Adding spam links', |
|||
summary: 'Warning: Adding spam links' |
|||
}, |
|||
level4: { |
|||
label: 'Adding spam links', |
|||
summary: 'Final warning: Adding spam links' |
|||
}, |
|||
level4im: { |
|||
label: 'Adding spam links', |
|||
summary: 'Only warning: Adding spam links' |
|||
} |
|||
} |
} |
||
}, |
}, |
||
}, |
|||
'Behavior towards other editors': { |
|||
'uw-agf': { |
|||
level1: { |
|||
level4: { |
|||
label: 'Not assuming good faith', |
|||
"Common warnings": { |
|||
summary: 'General note: Not assuming good faith' |
|||
"uw-generic4": { |
|||
}, |
|||
label: "Generic warning (for template series missing level 4)", |
|||
level2: { |
|||
summary: "Final warning notice" |
|||
label: 'Not assuming good faith', |
|||
summary: 'Caution: Not assuming good faith' |
|||
}, |
|||
level3: { |
|||
label: 'Not assuming good faith', |
|||
summary: 'Warning: Not assuming good faith' |
|||
} |
|||
}, |
}, |
||
"uw-vandalism4": { |
|||
label: "Vandalism", |
|||
summary: "Final warning: Vandalism" |
|||
label: 'Harassment of other users', |
|||
summary: 'General note: Harassment of other users' |
|||
}, |
|||
level2: { |
|||
label: 'Harassment of other users', |
|||
summary: 'Caution: Harassment of other users' |
|||
}, |
|||
level3: { |
|||
label: 'Harassment of other users', |
|||
summary: 'Warning: Harassment of other users' |
|||
}, |
|||
level4: { |
|||
label: 'Harassment of other users', |
|||
summary: 'Final warning: Harassment of other users' |
|||
}, |
|||
level4im: { |
|||
label: 'Harassment of other users', |
|||
summary: 'Only warning: Harassment of other users' |
|||
} |
|||
}, |
}, |
||
"uw-delete4": { |
|||
label: "Removal of content, blanking", |
|||
level1: { |
|||
summary: "Final warning: Removal of content, blanking" |
|||
label: 'Personal attack directed at a specific editor', |
|||
} |
|||
summary: 'General note: Personal attack directed at a specific editor' |
|||
}, |
|||
"Promotions and spam": { |
|||
level2: { |
|||
"uw-advert4": { |
|||
label: 'Personal attack directed at a specific editor', |
|||
label: "Using Meta for advertising or promotion", |
|||
summary: 'Caution: Personal attack directed at a specific editor' |
|||
summary: "Final warning: Using Meta for advertising or promotion" |
|||
}, |
|||
level3: { |
|||
label: 'Personal attack directed at a specific editor', |
|||
summary: 'Warning: Personal attack directed at a specific editor' |
|||
}, |
|||
level4: { |
|||
label: 'Personal attack directed at a specific editor', |
|||
summary: 'Final warning: Personal attack directed at a specific editor' |
|||
}, |
|||
level4im: { |
|||
label: 'Personal attack directed at a specific editor', |
|||
summary: 'Only warning: Personal attack directed at a specific editor' |
|||
} |
|||
}, |
}, |
||
"uw-spam4": { |
|||
label: "Adding spam links", |
|||
level1: { |
|||
summary: "Final warning: Adding spam links" |
|||
summary: 'General note: Improper use of warning or blocking template' |
|||
}, |
|||
level2: { |
|||
label: 'Improper use of warning or blocking template', |
|||
summary: 'Caution: Improper use of warning or blocking template' |
|||
} |
|||
} |
} |
||
}, |
}, |
||
"Behavior towards other editors": { |
|||
'Removal of deletion tags': { |
|||
"uw-harass4": { |
|||
label: "Harassment of other users", |
|||
level1: { |
|||
summary: "Final warning: Harassment of other users" |
|||
label: 'Removing {{afd}} templates', |
|||
summary: 'General note: Removing {{afd}} templates' |
|||
}, |
|||
level2: { |
|||
label: 'Removing {{afd}} templates', |
|||
summary: 'Caution: Removing {{afd}} templates' |
|||
}, |
|||
level3: { |
|||
label: 'Removing {{afd}} templates', |
|||
summary: 'Warning: Removing {{afd}} templates' |
|||
}, |
|||
level4: { |
|||
label: 'Removing {{afd}} templates', |
|||
summary: 'Final warning: Removing {{afd}} templates' |
|||
} |
|||
}, |
}, |
||
"uw-pa4": { |
|||
label: "Personal attack directed at a specific editor", |
|||
level1: { |
|||
summary: "Final warning: Personal attack directed at a specific editor" |
|||
label: 'Removing {{blp prod}} templates', |
|||
} |
|||
summary: 'General note: Removing {{blp prod}} templates' |
|||
}, |
|||
}, |
|||
level2: { |
|||
label: 'Removing {{blp prod}} templates', |
|||
level4im: { |
|||
summary: 'Caution: Removing {{blp prod}} templates' |
|||
"Common warnings": { |
|||
}, |
|||
"uw-vandalism4im": { |
|||
label: "Vandalism", |
|||
summary: "Only warning: Vandalism" |
|||
}, |
|||
level4: { |
|||
label: 'Removing {{blp prod}} templates', |
|||
summary: 'Final warning: Removing {{blp prod}} templates' |
|||
} |
|||
}, |
}, |
||
"uw-delete4im": { |
|||
label: "Removal of content, blanking", |
|||
level1: { |
|||
summary: "Only warning: Removal of content, blanking" |
|||
label: 'Removing file deletion tags', |
|||
summary: 'General note: Removing file deletion tags' |
|||
}, |
|||
level2: { |
|||
label: 'Removing file deletion tags', |
|||
summary: 'Caution: Removing file deletion tags' |
|||
}, |
|||
level3: { |
|||
label: 'Removing file deletion tags', |
|||
summary: 'Warning: Removing file deletion tags' |
|||
}, |
|||
level4: { |
|||
label: 'Removing file deletion tags', |
|||
summary: 'Final warning: Removing file deletion tags' |
|||
} |
|||
}, |
}, |
||
"uw-upvio-wikiname": { |
|||
label: "Username policy violation (Wikiname)", |
|||
level1: { |
|||
summary: "Only warning: Violation of the username policy (wikiname)" |
|||
label: 'Removing {{tfd}} templates', |
|||
} |
|||
summary: 'General note: Removing {{tfd}} templates' |
|||
}, |
|||
"Promotions and spam": { |
|||
level2: { |
|||
"uw-advert4im": { |
|||
label: 'Removing {{tfd}} templates', |
|||
label: "Using Meta for advertising or promotion", |
|||
summary: 'Caution: Removing {{tfd}} templates' |
|||
summary: "Only warning: Using Meta for advertising or promotion" |
|||
}, |
|||
level3: { |
|||
label: 'Removing {{tfd}} templates', |
|||
summary: 'Warning: Removing {{tfd}} templates' |
|||
}, |
|||
level4: { |
|||
label: 'Removing {{tfd}} templates', |
|||
summary: 'Final warning: Removing {{tfd}} templates' |
|||
} |
|||
}, |
}, |
||
"uw-spam4im": { |
|||
label: "Adding spam links", |
|||
level1: { |
|||
summary: "Only warning: Adding spam links" |
|||
label: 'Removing speedy deletion tags', |
|||
summary: 'General note: Removing speedy deletion tags' |
|||
}, |
|||
level2: { |
|||
label: 'Removing speedy deletion tags', |
|||
summary: 'Caution: Removing speedy deletion tags' |
|||
}, |
|||
level3: { |
|||
label: 'Removing speedy deletion tags', |
|||
summary: 'Warning: Removing speedy deletion tags' |
|||
}, |
|||
level4: { |
|||
label: 'Removing speedy deletion tags', |
|||
summary: 'Final warning: Removing speedy deletion tags' |
|||
} |
|||
} |
} |
||
}, |
}, |
||
"Behavior towards other editors": { |
|||
'Other': { |
|||
"uw-harass4im": { |
|||
label: "Harassment of other users", |
|||
level1: { |
|||
summary: "Only warning: Harassment of other users" |
|||
label: 'Triggering the edit filter', |
|||
summary: 'General note: Triggering the edit filter' |
|||
}, |
|||
level2: { |
|||
label: 'Triggering the edit filter', |
|||
summary: 'Caution: Triggering the edit filter' |
|||
}, |
|||
level3: { |
|||
label: 'Triggering the edit filter', |
|||
summary: 'Warning: Triggering the edit filter' |
|||
}, |
|||
level4: { |
|||
label: 'Triggering the edit filter', |
|||
summary: 'Final warning: Triggering the edit filter' |
|||
}, |
|||
level4im: { |
|||
label: 'Triggering the edit filter', |
|||
summary: 'Only warning: Triggering the edit filter' |
|||
} |
|||
}, |
}, |
||
"uw-npa4im": { |
|||
label: "Personal attack directed at a specific editor", |
|||
level1: { |
|||
summary: "Only warning: Personal attack directed at a specific editor" |
|||
label: 'Using talk page as forum', |
|||
} |
|||
summary: 'General note: Using talk page as forum' |
|||
}, |
|||
"Other": { |
|||
"uw-create4im": { |
|||
label: 'Using talk page as forum', |
|||
label: "Creating inappropriate pages", |
|||
summary: 'Caution: Using talk page as forum' |
|||
summary: "Only warning: Creating inappropriate pages" |
|||
}, |
|||
level3: { |
|||
label: 'Using talk page as forum', |
|||
summary: 'Warning: Using talk page as forum' |
|||
}, |
|||
level4: { |
|||
label: 'Using talk page as forum', |
|||
summary: 'Final warning: Using talk page as forum' |
|||
} |
|||
}, |
}, |
||
"uw-move4im": { |
|||
label: "Page moves against naming conventions or consensus", |
|||
level1: { |
|||
summary: "Only warning: Page moves against naming conventions or consensus" |
|||
label: 'Creating inappropriate pages', |
|||
summary: 'General note: Creating inappropriate pages' |
|||
}, |
|||
level2: { |
|||
label: 'Creating inappropriate pages', |
|||
summary: 'Caution: Creating inappropriate pages' |
|||
}, |
|||
level3: { |
|||
label: 'Creating inappropriate pages', |
|||
summary: 'Warning: Creating inappropriate pages' |
|||
}, |
|||
level4: { |
|||
label: 'Creating inappropriate pages', |
|||
summary: 'Final warning: Creating inappropriate pages' |
|||
}, |
|||
level4im: { |
|||
label: 'Creating inappropriate pages', |
|||
summary: 'Only warning: Creating inappropriate pages' |
|||
} |
|||
}, |
}, |
||
"uw-upload4im": { |
|||
label: "Uploading unencyclopedic images", |
|||
level1: { |
|||
summary: "Only warning: Uploading unencyclopedic images" |
|||
label: 'Manual of style', |
|||
} |
|||
summary: 'General note: Formatting, date, language, etc (Manual of style)' |
|||
}/*, |
|||
"To be removed from Twinkle": { |
|||
level2: { |
|||
"uw-af4im": { |
|||
label: 'Manual of style', |
|||
label: "Inappropriate feedback through the Article Feedback Tool", |
|||
summary: 'Caution: Formatting, date, language, etc (Manual of style)' |
|||
summary: "Only warning: Inappropriate feedback through the Article Feedback Tool" |
|||
}, |
|||
level3: { |
|||
label: 'Manual of style', |
|||
summary: 'Warning: Formatting, date, language, etc (Manual of style)' |
|||
}, |
|||
level4: { |
|||
label: 'Manual of style', |
|||
summary: 'Final warning: Formatting, date, language, etc (Manual of style)' |
|||
} |
|||
}, |
|||
'uw-move': { |
|||
level1: { |
|||
label: 'Page moves against naming conventions or consensus', |
|||
summary: 'General note: Page moves against naming conventions or consensus' |
|||
}, |
|||
level2: { |
|||
label: 'Page moves against naming conventions or consensus', |
|||
summary: 'Caution: Page moves against naming conventions or consensus' |
|||
}, |
|||
level3: { |
|||
label: 'Page moves against naming conventions or consensus', |
|||
summary: 'Warning: Page moves against naming conventions or consensus' |
|||
}, |
|||
level4: { |
|||
label: 'Page moves against naming conventions or consensus', |
|||
summary: 'Final warning: Page moves against naming conventions or consensus' |
|||
}, |
|||
level4im: { |
|||
label: 'Page moves against naming conventions or consensus', |
|||
summary: 'Only warning: Page moves against naming conventions or consensus' |
|||
} |
|||
}, |
|||
'uw-tpv': { |
|||
level1: { |
|||
label: "Refactoring others' talk page comments", |
|||
summary: "General note: Refactoring others' talk page comments" |
|||
}, |
|||
level2: { |
|||
label: "Refactoring others' talk page comments", |
|||
summary: "Caution: Refactoring others' talk page comments" |
|||
}, |
|||
level3: { |
|||
label: "Refactoring others' talk page comments", |
|||
summary: "Warning: Refactoring others' talk page comments" |
|||
}, |
|||
level4: { |
|||
label: "Refactoring others' talk page comments", |
|||
summary: "Final warning: Refactoring others' talk page comments" |
|||
}, |
|||
level4im: { |
|||
label: "Refactoring others' talk page comments", |
|||
summary: "Only warning: Refactoring others' talk page comments" |
|||
} |
|||
}, |
}, |
||
"uw-redirect4im": { |
|||
label: "Creating malicious redirects", |
|||
level1: { |
|||
summary: "Only warning: Creating malicious redirects" |
|||
label: 'Uploading unencyclopedic images', |
|||
summary: 'General note: Uploading unencyclopedic images' |
|||
}, |
|||
level2: { |
|||
label: 'Uploading unencyclopedic images', |
|||
summary: 'Caution: Uploading unencyclopedic images' |
|||
}, |
|||
level3: { |
|||
label: 'Uploading unencyclopedic images', |
|||
summary: 'Warning: Uploading unencyclopedic images' |
|||
}, |
|||
level4: { |
|||
label: 'Uploading unencyclopedic images', |
|||
summary: 'Final warning: Uploading unencyclopedic images' |
|||
}, |
|||
level4im: { |
|||
label: 'Uploading unencyclopedic images', |
|||
summary: 'Only warning: Uploading unencyclopedic images' |
|||
} |
|||
} |
} |
||
} |
}*/ |
||
}, |
}, |
||
singlenotice: { |
singlenotice: { |
||
"uw-2redirect": { |
|||
label: |
label: "Creating double redirects through bad page moves", |
||
summary: |
summary: "Notice: Creating double redirects through bad page moves" |
||
}, |
}, |
||
"uw-warn": { |
|||
label: "Place user warning templates when reverting vandalism", |
|||
label: 'Bad AIV report', |
|||
summary: |
summary: "Notice: You can use user warning templates when reverting vandalism" |
||
} |
|||
}, |
|||
singlewarn: { |
|||
"uw-3rr": { |
|||
label: "Violating the three-revert rule; see also uw-ew", |
|||
summary: "Warning: Violating the three-revert rule" |
|||
}, |
}, |
||
"uw-affiliate": { |
|||
label: |
label: "Affiliate marketing", |
||
summary: |
summary: "Warning: Affiliate marketing" |
||
hideReason: true |
|||
}, |
}, |
||
"uw-agf-sock": { |
|||
label: "Use of multiple accounts (assuming good faith)", |
|||
label: 'Creating autobiographies', |
|||
summary: |
summary: "Warning: Using multiple accounts" |
||
}, |
}, |
||
"uw-attack": { |
|||
label: |
label: "Creating attack pages", |
||
summary: |
summary: "Warning: Creating attack pages", |
||
suppressArticleInSummary: true |
|||
}, |
}, |
||
"uw-attempt": { |
|||
label: |
label: "Triggering the edit filter", |
||
summary: |
summary: "Warning: Triggering the edit filter" |
||
}, |
}, |
||
"uw-bizlist": { |
|||
label: |
label: "Business promotion", |
||
summary: |
summary: "Warning: Promoting a business" |
||
suppressArticleInSummary: true // non-standard (user name, not article), and not necessary |
|||
}, |
}, |
||
"uw-botun": { |
|||
label: |
label: "Bot username", |
||
summary: |
summary: "Warning: Bot username" |
||
hideReason: true |
|||
}, |
}, |
||
"uw-canvass": { |
|||
label: |
label: "Canvassing", |
||
summary: |
summary: "Warning: Canvassing" |
||
heading: 'Managing a conflict of interest' |
|||
}, |
}, |
||
"uw-copyright": { |
|||
label: |
label: "Copyright violation", |
||
summary: |
summary: "Warning: Copyright violation" |
||
}, |
}, |
||
"uw-copyright-link": { |
|||
label: |
label: "Linking to copyrighted works violation", |
||
summary: |
summary: "Warning: Linking to copyrighted works violation" |
||
}, |
}, |
||
"uw-copyright-new": { |
|||
label: |
label: "Copyright violation (with explanation for new users)", |
||
summary: |
summary: "Notice: Avoiding copyright problems", |
||
heading: "Meta and copyright" |
|||
}, |
}, |
||
"uw-copyright-remove": { |
|||
label: |
label: "Removing {{copyvio}} template from articles", |
||
summary: |
summary: "Warning: Removing {{copyvio}} templates" |
||
}, |
}, |
||
"uw-efsummary": { |
|||
label: |
label: "Edit summary triggering the edit filter", |
||
summary: |
summary: "Warning: Edit summary triggering the edit filter" |
||
}, |
}, |
||
"uw-ew": { |
|||
label: |
label: "Edit warring (stronger wording)", |
||
summary: |
summary: "Warning: Edit warring" |
||
}, |
}, |
||
"uw-ewsoft": { |
|||
label: |
label: "Edit warring (softer wording for newcomers)", |
||
summary: |
summary: "Warning: Edit warring" |
||
}, |
}, |
||
"uw-hoax": { |
|||
label: |
label: "Creating hoaxes", |
||
summary: |
summary: "Warning: Creating hoaxes" |
||
}, |
}, |
||
"uw-legal": { |
|||
label: "Making legal threats", |
|||
label: 'User should draft in userspace without the risk of speedy deletion', |
|||
summary: "Warning: Making legal threats" |
|||
summary: 'Notice: Consider drafting your article in [[Help:Userspace draft|userspace]]' |
|||
}, |
}, |
||
"uw-login": { |
|||
label: |
label: "Editing while logged out", |
||
summary: |
summary: "Warning: Editing while logged out" |
||
}, |
}, |
||
"uw-longterm": { |
|||
label: |
label: "Long term pattern of vandalism", |
||
summary: |
summary: "Warning: Long term pattern of vandalism" |
||
hideLinkedPage: true, |
|||
hideReason: true |
|||
}, |
}, |
||
"uw-multipleIPs": { |
|||
label: |
label: "Usage of multiple IPs", |
||
summary: "Warning: Usage of multiple IPs" |
|||
summary: 'Notice: Keep external links to External links sections at the bottom of an article' |
|||
}, |
}, |
||
"uw-pinfo": { |
|||
label: |
label: "Personal info", |
||
summary: |
summary: "Warning: Personal info" |
||
}, |
}, |
||
"uw-socksuspect": { |
|||
label: |
label: "Sockpuppetry", |
||
summary: "Warning: You are a suspected [[WP:SOCK|sockpuppet]]" // of User:... |
|||
summary: 'Notice: Allow creators time to improve their articles before tagging them for deletion' |
|||
}, |
}, |
||
"uw-upv": { |
|||
label: |
label: "Userpage vandalism", |
||
summary: |
summary: "Warning: Userpage vandalism" |
||
}, |
}, |
||
"uw-username": { |
|||
label: "Username is against policy", |
|||
label: 'Italicize books, films, albums, magazines, TV series, etc within articles', |
|||
summary: |
summary: "Warning: Your username might be against policy", |
||
suppressArticleInSummary: true // not relevant for this template |
|||
}, |
}, |
||
"uw-coi-username": { |
|||
label: |
label: "Username is against policy, and conflict of interest", |
||
summary: |
summary: "Warning: Username and conflict of interest policy", |
||
heading: |
heading: "Your username" |
||
}, |
}, |
||
"uw-userpage": { |
|||
label: |
label: "Userpage or subpage is against policy", |
||
summary: |
summary: "Warning: Userpage or subpage is against policy" |
||
}, |
}, |
||
"uw-wrongsummary": { |
|||
label: |
label: "Using inaccurate or inappropriate edit summaries", |
||
summary: |
summary: "Warning: Using inaccurate or inappropriate edit summaries" |
||
} |
|||
}, |
|||
block: { |
|||
"uw-block": { |
|||
label: "Block", |
|||
summary: "You have been blocked from editing", |
|||
pageParam: true, |
|||
reasonParam: true, // allows editing of reason for generic templates |
|||
suppressArticleInSummary: true |
|||
}, |
}, |
||
"uw-blocknotalk": { |
|||
label: |
label: "Block - talk page disabled", |
||
summary: "You have been blocked from editing and your user talk page has been disabled", |
|||
summary: 'Notice: Creating non-English articles' |
|||
pageParam: true, |
|||
reasonParam: true, |
|||
suppressArticleInSummary: true |
|||
}, |
}, |
||
"uw-blockindef": { |
|||
label: |
label: "Block - indefinite", |
||
summary: |
summary: "You have been indefinitely blocked from editing", |
||
indefinite: true, |
|||
pageParam: true, |
|||
reasonParam: true, |
|||
suppressArticleInSummary: true |
|||
}, |
}, |
||
"uw-ablock": { |
|||
label: |
label: "Block - IP address", |
||
summary: |
summary: "Your IP address has been blocked from editing", |
||
pageParam: true, |
|||
suppressArticleInSummary: true |
|||
}, |
}, |
||
"uw-vblock": { |
|||
label: "Vandalism block", |
|||
label: 'Copying from public domain sources without attribution', |
|||
summary: "You have been blocked from editing for persistent [[WP:VAND|vandalism]]", |
|||
summary: 'Notice: Copying from public domain sources without attribution' |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-voablock": { |
|||
label: |
label: "Vandalism-only account block (indefinite)", |
||
summary: "You have been indefinitely blocked from editing because your account is being [[WP:VOA|used only for vandalism]]", |
|||
summary: 'Notice: Use preview button to avoid mistakes' |
|||
indefinite: true, |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-sblock": { |
|||
label: |
label: "Spam block", |
||
summary: "You have been blocked from editing for using Meta for spam purposes" |
|||
summary: 'Notice: Be careful when removing redlinks' |
|||
}, |
}, |
||
"uw-adblock": { |
|||
label: "Advertising block", |
|||
label: 'Adding citations to research published by a small group of researchers', |
|||
summary: "You have been blocked from editing for [[WP:SOAP|advertising or self-promotion]]", |
|||
summary: 'Notice: Adding citations to research published by a small group of researchers', |
|||
pageParam: true |
|||
hideReason: true |
|||
}, |
}, |
||
"uw-soablock": { |
|||
label: |
label: "Spam/advertising-only account block (indefinite)", |
||
summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:SPAM|spam, advertising, or promotion]]", |
|||
summary: 'Notice: Self-reverted editing tests' |
|||
indefinite: true, |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-npblock": { |
|||
label: |
label: "Creating nonsense pages block", |
||
summary: "You have been blocked from editing for creating [[WP:PN|nonsense pages]]", |
|||
summary: 'Notice: Wikipedia is not a social network' |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-copyrightblock": { |
|||
label: |
label: "Copyright violation block", |
||
summary: |
summary: "You have been blocked from editing for continued [[WP:COPYVIO|copyright infringement]]", |
||
pageParam: true |
|||
}, |
}, |
||
"uw-spoablock": { |
|||
label: "Sockpuppet account block (indefinite)", |
|||
label: 'Adding spoiler alerts or removing spoilers from appropriate sections', |
|||
summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:SOCK|sock puppetry]]", |
|||
summary: "Notice: Don't delete or flag potential 'spoilers' in Wikipedia articles" |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-ipevadeblock": { |
|||
label: |
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]]" |
|||
summary: 'Notice: Talk in article' |
|||
}, |
}, |
||
"uw-hblock": { |
|||
label: |
label: "Harassment block", |
||
summary: "You have been blocked from editing for attempting to [[WP:HARASS|harass]] other users", |
|||
summary: 'Notice: Not signing posts' |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-disruptblock": { |
|||
label: |
label: "Disruptive editing block", |
||
summary: |
summary: "You have been blocked from editing for [[WP:DE|disruptive editing]]", |
||
pageParam: true |
|||
}, |
}, |
||
"uw-deoablock": { |
|||
label: "Disruption/trolling-only account block (indefinite)", |
|||
label: 'Adding translations without proper attribution', |
|||
summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:DE|trolling, disruption or harassment]]", |
|||
summary: 'Notice: Attribution required when translating articles' |
|||
indefinite: true, |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-lblock": { |
|||
label: "Legal threat block (indefinite)", |
|||
label: 'Copying from compatibly-licensed sources without attribution', |
|||
summary: "You have been indefinitely blocked from editing for making [[WP:NLT|legal threats or taking legal action]]", |
|||
summary: 'Notice: Copying from compatibly-licensed sources without attribution' |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-aeblock": { |
|||
label: |
label: "Arbitration enforcement block", |
||
summary: "You have been blocked from editing for violating an [[WP:Arbitration|arbitration decision]] with your edits", |
|||
summary: 'Notice: Stale userspace draft' |
|||
pageParam: true, |
|||
reasonParam: true |
|||
}, |
}, |
||
"uw-efblock": { |
|||
label: "Edit filter-related block", |
|||
label: 'Adding video game walkthroughs, cheats or instructions', |
|||
summary: "You have been blocked from editing for making disruptive edits that repeatedly triggered the [[WP:EF|edit filter]]" |
|||
summary: 'Notice: Adding video game walkthroughs, cheats or instructions' |
|||
}, |
}, |
||
"uw-myblock": { |
|||
label: "Social networking block", |
|||
label: 'Place user warning templates when reverting vandalism', |
|||
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]]", |
|||
summary: 'Notice: You can use user warning templates when reverting vandalism' |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-dblock": { |
|||
label: "Deletion/removal of content block", |
|||
label: 'Using inaccurate or inappropriate edit summaries', |
|||
summary: "You have been blocked from editing for continued [[WP:VAND|removal of material]]", |
|||
summary: 'Notice: Using inaccurate or inappropriate edit summaries' |
|||
pageParam: true |
|||
} |
|||
}, |
|||
singlewarn: { |
|||
'uw-3rr': { |
|||
label: 'Potential three-revert rule violation; see also uw-ew', |
|||
summary: 'Warning: Three-revert rule' |
|||
}, |
}, |
||
"uw-compblock": { |
|||
label: "Possible compromised account block (indefinite)", |
|||
label: 'Affiliate marketing', |
|||
summary: "You have been indefinitely blocked from editing because it is believed that your [[WP:SECURE|account has been compromised]]", |
|||
summary: 'Warning: Affiliate marketing' |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-botblock": { |
|||
label: |
label: "Unapproved bot block", |
||
summary: "You have been blocked from editing because it appears you are running a [[WP:BOT|bot script]] without [[WP:BRFA|approval]]", |
|||
summary: 'Warning: Creating attack pages', |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-ublock": { |
|||
label: |
label: "Username soft block (indefinite)", |
||
summary: "You have been indefinitely blocked from editing because your username is a violation of the [[WP:U|username policy]]", |
|||
summary: 'Warning: Bot username' |
|||
indefinite: true, |
|||
reasonParam: true |
|||
}, |
}, |
||
"uw-uhblock": { |
|||
label: |
label: "Username hard block (indefinite)", |
||
summary: "You have been indefinitely blocked from editing because your username is a blatant violation of the [[WP:U|username policy]]", |
|||
summary: 'Warning: Canvassing' |
|||
indefinite: true, |
|||
reasonParam: true |
|||
}, |
}, |
||
"uw-softerblock": { |
|||
label: |
label: "Promotional username soft block (indefinite)", |
||
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", |
|||
summary: 'Warning: Copyright violation' |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-causeblock": { |
|||
label: "Promotional username soft block, for charitable causes (indefinite)", |
|||
label: 'Linking to copyrighted works violation', |
|||
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", |
|||
summary: 'Warning: Linking to copyrighted works violation' |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-botublock": { |
|||
label: |
label: "Bot username soft block (indefinite)", |
||
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", |
|||
summary: 'Notice: Avoiding copyright problems', |
|||
indefinite: true |
|||
heading: 'Wikipedia and copyright' |
|||
}, |
}, |
||
"uw-memorialblock": { |
|||
label: |
label: "Memorial username soft block (indefinite)", |
||
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", |
|||
summary: 'Warning: Removing {{copyvio}} templates' |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-ublock-famous": { |
|||
label: |
label: "Famous username soft block (indefinite)", |
||
summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] matches the name of a well-known living individual", |
|||
summary: 'Warning: Edit summary triggering the edit filter' |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-ublock-double": { |
|||
label: |
label: "Similar username soft block (indefinite)", |
||
summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] is too similar to the username of another Meta user", |
|||
summary: 'Warning: Edit warring' |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-uhblock-double": { |
|||
label: |
label: "Username impersonation hard block (indefinite)", |
||
summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] appears to impersonate another established Meta user", |
|||
summary: 'Warning: Edit warring' |
|||
indefinite: true |
|||
}, |
}, |
||
"uw-vaublock": { |
|||
label: "Vandalism-only account and username hard block (indefinite)", |
|||
label: 'Hijacking articles', |
|||
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]]", |
|||
summary: 'Warning: Hijacking articles' |
|||
indefinite: true, |
|||
pageParam: true |
|||
}, |
}, |
||
"uw-spamublock": { |
|||
label: "Spam-only account and promotional username hard block (indefinite)", |
|||
label: 'Creating hoaxes', |
|||
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]]", |
|||
summary: 'Warning: Creating hoaxes' |
|||
indefinite: true |
|||
}, |
|||
'uw-legal': { |
|||
label: 'Making legal threats', |
|||
summary: 'Warning: Making legal threats' |
|||
}, |
|||
'uw-login': { |
|||
label: 'Editing while logged out', |
|||
summary: 'Warning: Editing while logged out' |
|||
}, |
|||
'uw-multipleIPs': { |
|||
label: 'Usage of multiple IPs', |
|||
summary: 'Warning: Vandalism using multiple IPs' |
|||
}, |
|||
'uw-paraphrase': { |
|||
label: 'Close paraphrasing', |
|||
summary: 'Warning: Close paraphrasing' |
|||
}, |
|||
'uw-pinfo': { |
|||
label: 'Personal info (outing)', |
|||
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': { |
|||
label: 'Sockpuppetry', |
|||
summary: 'Warning: You are a suspected [[WP:SOCK|sockpuppet]]' // of User:... |
|||
}, |
|||
'uw-upv': { |
|||
label: 'Userpage vandalism', |
|||
summary: 'Warning: Userpage vandalism' |
|||
}, |
|||
'uw-username': { |
|||
label: 'Username is against policy', |
|||
summary: 'Warning: Your username might be against policy', |
|||
suppressArticleInSummary: true // not relevant for this template |
|||
}, |
|||
'uw-coi-username': { |
|||
label: 'Username is against policy, and conflict of interest', |
|||
summary: 'Warning: Username and conflict of interest', |
|||
heading: 'Your username' |
|||
}, |
|||
'uw-userpage': { |
|||
label: 'Userpage or subpage is against policy', |
|||
summary: 'Warning: Userpage or subpage is against policy' |
|||
} |
} |
||
} |
} |
||
}; |
}; |
||
Twinkle.warn.prev_block_timer = null; |
|||
/** |
|||
Twinkle.warn.prev_block_reason = null; |
|||
* Reads Twinkle.warn.messages and returns a specified template's property (such as label, summary, |
|||
* suppressArticleInSummary, hideLinkedPage, or hideReason) |
|||
*/ |
|||
Twinkle.warn.getTemplateProperty = function(templates, templateName, propertyName) { |
|||
var result; |
|||
var isNumberedTemplate = templateName.match(/(1|2|3|4|4im)$/); |
|||
if (isNumberedTemplate) { |
|||
var unNumberedTemplateName = templateName.replace(/(?:1|2|3|4|4im)$/, ''); |
|||
var level = isNumberedTemplate[0]; |
|||
var numberedWarnings = {}; |
|||
$.each(templates.levels, function(key, val) { |
|||
$.extend(numberedWarnings, val); |
|||
}); |
|||
$.each(numberedWarnings, function(key) { |
|||
if (key === unNumberedTemplateName) { |
|||
result = numberedWarnings[key]['level' + level][propertyName]; |
|||
} |
|||
}); |
|||
} |
|||
// Non-level templates can also end in a number. So check this for all templates. |
|||
var otherWarnings = {}; |
|||
$.each(templates, function(key, val) { |
|||
if (key !== 'levels') { |
|||
$.extend(otherWarnings, val); |
|||
} |
|||
}); |
|||
$.each(otherWarnings, function(key) { |
|||
if (key === templateName) { |
|||
result = otherWarnings[key][propertyName]; |
|||
} |
|||
}); |
|||
return result; |
|||
}; |
|||
// Used repeatedly below across menu rebuilds |
|||
Twinkle.warn.prev_article = null; |
Twinkle.warn.prev_article = null; |
||
Twinkle.warn.prev_reason = null; |
Twinkle.warn.prev_reason = null; |
||
Twinkle.warn.talkpageObj = null; |
|||
Twinkle.warn.callback.change_category = function twinklewarnCallbackChangeCategory(e) { |
Twinkle.warn.callback.change_category = function twinklewarnCallbackChangeCategory(e) { |
||
Line 1,295: | Line 666: | ||
var old_subvalue = sub_group.value; |
var old_subvalue = sub_group.value; |
||
var old_subvalue_re; |
var old_subvalue_re; |
||
if |
if( old_subvalue ) { |
||
old_subvalue = old_subvalue.replace(/\d*(im)?$/, '' ); |
|||
if (value === 'kitchensink') { // Exact match possible in kitchensink menu |
|||
old_subvalue_re = new RegExp( $.escapeRE( old_subvalue ) + "(\\d*(?:im)?)$" ); |
|||
} else { |
|||
old_subvalue = old_subvalue.replace(/\d*(im)?$/, ''); |
|||
old_subvalue_re = new RegExp(mw.util.escapeRegExp(old_subvalue) + '(\\d*(?:im)?)$'); |
|||
} |
|||
} |
} |
||
while |
while( sub_group.hasChildNodes() ){ |
||
sub_group.removeChild(sub_group.firstChild); |
sub_group.removeChild( sub_group.firstChild ); |
||
} |
} |
||
var selected = false; |
|||
// worker function to create the combo box entries |
// worker function to create the combo box entries |
||
var createEntries = function(contents, container, wrapInOptgroup |
var createEntries = function( contents, container, wrapInOptgroup ) { |
||
val = typeof val !== 'undefined' ? val : value; // IE doesn't support default parameters |
|||
// level2->2, singlewarn->''; also used to distinguish the |
|||
// scaled levels from singlenotice, singlewarn, and custom |
|||
var level = val.replace(/^\D+/g, ''); |
|||
// due to an apparent iOS bug, we have to add an option-group to prevent truncation of text |
// 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") |
// (search WT:TW archives for "Problem selecting warnings on an iPhone") |
||
if (wrapInOptgroup && $.client.profile().platform === |
if ( wrapInOptgroup && $.client.profile().platform === "iphone" ) { |
||
var wrapperOptgroup = new Morebits.quickForm.element({ |
var wrapperOptgroup = new Morebits.quickForm.element( { |
||
type: 'optgroup', |
type: 'optgroup', |
||
label: 'Available templates' |
label: 'Available templates' |
||
}); |
} ); |
||
wrapperOptgroup = wrapperOptgroup.render(); |
wrapperOptgroup = wrapperOptgroup.render(); |
||
container.appendChild(wrapperOptgroup); |
container.appendChild( wrapperOptgroup ); |
||
container = wrapperOptgroup; |
container = wrapperOptgroup; |
||
} |
} |
||
$.each(contents, function(itemKey, itemProperties) { |
$.each( contents, function( itemKey, itemProperties ) { |
||
var key = (typeof itemKey === "string") ? itemKey : itemProperties.value; |
|||
// Skip if the current template doesn't have a version for the current level |
|||
if (!!level && !itemProperties[val]) { |
|||
var selected = false; |
|||
return; |
|||
if( old_subvalue && old_subvalue_re.test( key ) ) { |
|||
selected = true; |
|||
} |
} |
||
var key = typeof itemKey === 'string' ? itemKey : itemProperties.value; |
|||
var template = key + level; |
|||
var elem = new Morebits.quickForm.element({ |
var elem = new Morebits.quickForm.element( { |
||
type: 'option', |
type: 'option', |
||
label: |
label: "{{" + key + "}}: " + itemProperties.label, |
||
value: |
value: key, |
||
selected: selected |
|||
}); |
|||
} ); |
|||
var elemRendered = container.appendChild( elem.render() ); |
|||
// Select item best corresponding to previous selection |
|||
$(elemRendered).data("messageData", itemProperties); |
|||
if (!selected && old_subvalue && old_subvalue_re.test(template)) { |
|||
} ); |
|||
elem.data.selected = selected = true; |
|||
} |
|||
var elemRendered = container.appendChild(elem.render()); |
|||
$(elemRendered).data('messageData', itemProperties); |
|||
}); |
|||
}; |
|||
var createGroup = function(warnGroup, label, wrapInOptgroup, val) { |
|||
wrapInOptgroup = typeof wrapInOptgroup !== 'undefined' ? wrapInOptgroup : true; |
|||
var optgroup = new Morebits.quickForm.element({ |
|||
type: 'optgroup', |
|||
label: label |
|||
}); |
|||
optgroup = optgroup.render(); |
|||
sub_group.appendChild(optgroup); |
|||
createEntries(warnGroup, optgroup, wrapInOptgroup, val); |
|||
}; |
}; |
||
if( value === "singlenotice" || value === "singlewarn" || value === "block" ) { |
|||
switch (value) { |
|||
// no categories, just create the options right away |
|||
case 'singlenotice': |
|||
createEntries( Twinkle.warn.messages[ value ], sub_group, true ); |
|||
case 'singlewarn': |
|||
} else if( value === "custom" ) { |
|||
createEntries(Twinkle.warn.messages[value], sub_group, true); |
|||
createEntries( Twinkle.getPref("customWarningList"), sub_group, true ); |
|||
break; |
|||
} else { |
|||
case 'singlecombined': |
|||
// create the option-groups |
|||
var unSortedSinglets = $.extend({}, Twinkle.warn.messages.singlenotice, Twinkle.warn.messages.singlewarn); |
|||
$.each( Twinkle.warn.messages[ value ], function( groupLabel, groupContents ) { |
|||
var sortedSingletMessages = {}; |
|||
var optgroup = new Morebits.quickForm.element( { |
|||
Object.keys(unSortedSinglets).sort().forEach(function(key) { |
|||
type: 'optgroup', |
|||
sortedSingletMessages[key] = unSortedSinglets[key]; |
|||
label: groupLabel |
|||
}); |
|||
} ); |
|||
createEntries(sortedSingletMessages, sub_group, true); |
|||
optgroup = optgroup.render(); |
|||
break; |
|||
sub_group.appendChild( optgroup ); |
|||
case 'custom': |
|||
// create the options |
|||
createEntries(Twinkle.getPref('customWarningList'), sub_group, true); |
|||
createEntries( groupContents, optgroup, false ); |
|||
break; |
|||
} ); |
|||
case 'kitchensink': |
|||
} |
|||
['level1', 'level2', 'level3', 'level4', 'level4im'].forEach(function(lvl) { |
|||
$.each(Twinkle.warn.messages.levels, function(levelGroupLabel, levelGroup) { |
|||
createGroup(levelGroup, 'Level ' + lvl.slice(5) + ': ' + levelGroupLabel, true, lvl); |
|||
}); |
|||
}); |
|||
createGroup(Twinkle.warn.messages.singlenotice, 'Single-issue notices'); |
|||
createGroup(Twinkle.warn.messages.singlewarn, 'Single-issue warnings'); |
|||
createGroup(Twinkle.getPref('customWarningList'), 'Custom warnings'); |
|||
break; |
|||
case 'level1': |
|||
case 'level2': |
|||
case 'level3': |
|||
case 'level4': |
|||
case 'level4im': |
|||
// Creates subgroup regardless of whether there is anything to place in it; |
|||
// leaves "Removal of deletion tags" empty for 4im |
|||
$.each(Twinkle.warn.messages.levels, function(groupLabel, groupContents) { |
|||
createGroup(groupContents, groupLabel, false); |
|||
}); |
|||
break; |
|||
case 'autolevel': |
|||
// Check user page to determine appropriate level |
|||
var autolevelProc = function() { |
|||
var wikitext = Twinkle.warn.talkpageObj.getPageText(); |
|||
// history not needed for autolevel |
|||
var latest = Twinkle.warn.callbacks.dateProcessing(wikitext)[0]; |
|||
// Pseudo-params with only what's needed to parse the level i.e. no messageData |
|||
var params = { |
|||
sub_group: old_subvalue, |
|||
article: e.target.root.article.value |
|||
}; |
|||
var lvl = 'level' + Twinkle.warn.callbacks.autolevelParseWikitext(wikitext, params, latest)[1]; |
|||
if( value === 'block' ) { |
|||
// Identical to level1, etc. above but explicitly provides the level |
|||
// create the block-related fields |
|||
$.each(Twinkle.warn.messages.levels, function(groupLabel, groupContents) { |
|||
var more = new Morebits.quickForm.element( { type: 'div', id: 'block_fields' } ); |
|||
createGroup(groupContents, groupLabel, false, lvl); |
|||
more.append( { |
|||
}); |
|||
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...' |
|||
} ); |
|||
more.append( { |
|||
type: 'input', |
|||
name: 'block_reason', |
|||
label: '"You have been blocked for ..." ', |
|||
tooltip: 'An optional reason, to replace the default generic reason. Only available for the generic block templates.' |
|||
} ); |
|||
e.target.root.insertBefore( more.render(), e.target.root.lastChild ); |
|||
// restore saved values of fields |
|||
// Trigger subcategory change, add select menu, etc. |
|||
if(Twinkle.warn.prev_block_timer !== null) { |
|||
e.target.root.block_timer.value = Twinkle.warn.prev_block_timer; |
|||
}; |
|||
Twinkle.warn.prev_block_timer = null; |
|||
} |
|||
if(Twinkle.warn.prev_block_reason !== null) { |
|||
e.target.root.block_reason.value = Twinkle.warn.prev_block_reason; |
|||
Twinkle.warn.prev_block_reason = null; |
|||
} |
|||
if(Twinkle.warn.prev_article === null) { |
|||
Twinkle.warn.prev_article = e.target.root.article.value; |
|||
} |
|||
e.target.root.article.disabled = false; |
|||
$(e.target.root.reason).parent().hide(); |
|||
e.target.root.previewer.closePreview(); |
|||
} else if( e.target.root.block_timer ) { |
|||
// hide the block-related fields |
|||
if(!e.target.root.block_timer.disabled && Twinkle.warn.prev_block_timer === null) { |
|||
Twinkle.warn.prev_block_timer = e.target.root.block_timer.value; |
|||
} |
|||
if(!e.target.root.block_reason.disabled && Twinkle.warn.prev_block_reason === null) { |
|||
Twinkle.warn.prev_block_reason = e.target.root.block_reason.value; |
|||
} |
|||
// hack to fix something really weird - removed elements seem to somehow keep an association with the form |
|||
if (Twinkle.warn.talkpageObj) { |
|||
e.target.root.block_reason = null; |
|||
autolevelProc(); |
|||
} else { |
|||
var usertalk_page = new Morebits.wiki.page('User_talk:' + mw.config.get('wgRelevantUserName'), 'Loading previous warnings'); |
|||
usertalk_page.setFollowRedirect(true, false); |
|||
usertalk_page.load(function(pageobj) { |
|||
Twinkle.warn.talkpageObj = pageobj; // Update talkpageObj |
|||
autolevelProc(); |
|||
}, function() { |
|||
// Catch and warn if the talkpage can't load, |
|||
// most likely because it's a cross-namespace redirect |
|||
// Supersedes the typical $autolevelMessage added in autolevelParseWikitext |
|||
var $noTalkPageNode = $('<strong/>', { |
|||
text: 'Unable to load user talk page; it might be a cross-namespace redirect. Autolevel detection will not work.', |
|||
id: 'twinkle-warn-autolevel-message', |
|||
css: {color: 'red' } |
|||
}); |
|||
$noTalkPageNode.insertBefore($('#twinkle-warn-warning-messages')); |
|||
// If a preview was opened while in a different mode, close it |
|||
// Should nullify the need to catch the error in preview callback |
|||
e.target.root.previewer.closePreview(); |
|||
}); |
|||
} |
|||
break; |
|||
default: |
|||
alert('Unknown warning group in twinklewarn'); |
|||
break; |
|||
} |
|||
$(e.target.root).find("#block_fields").remove(); |
|||
// Trigger subcategory change, add select menu, etc. |
|||
// Here because of the async load for autolevel |
|||
if (value !== 'autolevel') { |
|||
// reset any autolevel-specific messages while we're here |
|||
$('#twinkle-warn-autolevel-message').remove(); |
|||
if(e.target.root.article.disabled && Twinkle.warn.prev_article !== null) { |
|||
Twinkle.warn.callback.postCategoryCleanup(e); |
|||
e.target.root.article.value = Twinkle.warn.prev_article; |
|||
Twinkle.warn.prev_article = null; |
|||
} |
|||
e.target.root.article.disabled = false; |
|||
$(e.target.root.reason).parent().show(); |
|||
e.target.root.previewer.closePreview(); |
|||
} |
} |
||
}; |
|||
Twinkle.warn.callback.postCategoryCleanup = function twinklewarnCallbackPostCategoryCleanup(e) { |
|||
// clear overridden label on article textbox |
// clear overridden label on article textbox |
||
Morebits.quickForm.setElementTooltipVisibility(e.target.root.article, true); |
Morebits.quickForm.setElementTooltipVisibility(e.target.root.article, true); |
||
Morebits.quickForm.resetElementLabel(e.target.root.article); |
Morebits.quickForm.resetElementLabel(e.target.root.article); |
||
// Trigger custom label/change on main category change |
|||
Twinkle.warn.callback.change_subcategory(e); |
|||
// |
// hide the big red notice |
||
$("#tw-warn-red-notice").remove(); |
|||
if (!Twinkle.getPref('oldSelect')) { |
|||
$('select[name=sub_group]') |
|||
.select2({ |
|||
width: '100%', |
|||
matcher: Morebits.select2.matchers.optgroupFull, |
|||
templateResult: Morebits.select2.highlightSearchMatches, |
|||
language: { |
|||
searching: Morebits.select2.queryInterceptor |
|||
} |
|||
}) |
|||
.change(Twinkle.warn.callback.change_subcategory); |
|||
$('.select2-selection').keydown(Morebits.select2.autoStart).focus(); |
|||
mw.util.addCSS( |
|||
// Increase height |
|||
'.select2-container .select2-dropdown .select2-results > .select2-results__options { max-height: 350px; }' + |
|||
// Reduce padding |
|||
'.select2-results .select2-results__option { padding-top: 1px; padding-bottom: 1px; }' + |
|||
'.select2-results .select2-results__group { padding-top: 1px; padding-bottom: 1px; } ' + |
|||
// Adjust font size |
|||
'.select2-container .select2-dropdown .select2-results { font-size: 13px; }' + |
|||
'.select2-container .selection .select2-selection__rendered { font-size: 13px; }' |
|||
); |
|||
} |
|||
}; |
}; |
||
Twinkle.warn.callback.change_subcategory = function twinklewarnCallbackChangeSubcategory(e) { |
Twinkle.warn.callback.change_subcategory = function twinklewarnCallbackChangeSubcategory(e) { |
||
var |
var main_group = e.target.form.main_group.value; |
||
var |
var value = e.target.form.sub_group.value; |
||
// If template shouldn't have a linked article, hide the linked article label and text box |
|||
var hideLinkedPage = Twinkle.warn.getTemplateProperty(Twinkle.warn.messages, selected_template, 'hideLinkedPage'); |
|||
if (hideLinkedPage) { |
|||
e.target.form.article.value = ''; |
|||
Morebits.quickForm.setElementVisibility(e.target.form.article.parentElement, false); |
|||
} else { |
|||
Morebits.quickForm.setElementVisibility(e.target.form.article.parentElement, true); |
|||
} |
|||
// If template shouldn't have an optional message, hide the optional message label and text box |
|||
var hideReason = Twinkle.warn.getTemplateProperty(Twinkle.warn.messages, selected_template, 'hideReason'); |
|||
if (hideReason) { |
|||
e.target.form.reason.value = ''; |
|||
Morebits.quickForm.setElementVisibility(e.target.form.reason.parentElement, false); |
|||
} else { |
|||
Morebits.quickForm.setElementVisibility(e.target.form.reason.parentElement, true); |
|||
} |
|||
// 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( value === 'uw-bite' || value === 'uw-username' || value === 'uw-socksuspect' ) { |
|||
if (hasLevel) { |
|||
if(Twinkle.warn.prev_article === null) { |
|||
if (notLinkedArticle[selected_template]) { |
|||
if (Twinkle.warn.prev_article === null) { |
|||
Twinkle.warn.prev_article = e.target.form.article.value; |
Twinkle.warn.prev_article = e.target.form.article.value; |
||
} |
} |
||
e.target.form.article.notArticle = true; |
e.target.form.article.notArticle = true; |
||
e.target.form.article.value = ''; |
e.target.form.article.value = ''; |
||
} else if( e.target.form.article.notArticle ) { |
|||
if(Twinkle.warn.prev_article !== null) { |
|||
// change form labels according to the warning selected |
|||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false); |
|||
Morebits.quickForm.overrideElementLabel(e.target.form.article, notLinkedArticle[selected_template]); |
|||
} else if (e.target.form.article.notArticle) { |
|||
if (Twinkle.warn.prev_article !== null) { |
|||
e.target.form.article.value = Twinkle.warn.prev_article; |
e.target.form.article.value = Twinkle.warn.prev_article; |
||
Twinkle.warn.prev_article = null; |
Twinkle.warn.prev_article = null; |
||
} |
} |
||
e.target.form.article.notArticle = false; |
e.target.form.article.notArticle = false; |
||
} |
|||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, true); |
|||
} else if( main_group === 'block' ) { |
|||
Morebits.quickForm.resetElementLabel(e.target.form.article); |
|||
if( Twinkle.warn.messages.block[value].indefinite ) { |
|||
if(Twinkle.warn.prev_block_timer === null) { |
|||
Twinkle.warn.prev_block_timer = e.target.form.block_timer.value; |
|||
} |
|||
e.target.form.block_timer.disabled = true; |
|||
e.target.form.block_timer.value = 'indefinite'; |
|||
} else if( e.target.form.block_timer.disabled ) { |
|||
if(Twinkle.warn.prev_block_timer !== null) { |
|||
e.target.form.block_timer.value = Twinkle.warn.prev_block_timer; |
|||
Twinkle.warn.prev_block_timer = null; |
|||
} |
|||
e.target.form.block_timer.disabled = false; |
|||
} |
|||
if( Twinkle.warn.messages.block[value].pageParam ) { |
|||
if(Twinkle.warn.prev_article !== null) { |
|||
e.target.form.article.value = Twinkle.warn.prev_article; |
|||
Twinkle.warn.prev_article = null; |
|||
} |
|||
e.target.form.article.disabled = false; |
|||
} else if( !e.target.form.article.disabled ) { |
|||
if(Twinkle.warn.prev_article === null) { |
|||
Twinkle.warn.prev_article = e.target.form.article.value; |
|||
} |
|||
e.target.form.article.disabled = true; |
|||
e.target.form.article.value = ''; |
|||
} |
|||
if( Twinkle.warn.messages.block[value].reasonParam ) { |
|||
if(Twinkle.warn.prev_block_reason !== null) { |
|||
e.target.form.block_reason.value = Twinkle.warn.prev_block_reason; |
|||
Twinkle.warn.prev_block_reason = null; |
|||
} |
|||
e.target.form.block_reason.disabled = false; |
|||
} else if( !e.target.form.block_reason.disabled ) { |
|||
if(Twinkle.warn.prev_block_reason === null) { |
|||
Twinkle.warn.prev_block_reason = e.target.form.block_reason.value; |
|||
} |
|||
e.target.form.block_reason.disabled = true; |
|||
e.target.form.block_reason.value = ''; |
|||
} |
} |
||
} |
|||
// change form labels according to the warning selected |
|||
if (value === "uw-socksuspect") { |
|||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false); |
|||
Morebits.quickForm.overrideElementLabel(e.target.form.article, "Username of sock master, if known (without User:) "); |
|||
} else if (value === "uw-username") { |
|||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false); |
|||
Morebits.quickForm.overrideElementLabel(e.target.form.article, "Username violates policy because... "); |
|||
} else if (value === "uw-bite") { |
|||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false); |
|||
Morebits.quickForm.overrideElementLabel(e.target.form.article, "Username of 'bitten' user (without User:) "); |
|||
} else { |
|||
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 {{uw-[coi-]username}} appropriately |
// add big red notice, warning users about how to use {{uw-[coi-]username}} appropriately |
||
$( |
$("#tw-warn-red-notice").remove(); |
||
var $redWarning; |
var $redWarning; |
||
if ( |
if (value === "uw-username") { |
||
$redWarning = $("<div style='color: red;' id='tw-warn-red-notice'>{{uw-username}} should <b>not</b> be used for <b>blatant</b> username policy violations. " + |
$redWarning = $("<div style='color: red;' id='tw-warn-red-notice'>{{uw-username}} should <b>not</b> be used for <b>blatant</b> username policy violations. " + |
||
"Blatant violations should be reported directly to UAA (via Twinkle's ARV tab). " + |
"Blatant violations should be reported directly to UAA (via Twinkle's ARV tab). " + |
||
"{{uw-username}} should only be used in edge cases in order to engage in discussion with the user.</div>"); |
|||
$redWarning.insertAfter(Morebits.quickForm.getElementLabelObject(e.target.form.reasonGroup)); |
$redWarning.insertAfter(Morebits.quickForm.getElementLabelObject(e.target.form.reasonGroup)); |
||
} else if ( |
} else if (value === "uw-coi-username") { |
||
$redWarning = $("<div style='color: red;' id='tw-warn-red-notice'>{{uw-coi-username}} should <b>not</b> be used for <b>blatant</b> username policy violations. " + |
$redWarning = $("<div style='color: red;' id='tw-warn-red-notice'>{{uw-coi-username}} should <b>not</b> be used for <b>blatant</b> username policy violations. " + |
||
"Blatant violations should be reported directly to UAA (via Twinkle's ARV tab). " + |
"Blatant violations should be reported directly to UAA (via Twinkle's ARV tab). " + |
||
"{{uw-coi-username}} should only be used in edge cases in order to engage in discussion with the user.</div>"); |
|||
$redWarning.insertAfter(Morebits.quickForm.getElementLabelObject(e.target.form.reasonGroup)); |
$redWarning.insertAfter(Morebits.quickForm.getElementLabelObject(e.target.form.reasonGroup)); |
||
} |
} |
||
Line 1,569: | Line 888: | ||
Twinkle.warn.callbacks = { |
Twinkle.warn.callbacks = { |
||
getWarningWikitext: function(templateName, article, reason, isCustom) { |
getWarningWikitext: function(templateName, article, reason, isCustom) { |
||
var text = |
var text = "{{subst:" + templateName; |
||
// add linked article for user warnings |
|||
if (article) { |
if (article) { |
||
// add linked article for user warnings (non-block templates) |
|||
// c&pmove has the source as the first parameter |
|||
text += '|1=' + article; |
|||
if (templateName === 'uw-c&pmove') { |
|||
text += '|to=' + article; |
|||
} else { |
|||
text += '|1=' + article; |
|||
} |
|||
} |
} |
||
if (reason && !isCustom) { |
if (reason && !isCustom) { |
||
// add extra message |
// add extra message for non-block templates |
||
if (templateName === 'uw-csd' || templateName === 'uw-probation' || |
if (templateName === 'uw-csd' || templateName === 'uw-probation' || |
||
templateName === 'uw-userspacenoindex' || templateName === 'uw-userpage') { |
templateName === 'uw-userspacenoindex' || templateName === 'uw-userpage') { |
||
Line 1,596: | Line 910: | ||
} |
} |
||
return text |
return text; |
||
}, |
}, |
||
getBlockNoticeWikitext: function(templateName, article, blockTime, blockReason, isIndefTemplate) { |
|||
showPreview: function(form, templatename) { |
|||
var text = "{{subst:" + templateName; |
|||
var input = Morebits.quickForm.getInputData(form); |
|||
// Provided on autolevel, not otherwise |
|||
templatename = templatename || input.sub_group; |
|||
var linkedarticle = input.article; |
|||
var templatetext; |
|||
if (article && Twinkle.warn.messages.block[templateName].pageParam) { |
|||
templatetext = Twinkle.warn.callbacks.getWarningWikitext(templatename, linkedarticle, |
|||
text += '|page=' + article; |
|||
input.reason, input.main_group === 'custom'); |
|||
} |
|||
if (!/te?mp|^\s*$|min/.exec(blockTime) && !isIndefTemplate) { |
|||
if (/indef|\*|max/.exec(blockTime)) { |
|||
text += '|indef=yes'; |
|||
} else { |
|||
text += '|time=' + blockTime; |
|||
} |
|||
} |
|||
if (blockReason) { |
|||
text += '|reason=' + blockReason; |
|||
} |
|||
text += "|sig=true}}"; |
|||
form.previewer.beginRender(templatetext, 'User_talk:' + mw.config.get('wgRelevantUserName')); // Force wikitext/correct username |
|||
return text; |
|||
}, |
}, |
||
// Just a pass-through unless the autolevel option was selected |
|||
preview: function(form) { |
preview: function(form) { |
||
var templatename = form.sub_group.value; |
|||
var linkedarticle = form.article.value; |
|||
// Always get a new, updated talkpage for autolevel processing |
|||
var templatetext; |
|||
var usertalk_page = new Morebits.wiki.page('User_talk:' + mw.config.get('wgRelevantUserName'), 'Loading previous warnings'); |
|||
usertalk_page.setFollowRedirect(true, false); |
|||
// Will fail silently if the talk page is a cross-ns redirect, |
|||
// removal of the preview box handled when loading the menu |
|||
usertalk_page.load(function(pageobj) { |
|||
Twinkle.warn.talkpageObj = pageobj; // Update talkpageObj |
|||
if (templatename in Twinkle.warn.messages.block) { |
|||
var wikitext = pageobj.getPageText(); |
|||
templatetext = Twinkle.warn.callbacks.getBlockNoticeWikitext(templatename, linkedarticle, form.block_timer.value, |
|||
// history not needed for autolevel |
|||
form.block_reason.value, Twinkle.warn.messages.block[templatename].indefinite); |
|||
var params = { |
|||
sub_group: form.sub_group.value, |
|||
article: form.article.value, |
|||
messageData: $(form.sub_group).find('option[value="' + $(form.sub_group).val() + '"]').data('messageData') |
|||
}; |
|||
var template = Twinkle.warn.callbacks.autolevelParseWikitext(wikitext, params, latest)[0]; |
|||
Twinkle.warn.callbacks.showPreview(form, template); |
|||
// If the templates have diverged, fake a change event |
|||
// to reload the menu with the updated pageobj |
|||
if (form.sub_group.value !== template) { |
|||
var evt = document.createEvent('Event'); |
|||
evt.initEvent('change', true, true); |
|||
form.main_group.dispatchEvent(evt); |
|||
} |
|||
}); |
|||
} else { |
} else { |
||
Twinkle.warn.callbacks. |
templatetext = Twinkle.warn.callbacks.getWarningWikitext(templatename, linkedarticle, |
||
form.reason.value, form.main_group.value === 'custom'); |
|||
} |
} |
||
form.previewer.beginRender(templatetext); |
|||
}, |
}, |
||
main: function( pageobj ) { |
|||
/** |
|||
var text = pageobj.getPageText(); |
|||
* Used in the main and autolevel loops to determine when to warn |
|||
var params = pageobj.getCallbackParameters(); |
|||
* about excessively recent, stale, or identical warnings. |
|||
var messageData = params.messageData; |
|||
* @param {string} wikitext The text of a user's talk page, from getPageText() |
|||
* @returns {Object[]} - Array of objects: latest contains most recent |
|||
var history_re = /<!-- Template:(uw-.*?) -->.*?(\d{1,2}:\d{1,2}, \d{1,2} \w+ \d{4}) \(UTC\)/g; |
|||
* warning and date; history lists all prior warnings |
|||
*/ |
|||
dateProcessing: function(wikitext) { |
|||
var history_re = /<!--\s?Template:([uU]w-.*?)\s?-->.*?(\d{1,2}:\d{1,2}, \d{1,2} \w+ \d{4} \(UTC\))/g; |
|||
var history = {}; |
var history = {}; |
||
var latest = { date: new |
var latest = { date: new Date( 0 ), type: '' }; |
||
var current; |
var current; |
||
while ( |
while( ( current = history_re.exec( text ) ) ) { |
||
var |
var current_date = new Date( current[2] + ' UTC' ); |
||
if |
if( !( current[1] in history ) || history[ current[1] ] < current_date ) { |
||
history[ |
history[ current[1] ] = current_date; |
||
} |
} |
||
if |
if( current_date > latest.date ) { |
||
latest.date = current_date; |
latest.date = current_date; |
||
latest.type = |
latest.type = current[1]; |
||
} |
|||
} |
|||
return [latest, history]; |
|||
}, |
|||
/** |
|||
* Main loop for deciding what the level should increment to. Most of |
|||
* this is really just error catching and updating the subsequent data. |
|||
* May produce up to two notices in a twinkle-warn-autolevel-messages div |
|||
* |
|||
* @param {string} wikitext The text of a user's talk page, from getPageText() (required) |
|||
* @param {Object} params Params object: sub_group is the template (required); |
|||
* article is the user-provided article (form.article) used to link ARV on recent level4 warnings; |
|||
* messageData is only necessary if getting the full template, as it's |
|||
* used to ensure a valid template of that level exists |
|||
* @param {Object} latest First element of the array returned from |
|||
* dateProcessing. Provided here rather than processed within to avoid |
|||
* repeated call to dateProcessing |
|||
* @param {(Date|Morebits.date)} date Date from which staleness is determined |
|||
* @param {Morebits.status} statelem Status element, only used for handling error in final execution |
|||
* |
|||
* @returns {Array} - Array that contains the full template and just the warning level |
|||
*/ |
|||
autolevelParseWikitext: function(wikitext, params, latest, date, statelem) { |
|||
var level; // undefined rather than '' means the isNaN below will return true |
|||
if (/\d(?:im)?$/.test(latest.type)) { // level1-4im |
|||
level = parseInt(latest.type.replace(/.*(\d)(?:im)?$/, '$1'), 10); |
|||
} else if (latest.type) { // Non-numbered warning |
|||
// Try to leverage existing categorization of |
|||
// warnings, all but one are universally lowercased |
|||
var loweredType = /uw-multipleIPs/i.test(latest.type) ? 'uw-multipleIPs' : latest.type.toLowerCase(); |
|||
// It would be nice to account for blocks, but in most |
|||
// cases the hidden message is terminal, not the sig |
|||
if (Twinkle.warn.messages.singlewarn[loweredType]) { |
|||
level = 3; |
|||
} else { |
|||
level = 1; // singlenotice or not found |
|||
} |
} |
||
} |
} |
||
var date = new Date(); |
|||
var $autolevelMessage = $('<div/>', {id: 'twinkle-warn-autolevel-message'}); |
|||
if( params.sub_group in history ) { |
|||
if (isNaN(level)) { // No prior warnings found, this is the first |
|||
var temp_time = new Date( history[ params.sub_group ] ); |
|||
level = 1; |
|||
temp_time.setUTCHours( temp_time.getUTCHours() + 24 ); |
|||
} else if (level > 4 || level < 1) { // Shouldn't happen |
|||
var message = 'Unable to parse previous warning level, please manually select a warning level.'; |
|||
if |
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?" ) ) { |
|||
statelem.error(message); |
|||
pageobj.statelem.info( 'aborted per user request' ); |
|||
} else { |
|||
return; |
|||
} |
|||
return; |
|||
} else { |
|||
date = date || new Date(); |
|||
var autoTimeout = new Morebits.date(latest.date.getTime()).add(parseInt(Twinkle.getPref('autolevelStaleDays'), 10), 'days'); |
|||
if (autoTimeout.isAfter(date)) { |
|||
if (level === 4) { |
|||
level = 4; |
|||
// Basically indicates whether we're in the final Main evaluation or not, |
|||
// and thus whether we can continue or need to display the warning and link |
|||
if (!statelem) { |
|||
var $link = $('<a/>', { |
|||
href: '#', |
|||
text: 'click here to open the ARV tool.', |
|||
css: { fontWeight: 'bold' }, |
|||
click: function() { |
|||
Morebits.wiki.actionCompleted.redirect = null; |
|||
Twinkle.warn.dialog.close(); |
|||
Twinkle.arv.callback(mw.config.get('wgRelevantUserName')); |
|||
$('input[name=page]').val(params.article); // Target page |
|||
$('input[value=final]').prop('checked', true); // Vandalism after final |
|||
} |
|||
}); |
|||
var statusNode = $('<div/>', { |
|||
text: mw.config.get('wgRelevantUserName') + ' recently received a level 4 warning (' + latest.type + ') so it might be better to report them instead; ', |
|||
css: {color: 'red' } |
|||
}); |
|||
statusNode.append($link[0]); |
|||
$autolevelMessage.append(statusNode); |
|||
} |
|||
} else { // Automatically increase severity |
|||
level += 1; |
|||
} |
} |
||
} else { // Reset warning level if most-recent warning is too old |
|||
level = 1; |
|||
} |
} |
||
} |
} |
||
latest.date.setUTCMinutes( latest.date.getUTCMinutes() + 1 ); // after long debate, one minute is max |
|||
$autolevelMessage.prepend($('<div>Will issue a <span style="font-weight: bold;">level ' + level + '</span> template.</div>')); |
|||
// Place after the stale and other-user-reverted (text-only) messages |
|||
$('#twinkle-warn-autolevel-message').remove(); // clean slate |
|||
$autolevelMessage.insertAfter($('#twinkle-warn-warning-messages')); |
|||
if( latest.date > date ) { |
|||
var template = params.sub_group.replace(/(.*)\d$/, '$1'); |
|||
if( !confirm( "A " + latest.type + " has been issued in the last minute. \nWould you still like to add this warning/notice?" ) ) { |
|||
// Validate warning level, falling back to the uw-generic series. |
|||
pageobj.statelem.info( 'aborted per user request' ); |
|||
// Only a few items are missing a level, and in all but a handful |
|||
return; |
|||
// of cases, the uw-generic series is explicitly used elsewhere per WP:UTM. |
|||
} |
|||
if (params.messageData && !params.messageData['level' + level]) { |
|||
template = 'uw-generic'; |
|||
} |
} |
||
template += level; |
|||
var dateHeaderRegex = new RegExp( "^==+\\s*(?:" + date.getUTCMonthName() + '|' + date.getUTCMonthNameAbbrev() + |
|||
return [template, level]; |
|||
")\\s+" + date.getUTCFullYear() + "\\s*==+", 'mg' ); |
|||
}, |
|||
var dateHeaderRegexLast, dateHeaderRegexResult; |
|||
main: function(pageobj) { |
|||
while ((dateHeaderRegexLast = dateHeaderRegex.exec( text )) !== null) { |
|||
var text = pageobj.getPageText(); |
|||
dateHeaderRegexResult = dateHeaderRegexLast; |
|||
var statelem = pageobj.getStatusElement(); |
|||
} |
|||
var params = pageobj.getCallbackParameters(); |
|||
// If dateHeaderRegexResult is null then lastHeaderIndex is never checked. If it is not null but |
|||
var messageData = params.messageData; |
|||
// \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 ) { |
|||
// JS somehow didn't get destructured assignment until ES6 so of course IE doesn't support it |
|||
text += "\n\n"; |
|||
var warningHistory = Twinkle.warn.callbacks.dateProcessing(text); |
|||
} |
|||
var latest = warningHistory[0]; |
|||
var history = warningHistory[1]; |
|||
if( params.main_group === 'block' ) { |
|||
var now = new Morebits.date(pageobj.getLoadTime()); |
|||
if( Twinkle.getPref('blankTalkpageOnIndefBlock') && params.sub_group !== 'uw-lblock' && ( messageData.indefinite || (/indef|\*|max/).exec( params.block_timer ) ) ) { |
|||
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"; |
|||
} 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.getBlockNoticeWikitext(params.sub_group, params.article, params.block_timer, params.reason, messageData.indefinite); |
|||
Twinkle.warn.talkpageObj = pageobj; // Update talkpageObj, just in case |
|||
} else { |
|||
if (params.main_group === 'autolevel') { |
|||
if( messageData.heading ) { |
|||
// [template, level] |
|||
text += "== " + messageData.heading + " ==\n"; |
|||
var templateAndLevel = Twinkle.warn.callbacks.autolevelParseWikitext(text, params, latest, now, statelem); |
|||
} 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' ); |
|||
// Only if there's a change from the prior display/load |
|||
text += "== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ==\n"; |
|||
if (params.sub_group !== templateAndLevel[0] && !confirm('Will issue a {{' + templateAndLevel[0] + '}} template to the user, okay?')) { |
|||
statelem.error('aborted per user request'); |
|||
return; |
|||
} |
|||
// Update params now that we've selected a warning |
|||
params.sub_group = templateAndLevel[0]; |
|||
messageData = params.messageData['level' + templateAndLevel[1]]; |
|||
} else if (params.sub_group in history) { |
|||
if (new Morebits.date(history[params.sub_group]).add(1, 'day').isAfter(now)) { |
|||
if (!confirm('An identical ' + params.sub_group + ' has been issued in the last 24 hours. \nWould you still like to add this warning/notice?')) { |
|||
statelem.error('aborted per user request'); |
|||
return; |
|||
} |
|||
} |
} |
||
text += Twinkle.warn.callbacks.getWarningWikitext(params.sub_group, params.article, |
|||
params.reason, params.main_group === 'custom') + " ~~~~"; |
|||
} |
} |
||
if ( Twinkle.getPref('showSharedIPNotice') && Morebits.isIPAddress( mw.config.get('wgTitle') ) ) { |
|||
latest.date.add(1, 'minute'); // after long debate, one minute is max |
|||
Morebits.status.info( 'Info', 'Adding a shared IP notice' ); |
|||
text += "\n{{subst:SharedIPAdvice}}"; |
|||
if (latest.date.isAfter(now)) { |
|||
if (!confirm('A ' + latest.type + ' has been issued in the last minute. \nWould you still like to add this warning/notice?')) { |
|||
statelem.error('aborted per user request'); |
|||
return; |
|||
} |
|||
} |
} |
||
// build the edit summary |
// build the edit summary |
||
var summary; |
|||
// Function to handle generation of summary prefix for custom templates |
|||
if( params.main_group === 'custom' ) { |
|||
var customProcess = function(template) { |
|||
switch( params.sub_group.substr( -1 ) ) { |
|||
template = template.split('|')[0]; |
|||
case "1": |
|||
summary = "General note"; |
|||
switch (template.substr(-1)) { |
|||
case '1': |
|||
prefix = 'General note'; |
|||
break; |
break; |
||
case |
case "2": |
||
summary = "Caution"; |
|||
break; |
break; |
||
case |
case "3": |
||
summary = "Warning"; |
|||
break; |
break; |
||
case |
case "4": |
||
summary = "Final warning"; |
|||
break; |
break; |
||
case |
case "m": |
||
if |
if( params.sub_group.substr( -3 ) === "4im" ) { |
||
summary = "Only warning"; |
|||
break; |
break; |
||
} |
} |
||
summary = "Notice"; |
|||
break; |
|||
default: |
default: |
||
summary = "Notice"; |
|||
break; |
break; |
||
} |
} |
||
summary += ": " + Morebits.string.toUpperCaseFirstChar(messageData.label); |
|||
}; |
|||
var summary; |
|||
if (params.main_group === 'custom') { |
|||
summary = customProcess(params.sub_group); |
|||
} else { |
} else { |
||
summary = messageData.summary; |
|||
// Normalize kitchensink to the 1-4im style |
|||
if ( |
if ( messageData.suppressArticleInSummary !== true && params.article ) { |
||
if ( params.sub_group === "uw-socksuspect" ) { // this template requires a username |
|||
summary += " of [[User:" + params.article + "]]"; |
|||
if (sub === 'm') { |
|||
sub = params.sub_group.substr(-3); |
|||
} |
|||
// Don't overwrite uw-3rr, technically unnecessary |
|||
if (/\d/.test(sub)) { |
|||
params.main_group = 'level' + sub; |
|||
} |
|||
} |
|||
// singlet || level1-4im, no need to /^\D+$/.test(params.main_group) |
|||
summary = messageData.summary || (messageData[params.main_group] && messageData[params.main_group].summary); |
|||
// Not in Twinkle.warn.messages, assume custom template |
|||
if (!summary) { |
|||
summary = customProcess(params.sub_group); |
|||
} |
|||
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 { |
} else { |
||
summary += |
summary += " on [[" + params.article + "]]"; |
||
} |
} |
||
} |
} |
||
} |
} |
||
summary += "." + Twinkle.getPref("summaryAd"); |
|||
pageobj. |
pageobj.setPageText( text ); |
||
pageobj. |
pageobj.setEditSummary( summary ); |
||
pageobj.setWatchlist(Twinkle.getPref('watchWarnings')); |
pageobj.setWatchlist( Twinkle.getPref('watchWarnings') ); |
||
pageobj.save(); |
|||
// Get actual warning text |
|||
var warningText = 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'); |
|||
warningText += '\n{{subst:Shared IP advice}}'; |
|||
} |
|||
var sectionExists = false, sectionNumber = 0; |
|||
// Only check sections if there are sections or there's a chance we won't create our own |
|||
if (!messageData.heading && text.length) { |
|||
// Get all sections |
|||
var sections = text.match(/^(==*).+\1/gm); |
|||
if (sections && sections.length !== 0) { |
|||
// Find the index of the section header in question |
|||
var dateHeaderRegex = now.monthHeaderRegex(); |
|||
sectionNumber = 0; |
|||
// Find this month's section among L2 sections, preferring the bottom-most |
|||
sectionExists = sections.reverse().some(function(sec, idx) { |
|||
return /^(==)[^=].+\1/m.test(sec) && dateHeaderRegex.test(sec) && typeof (sectionNumber = sections.length - 1 - idx) === 'number'; |
|||
}); |
|||
} |
|||
} |
|||
if (sectionExists) { // append to existing section |
|||
pageobj.setPageSection(sectionNumber + 1); |
|||
pageobj.setAppendText('\n\n' + warningText); |
|||
pageobj.append(); |
|||
} else { |
|||
if (messageData.heading) { // create new section |
|||
pageobj.setNewSectionTitle(messageData.heading); |
|||
} else { |
|||
Morebits.status.info('Info', 'Will create a new talk page section for this month, as none was found'); |
|||
pageobj.setNewSectionTitle(now.monthHeader(0)); |
|||
} |
|||
pageobj.setNewSectionText(warningText); |
|||
pageobj.newSection(); |
|||
} |
|||
} |
} |
||
}; |
}; |
||
Twinkle.warn.callback.evaluate = function twinklewarnCallbackEvaluate(e) { |
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 |
|||
// reason, main_group, sub_group, article |
|||
var params = Morebits.quickForm.getInputData(e.target); |
|||
if(e.target.sub_group.value === 'uw-username' && e.target.article.value.trim() === '') { |
|||
// Check that a reason was filled in if uw-username was selected |
|||
alert("You must supply a reason for the {{uw-username}} template."); |
|||
if (params.sub_group === 'uw-username' && !params.article) { |
|||
alert('You must supply a reason for the {{uw-username}} template.'); |
|||
return; |
return; |
||
} |
} |
||
// The autolevel option will already know by now if a user talk page |
|||
// is a cross-namespace redirect (via !!Twinkle.warn.talkpageObj), so |
|||
// technically we could alert an error here, but the user will have |
|||
// already ignored the bold red error above. Moreover, they probably |
|||
// *don't* want to actually issue a warning, so the error handling |
|||
// after the form is submitted is probably preferable |
|||
// Find the selected <option> element so we can fetch the data structure |
// Find the selected <option> element so we can fetch the data structure |
||
var |
var selectedEl = $(e.target.sub_group).find('option[value="' + $(e.target.sub_group).val() + '"]'); |
||
params.messageData = $selectedEl.data('messageData'); |
|||
// Then, grab all the values provided by the form |
|||
Morebits.simpleWindow.setButtonsEnabled(false); |
|||
var params = { |
|||
Morebits.status.init(e.target); |
|||
reason: e.target.block_reason ? e.target.block_reason.value : 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... |
|||
block_timer: e.target.block_timer ? e.target.block_timer.value : null, |
|||
messageData: selectedEl.data("messageData") |
|||
}; |
|||
Morebits. |
Morebits.simpleWindow.setButtonsEnabled( false ); |
||
Morebits.status.init( e.target ); |
|||
Morebits.wiki.actionCompleted.notice = 'Warning complete, reloading talk page in a few seconds'; |
|||
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName'); |
|||
var wikipedia_page = new Morebits.wiki.page(userTalkPage, 'User talk page modification'); |
|||
Morebits.wiki.actionCompleted.notice = "Warning complete, reloading talk page in a few seconds"; |
|||
wikipedia_page.setCallbackParameters(params); |
|||
wikipedia_page.setFollowRedirect(true, false); |
|||
wikipedia_page.load(Twinkle.warn.callbacks.main); |
|||
}; |
|||
var Meta_page = new Morebits.wiki.page( mw.config.get('wgPageName'), 'User talk page modification' ); |
|||
Twinkle.addInitCallback(Twinkle.warn, 'warn'); |
|||
Meta_page.setCallbackParameters( params ); |
|||
Meta_page.setFollowRedirect( true ); |
|||
Meta_page.load( Twinkle.warn.callbacks.main ); |
|||
}; |
|||
})(jQuery); |
})(jQuery); |
||
// |
//</nowiki> |
Latest revision as of 06:51, 24 May 2024
//<nowiki>
(function($){
/*
****************************************
*** twinklewarn.js: Warn module
****************************************
* Mode of invocation: Tab ("Warn")
* Active on: User talk pages
* Config directives in: TwinkleConfig
*/
Twinkle.warn = function twinklewarn() {
if( mw.config.get('wgNamespaceNumber') === 3 ) {
Twinkle.addPortletLink( Twinkle.warn.callback, "Warn", "tw-warn", "Warn/notify user" );
}
// modify URL of talk page on rollback success pages
if( mw.config.get('wgAction') === 'rollback' ) {
var $vandalTalkLink = $("#mw-rollback-success").find(".mw-usertoollinks a").first();
$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);
}
}
};
Twinkle.warn.callback = function twinklewarnCallback() {
if( mw.config.get('wgTitle').split( '/' )[0] === 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: 'General note (1)', value: 'level1', selected: ( defaultGroup === 1 || defaultGroup < 1 || ( Morebits.userIsInGroup( 'sysop' ) ? defaultGroup > 8 : defaultGroup > 7 ) ) } );
main_group.append( { type: 'option', label: 'Caution (2)', value: 'level2', selected: ( defaultGroup === 2 ) } );
main_group.append( { type: 'option', label: 'Warning (3)', value: 'level3', selected: ( defaultGroup === 3 ) } );
main_group.append( { type: 'option', label: 'Final warning (4)', value: 'level4', selected: ( defaultGroup === 4 ) } );
main_group.append( { type: 'option', label: 'Only warning (4im)', 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 ) } );
}
if( Morebits.userIsInGroup( 'sysop' ) ) {
main_group.append( { type: 'option', label: 'Blocking', value: 'block', selected: ( defaultGroup === 8 ) } );
}
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-test1": {
label: "Editing tests",
summary: "General note: Editing tests"
},
},
"Promotions and spam": {
"uw-advert1": {
label: "Using Meta for advertising or promotion",
summary: "General note: Using Meta for advertising or promotion"
},
"uw-spam1": {
label: "Adding spam links",
summary: "General note: Adding spam links"
}
},
"Behavior towards other editors": {
"uw-agf1": {
label: "Not assuming good faith",
summary: "General note: Not assuming good faith"
},
"uw-harass1": {
label: "Harassment of other users",
summary: "General note: Harassment of other users"
},
"uw-pa1": {
label: "Personal attack directed at a specific editor",
summary: "General note: Personal attack directed at a specific editor"
},
"uw-tempabuse1": {
label: "Improper use of warning or blocking template",
summary: "General note: Improper use of warning or blocking template"
}
},
},
level2: {
"Common warnings": {
"uw-vandalism2": {
label: "Vandalism",
summary: "Caution: Unconstructive editing"
},
"uw-test2": {
label: "Editing tests",
summary: "Caution: Editing tests"
},
},
"Promotions and spam": {
"uw-advert2": {
label: "Using Meta for advertising or promotion",
summary: "Caution: Using Meta for advertising or promotion"
},
"uw-spam2": {
label: "Adding spam links",
summary: "Caution: Adding spam links"
}
},
"Behavior towards other editors": {
"uw-agf2": {
label: "Not assuming good faith",
summary: "Caution: Not assuming good faith"
},
"uw-harass2": {
label: "Harassment of other users",
summary: "Caution: Harassment of other users"
},
"uw-pa2": {
label: "Personal attack directed at a specific editor",
summary: "Caution: Personal attack directed at a specific editor"
},
"uw-tempabuse2": {
label: "Improper use of warning or blocking template",
summary: "Caution: Improper use of warning or blocking template"
}
},
},
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"
},
},
"Promotions and spam": {
"uw-advert3": {
label: "Using Meta for advertising or promotion",
summary: "Warning: Using Meta for advertising or promotion"
},
"uw-spam3": {
label: "Adding spam links",
summary: "Warning: Adding spam links"
}
},
"Behavior towards other users": {
"uw-agf3": {
label: "Not assuming good faith",
summary: "Warning: Not assuming good faith"
},
"uw-harass3": {
label: "Harassment of other users",
summary: "Warning: Harassment of other users"
},
"uw-pa3": {
label: "Personal attack directed at a specific editor",
summary: "Warning: Personal attack directed at a specific editor"
}
},
},
level4: {
"Common warnings": {
"uw-generic4": {
label: "Generic warning (for template series missing level 4)",
summary: "Final warning notice"
},
"uw-vandalism4": {
label: "Vandalism",
summary: "Final warning: Vandalism"
},
"uw-delete4": {
label: "Removal of content, blanking",
summary: "Final warning: Removal of content, blanking"
}
},
"Promotions and spam": {
"uw-advert4": {
label: "Using Meta for advertising or promotion",
summary: "Final warning: Using Meta for advertising or promotion"
},
"uw-spam4": {
label: "Adding spam links",
summary: "Final warning: Adding spam links"
}
},
"Behavior towards other editors": {
"uw-harass4": {
label: "Harassment of other users",
summary: "Final warning: Harassment of other users"
},
"uw-pa4": {
label: "Personal attack directed at a specific editor",
summary: "Final warning: Personal attack directed at a specific editor"
}
},
},
level4im: {
"Common warnings": {
"uw-vandalism4im": {
label: "Vandalism",
summary: "Only warning: Vandalism"
},
"uw-delete4im": {
label: "Removal of content, blanking",
summary: "Only warning: Removal of content, blanking"
},
"uw-upvio-wikiname": {
label: "Username policy violation (Wikiname)",
summary: "Only warning: Violation of the username policy (wikiname)"
}
},
"Promotions and spam": {
"uw-advert4im": {
label: "Using Meta for advertising or promotion",
summary: "Only warning: Using Meta for advertising or promotion"
},
"uw-spam4im": {
label: "Adding spam links",
summary: "Only warning: Adding spam links"
}
},
"Behavior towards other editors": {
"uw-harass4im": {
label: "Harassment of other users",
summary: "Only warning: Harassment of other users"
},
"uw-npa4im": {
label: "Personal attack directed at a specific editor",
summary: "Only warning: Personal attack directed at a specific editor"
}
},
"Other": {
"uw-create4im": {
label: "Creating inappropriate pages",
summary: "Only warning: Creating inappropriate pages"
},
"uw-move4im": {
label: "Page moves against naming conventions or consensus",
summary: "Only warning: Page moves against naming conventions or consensus"
},
"uw-upload4im": {
label: "Uploading unencyclopedic images",
summary: "Only warning: Uploading unencyclopedic images"
}
}/*,
"To be removed from Twinkle": {
"uw-af4im": {
label: "Inappropriate feedback through the Article Feedback Tool",
summary: "Only warning: Inappropriate feedback through the Article Feedback Tool"
},
"uw-redirect4im": {
label: "Creating malicious redirects",
summary: "Only warning: Creating malicious redirects"
}
}*/
},
singlenotice: {
"uw-2redirect": {
label: "Creating double redirects through bad page moves",
summary: "Notice: Creating double redirects through bad page moves"
},
"uw-warn": {
label: "Place user warning templates when reverting vandalism",
summary: "Notice: You can use user warning templates when reverting vandalism"
}
},
singlewarn: {
"uw-3rr": {
label: "Violating the three-revert rule; see also uw-ew",
summary: "Warning: Violating the three-revert rule"
},
"uw-affiliate": {
label: "Affiliate marketing",
summary: "Warning: Affiliate marketing"
},
"uw-agf-sock": {
label: "Use of multiple accounts (assuming good faith)",
summary: "Warning: Using multiple accounts"
},
"uw-attack": {
label: "Creating attack pages",
summary: "Warning: Creating attack pages",
suppressArticleInSummary: true
},
"uw-attempt": {
label: "Triggering the edit filter",
summary: "Warning: Triggering the edit filter"
},
"uw-bizlist": {
label: "Business promotion",
summary: "Warning: Promoting a business"
},
"uw-botun": {
label: "Bot username",
summary: "Warning: Bot username"
},
"uw-canvass": {
label: "Canvassing",
summary: "Warning: Canvassing"
},
"uw-copyright": {
label: "Copyright violation",
summary: "Warning: Copyright violation"
},
"uw-copyright-link": {
label: "Linking to copyrighted works violation",
summary: "Warning: Linking to copyrighted works violation"
},
"uw-copyright-new": {
label: "Copyright violation (with explanation for new users)",
summary: "Notice: Avoiding copyright problems",
heading: "Meta and copyright"
},
"uw-copyright-remove": {
label: "Removing {{copyvio}} template from articles",
summary: "Warning: Removing {{copyvio}} templates"
},
"uw-efsummary": {
label: "Edit summary triggering the edit filter",
summary: "Warning: Edit summary triggering the edit filter"
},
"uw-ew": {
label: "Edit warring (stronger wording)",
summary: "Warning: Edit warring"
},
"uw-ewsoft": {
label: "Edit warring (softer wording for newcomers)",
summary: "Warning: Edit warring"
},
"uw-hoax": {
label: "Creating hoaxes",
summary: "Warning: Creating hoaxes"
},
"uw-legal": {
label: "Making legal threats",
summary: "Warning: Making legal threats"
},
"uw-login": {
label: "Editing while logged out",
summary: "Warning: Editing while logged out"
},
"uw-longterm": {
label: "Long term pattern of vandalism",
summary: "Warning: Long term pattern of vandalism"
},
"uw-multipleIPs": {
label: "Usage of multiple IPs",
summary: "Warning: Usage of multiple IPs"
},
"uw-pinfo": {
label: "Personal info",
summary: "Warning: Personal info"
},
"uw-socksuspect": {
label: "Sockpuppetry",
summary: "Warning: You are a suspected [[WP:SOCK|sockpuppet]]" // of User:...
},
"uw-upv": {
label: "Userpage vandalism",
summary: "Warning: Userpage vandalism"
},
"uw-username": {
label: "Username is against policy",
summary: "Warning: Your username might be against policy",
suppressArticleInSummary: true // not relevant for this template
},
"uw-coi-username": {
label: "Username is against policy, and conflict of interest",
summary: "Warning: Username and conflict of interest policy",
heading: "Your username"
},
"uw-userpage": {
label: "Userpage or subpage is against policy",
summary: "Warning: Userpage or subpage is against policy"
},
"uw-wrongsummary": {
label: "Using inaccurate or inappropriate edit summaries",
summary: "Warning: Using inaccurate or inappropriate edit summaries"
}
},
block: {
"uw-block": {
label: "Block",
summary: "You have been blocked from editing",
pageParam: true,
reasonParam: true, // allows editing of reason for generic templates
suppressArticleInSummary: true
},
"uw-blocknotalk": {
label: "Block - talk page disabled",
summary: "You have been blocked from editing and your user talk page has been disabled",
pageParam: true,
reasonParam: true,
suppressArticleInSummary: true
},
"uw-blockindef": {
label: "Block - indefinite",
summary: "You have been indefinitely blocked from editing",
indefinite: true,
pageParam: true,
reasonParam: true,
suppressArticleInSummary: true
},
"uw-ablock": {
label: "Block - IP address",
summary: "Your IP address has been blocked from editing",
pageParam: true,
suppressArticleInSummary: true
},
"uw-vblock": {
label: "Vandalism block",
summary: "You have been blocked from editing for persistent [[WP:VAND|vandalism]]",
pageParam: true
},
"uw-voablock": {
label: "Vandalism-only account block (indefinite)",
summary: "You have been indefinitely blocked from editing because your account is being [[WP:VOA|used only for vandalism]]",
indefinite: true,
pageParam: true
},
"uw-sblock": {
label: "Spam block",
summary: "You have been blocked from editing for using Meta for spam purposes"
},
"uw-adblock": {
label: "Advertising block",
summary: "You have been blocked from editing for [[WP:SOAP|advertising or self-promotion]]",
pageParam: true
},
"uw-soablock": {
label: "Spam/advertising-only account block (indefinite)",
summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:SPAM|spam, advertising, or promotion]]",
indefinite: true,
pageParam: true
},
"uw-npblock": {
label: "Creating nonsense pages block",
summary: "You have been blocked from editing for creating [[WP:PN|nonsense pages]]",
pageParam: true
},
"uw-copyrightblock": {
label: "Copyright violation block",
summary: "You have been blocked from editing for continued [[WP:COPYVIO|copyright infringement]]",
pageParam: true
},
"uw-spoablock": {
label: "Sockpuppet account block (indefinite)",
summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:SOCK|sock puppetry]]",
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": {
label: "Harassment block",
summary: "You have been blocked from editing for attempting to [[WP:HARASS|harass]] other users",
pageParam: true
},
"uw-disruptblock": {
label: "Disruptive editing block",
summary: "You have been blocked from editing for [[WP:DE|disruptive editing]]",
pageParam: true
},
"uw-deoablock": {
label: "Disruption/trolling-only account block (indefinite)",
summary: "You have been indefinitely blocked from editing because your account is being used only for [[WP:DE|trolling, disruption or harassment]]",
indefinite: true,
pageParam: true
},
"uw-lblock": {
label: "Legal threat block (indefinite)",
summary: "You have been indefinitely blocked from editing for making [[WP:NLT|legal threats or taking legal action]]",
indefinite: true
},
"uw-aeblock": {
label: "Arbitration enforcement block",
summary: "You have been blocked from editing for violating an [[WP:Arbitration|arbitration decision]] with your edits",
pageParam: true,
reasonParam: true
},
"uw-efblock": {
label: "Edit filter-related block",
summary: "You have been blocked from editing for making disruptive edits that repeatedly triggered the [[WP:EF|edit filter]]"
},
"uw-myblock": {
label: "Social networking block",
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
},
"uw-dblock": {
label: "Deletion/removal of content block",
summary: "You have been blocked from editing for continued [[WP:VAND|removal of material]]",
pageParam: true
},
"uw-compblock": {
label: "Possible compromised account block (indefinite)",
summary: "You have been indefinitely blocked from editing because it is believed that your [[WP:SECURE|account has been compromised]]",
indefinite: true
},
"uw-botblock": {
label: "Unapproved bot block",
summary: "You have been blocked from editing because it appears you are running a [[WP:BOT|bot script]] without [[WP:BRFA|approval]]",
pageParam: true
},
"uw-ublock": {
label: "Username soft block (indefinite)",
summary: "You have been indefinitely blocked from editing because your username is a violation of the [[WP:U|username policy]]",
indefinite: true,
reasonParam: true
},
"uw-uhblock": {
label: "Username hard block (indefinite)",
summary: "You have been indefinitely blocked from editing because your username is a blatant violation of the [[WP:U|username policy]]",
indefinite: true,
reasonParam: true
},
"uw-softerblock": {
label: "Promotional username soft block (indefinite)",
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
},
"uw-causeblock": {
label: "Promotional username soft block, for charitable causes (indefinite)",
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
},
"uw-botublock": {
label: "Bot username soft block (indefinite)",
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
},
"uw-memorialblock": {
label: "Memorial username soft block (indefinite)",
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
},
"uw-ublock-famous": {
label: "Famous username soft block (indefinite)",
summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] matches the name of a well-known living individual",
indefinite: true
},
"uw-ublock-double": {
label: "Similar username soft block (indefinite)",
summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] is too similar to the username of another Meta user",
indefinite: true
},
"uw-uhblock-double": {
label: "Username impersonation hard block (indefinite)",
summary: "You have been indefinitely blocked from editing because your [[WP:U|username]] appears to impersonate another established Meta user",
indefinite: true
},
"uw-vaublock": {
label: "Vandalism-only account and username hard block (indefinite)",
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,
pageParam: true
},
"uw-spamublock": {
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 [[WP:SPAM|spam or advertising]] and your username is a violation of the [[WP:U|username policy]]",
indefinite: true
}
}
};
Twinkle.warn.prev_block_timer = null;
Twinkle.warn.prev_block_reason = null;
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( $.escapeRE( 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;
}
var elem = new Morebits.quickForm.element( {
type: 'option',
label: "{{" + key + "}}: " + itemProperties.label,
value: key,
selected: selected
} );
var elemRendered = container.appendChild( elem.render() );
$(elemRendered).data("messageData", itemProperties);
} );
};
if( value === "singlenotice" || value === "singlewarn" || value === "block" ) {
// 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 );
} );
}
if( value === 'block' ) {
// create the block-related fields
var more = new Morebits.quickForm.element( { type: 'div', id: 'block_fields' } );
more.append( {
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...'
} );
more.append( {
type: 'input',
name: 'block_reason',
label: '"You have been blocked for ..." ',
tooltip: 'An optional reason, to replace the default generic reason. Only available for the generic block templates.'
} );
e.target.root.insertBefore( more.render(), e.target.root.lastChild );
// restore saved values of fields
if(Twinkle.warn.prev_block_timer !== null) {
e.target.root.block_timer.value = Twinkle.warn.prev_block_timer;
Twinkle.warn.prev_block_timer = null;
}
if(Twinkle.warn.prev_block_reason !== null) {
e.target.root.block_reason.value = Twinkle.warn.prev_block_reason;
Twinkle.warn.prev_block_reason = null;
}
if(Twinkle.warn.prev_article === null) {
Twinkle.warn.prev_article = e.target.root.article.value;
}
e.target.root.article.disabled = false;
$(e.target.root.reason).parent().hide();
e.target.root.previewer.closePreview();
} else if( e.target.root.block_timer ) {
// hide the block-related fields
if(!e.target.root.block_timer.disabled && Twinkle.warn.prev_block_timer === null) {
Twinkle.warn.prev_block_timer = e.target.root.block_timer.value;
}
if(!e.target.root.block_reason.disabled && Twinkle.warn.prev_block_reason === null) {
Twinkle.warn.prev_block_reason = e.target.root.block_reason.value;
}
// hack to fix something really weird - removed elements seem to somehow keep an association with the form
e.target.root.block_reason = null;
$(e.target.root).find("#block_fields").remove();
if(e.target.root.article.disabled && Twinkle.warn.prev_article !== null) {
e.target.root.article.value = Twinkle.warn.prev_article;
Twinkle.warn.prev_article = null;
}
e.target.root.article.disabled = false;
$(e.target.root.reason).parent().show();
e.target.root.previewer.closePreview();
}
// 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();
};
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;
if( main_group === 'singlenotice' || main_group === 'singlewarn' ) {
if( value === 'uw-bite' || value === 'uw-username' || value === 'uw-socksuspect' ) {
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 = '';
} 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;
}
} else if( main_group === 'block' ) {
if( Twinkle.warn.messages.block[value].indefinite ) {
if(Twinkle.warn.prev_block_timer === null) {
Twinkle.warn.prev_block_timer = e.target.form.block_timer.value;
}
e.target.form.block_timer.disabled = true;
e.target.form.block_timer.value = 'indefinite';
} else if( e.target.form.block_timer.disabled ) {
if(Twinkle.warn.prev_block_timer !== null) {
e.target.form.block_timer.value = Twinkle.warn.prev_block_timer;
Twinkle.warn.prev_block_timer = null;
}
e.target.form.block_timer.disabled = false;
}
if( Twinkle.warn.messages.block[value].pageParam ) {
if(Twinkle.warn.prev_article !== null) {
e.target.form.article.value = Twinkle.warn.prev_article;
Twinkle.warn.prev_article = null;
}
e.target.form.article.disabled = false;
} else if( !e.target.form.article.disabled ) {
if(Twinkle.warn.prev_article === null) {
Twinkle.warn.prev_article = e.target.form.article.value;
}
e.target.form.article.disabled = true;
e.target.form.article.value = '';
}
if( Twinkle.warn.messages.block[value].reasonParam ) {
if(Twinkle.warn.prev_block_reason !== null) {
e.target.form.block_reason.value = Twinkle.warn.prev_block_reason;
Twinkle.warn.prev_block_reason = null;
}
e.target.form.block_reason.disabled = false;
} else if( !e.target.form.block_reason.disabled ) {
if(Twinkle.warn.prev_block_reason === null) {
Twinkle.warn.prev_block_reason = e.target.form.block_reason.value;
}
e.target.form.block_reason.disabled = true;
e.target.form.block_reason.value = '';
}
}
// change form labels according to the warning selected
if (value === "uw-socksuspect") {
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false);
Morebits.quickForm.overrideElementLabel(e.target.form.article, "Username of sock master, if known (without User:) ");
} else if (value === "uw-username") {
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false);
Morebits.quickForm.overrideElementLabel(e.target.form.article, "Username violates policy because... ");
} else if (value === "uw-bite") {
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false);
Morebits.quickForm.overrideElementLabel(e.target.form.article, "Username of 'bitten' user (without User:) ");
} else {
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 {{uw-[coi-]username}} appropriately
$("#tw-warn-red-notice").remove();
var $redWarning;
if (value === "uw-username") {
$redWarning = $("<div style='color: red;' id='tw-warn-red-notice'>{{uw-username}} should <b>not</b> be used for <b>blatant</b> username policy violations. " +
"Blatant violations should be reported directly to UAA (via Twinkle's ARV tab). " +
"{{uw-username}} should only be used in edge cases in order to engage in discussion with the user.</div>");
$redWarning.insertAfter(Morebits.quickForm.getElementLabelObject(e.target.form.reasonGroup));
} else if (value === "uw-coi-username") {
$redWarning = $("<div style='color: red;' id='tw-warn-red-notice'>{{uw-coi-username}} should <b>not</b> be used for <b>blatant</b> username policy violations. " +
"Blatant violations should be reported directly to UAA (via Twinkle's ARV tab). " +
"{{uw-coi-username}} should only be used in edge cases in order to engage in discussion with the user.</div>");
$redWarning.insertAfter(Morebits.quickForm.getElementLabelObject(e.target.form.reasonGroup));
}
};
Twinkle.warn.callbacks = {
getWarningWikitext: function(templateName, article, reason, isCustom) {
var text = "{{subst:" + templateName;
if (article) {
// add linked article for user warnings (non-block templates)
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 += '}}';
if (reason && isCustom) {
// we assume that custom warnings lack a {{{2}}} parameter
text += " ''" + reason + "''";
}
return text;
},
getBlockNoticeWikitext: function(templateName, article, blockTime, blockReason, isIndefTemplate) {
var text = "{{subst:" + templateName;
if (article && Twinkle.warn.messages.block[templateName].pageParam) {
text += '|page=' + article;
}
if (!/te?mp|^\s*$|min/.exec(blockTime) && !isIndefTemplate) {
if (/indef|\*|max/.exec(blockTime)) {
text += '|indef=yes';
} else {
text += '|time=' + blockTime;
}
}
if (blockReason) {
text += '|reason=' + blockReason;
}
text += "|sig=true}}";
return text;
},
preview: function(form) {
var templatename = form.sub_group.value;
var linkedarticle = form.article.value;
var templatetext;
if (templatename in Twinkle.warn.messages.block) {
templatetext = Twinkle.warn.callbacks.getBlockNoticeWikitext(templatename, linkedarticle, form.block_timer.value,
form.block_reason.value, Twinkle.warn.messages.block[templatename].indefinite);
} else {
templatetext = Twinkle.warn.callbacks.getWarningWikitext(templatename, linkedarticle,
form.reason.value, form.main_group.value === 'custom');
}
form.previewer.beginRender(templatetext);
},
main: function( pageobj ) {
var text = pageobj.getPageText();
var params = pageobj.getCallbackParameters();
var messageData = params.messageData;
var history_re = /<!-- Template:(uw-.*?) -->.*?(\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( params.main_group === 'block' ) {
if( Twinkle.getPref('blankTalkpageOnIndefBlock') && params.sub_group !== 'uw-lblock' && ( messageData.indefinite || (/indef|\*|max/).exec( params.block_timer ) ) ) {
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";
} 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.getBlockNoticeWikitext(params.sub_group, params.article, params.block_timer, params.reason, messageData.indefinite);
} else {
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') && Morebits.isIPAddress( mw.config.get('wgTitle') ) ) {
Morebits.status.info( 'Info', 'Adding a shared IP notice' );
text += "\n{{subst:SharedIPAdvice}}";
}
// 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-socksuspect" ) { // this template requires 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) {
// 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 {{uw-username}} template.");
return;
}
// Find the selected <option> 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.block_reason ? e.target.block_reason.value : 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...
block_timer: e.target.block_timer ? e.target.block_timer.value : null,
messageData: selectedEl.data("messageData")
};
Morebits.simpleWindow.setButtonsEnabled( false );
Morebits.status.init( e.target );
Morebits.wiki.actionCompleted.redirect = mw.config.get('wgPageName');
Morebits.wiki.actionCompleted.notice = "Warning complete, reloading talk page in a few seconds";
var Meta_page = new Morebits.wiki.page( mw.config.get('wgPageName'), 'User talk page modification' );
Meta_page.setCallbackParameters( params );
Meta_page.setFollowRedirect( true );
Meta_page.load( Twinkle.warn.callbacks.main );
};
})(jQuery);
//</nowiki>