14,091
edits
m (1 revision imported) |
m (1 revision imported) |
||
(One intermediate revision by the same user not shown) | |||
Line 15: | Line 15: | ||
Twinkle.warn = function twinklewarn() { | Twinkle.warn = function twinklewarn() { | ||
if( mw.config.get(' | if( mw.config.get( 'wgRelevantUserName' ) ) { | ||
Twinkle.addPortletLink( Twinkle.warn.callback, "Warn", "tw-warn", "Warn/notify user" ); | Twinkle.addPortletLink( Twinkle.warn.callback, "Warn", "tw-warn", "Warn/notify user" ); | ||
} | } | ||
// | // Modify URL of talk page on rollback success pages. This is only used | ||
// when a user Ctrl+clicks on a rollback link. | |||
if( mw.config.get('wgAction') === 'rollback' ) { | if( mw.config.get('wgAction') === 'rollback' ) { | ||
var $vandalTalkLink = $("#mw-rollback-success").find(".mw-usertoollinks a").first(); | var $vandalTalkLink = $("#mw-rollback-success").find(".mw-usertoollinks a").first(); | ||
if ( $vandalTalkLink.length ) { | if ( $vandalTalkLink.length ) { | ||
Twinkle.warn.makeVandalTalkLink($vandalTalkLink); | |||
$vandalTalkLink.css("font-weight", "bold"); | $vandalTalkLink.css("font-weight", "bold"); | ||
} | |||
} | |||
// Override the mw.notify function to allow us to inject a link into the | |||
// rollback success popup. Only users with the 'rollback' right need this, | |||
// but we have no nice way of knowing who has that right (what with global | |||
// groups and the like) | |||
else if( mw.config.get('wgAction') === 'history' ) { | |||
mw.notifyOriginal = mw.notify; | |||
mw.notify = function mwNotifyTwinkleOverride(message, options) { | |||
// This is a horrible, awful hack to add a link to the rollback success | |||
// popup. All other notification popups should be left untouched. | |||
// It won't work for people whose user language is not English. | |||
// As it's a hack, it's liable to stop working or break sometimes, | |||
// particularly if the text or format of the confirmation message | |||
// (MediaWiki:Rollback-success-notify) changes. | |||
var regexMatch; | |||
if ( options && options.title && mw.msg && options.title === mw.msg('actioncomplete') && | |||
message && Array.isArray(message) && message[0] instanceof HTMLParagraphElement && | |||
(regexMatch = /^Reverted edits by (.+);\s+changed/.exec(message[0].innerText)) | |||
) { | |||
// Create a nicely-styled paragraph to place the link in | |||
var $p = $('<p/>'); | |||
$p.css("margin", "0.5em -1.5em -1.5em"); | |||
$p.css("padding", "0.5em 1.5em 0.8em"); | |||
$p.css("border-top", "1px #666 solid"); | |||
$p.css("cursor", "default"); | |||
$p.click(function(e) { e.stopPropagation(); }); | |||
// Create the new talk link and append it to the end of the message | |||
var $vandalTalkLink = $('<a/>'); | |||
$vandalTalkLink.text("Warn user with Twinkle"); | |||
$vandalTalkLink.attr("href", | //$vandalTalkLink.css("display", "block"); | ||
$vandalTalkLink.attr("href", mw.util.getUrl("User talk:" + regexMatch[1])); | |||
$vandalTalkLink. | Twinkle.warn.makeVandalTalkLink($vandalTalkLink); | ||
$p.append($vandalTalkLink); | |||
message[0].appendChild($p.get()[0]); | |||
// Don't auto-hide the notification. It only stays around for 5 seconds by | |||
// default, which might not be enough time for the user to read it and | |||
// click the link | |||
options.autoHide = false; | |||
} | } | ||
} | mw.notifyOriginal.apply(mw, arguments); | ||
}; | |||
} | |||
// for testing, use: | |||
// mw.notify([ $("<p>Reverted edits by foo; changed</p>")[0] ], { title: mw.msg('actioncomplete') } ); | |||
}; | |||
Twinkle.warn.makeVandalTalkLink = function($vandalTalkLink) { | |||
$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() { | Twinkle.warn.callback = function twinklewarnCallback() { | ||
if( mw.config.get(' | if( mw.config.get( 'wgRelevantUserName' ) === 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; | ||
Line 68: | Line 121: | ||
main_group.append( { type: 'option', label: 'Final warning (4)', value: 'level4', selected: ( defaultGroup === 4 ) } ); | 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: '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 notices', value: 'singlenotice', selected: ( defaultGroup === 6 ) } ); | ||
main_group.append( { type: 'option', label: 'Single issue warnings', value: 'singlewarn', selected: ( defaultGroup === 7 ) } ); | main_group.append( { type: 'option', label: 'Single-issue warnings', value: 'singlewarn', selected: ( defaultGroup === 7 ) } ); | ||
if( Twinkle.getPref( 'customWarningList' ).length ) { | if( Twinkle.getPref( 'customWarningList' ).length ) { | ||
main_group.append( { type: 'option', label: 'Custom warnings', value: 'custom', selected: ( defaultGroup === 9 ) } ); | main_group.append( { type: 'option', label: 'Custom warnings', value: 'custom', selected: ( defaultGroup === 9 ) } ); | ||
Line 140: | Line 193: | ||
summary: "General note: Adding unreferenced controversial information about living persons" | summary: "General note: Adding unreferenced controversial information about living persons" | ||
}, | }, | ||
"uw- | "uw-defamatory1": { | ||
label: "Addition of defamatory content", | label: "Addition of defamatory content", | ||
summary: "General note: Addition of defamatory content" | summary: "General note: Addition of defamatory content" | ||
Line 189: | Line 242: | ||
label: "Not adhering to neutral point of view", | label: "Not adhering to neutral point of view", | ||
summary: "General note: Not adhering to neutral point of view" | summary: "General note: Not adhering to neutral point of view" | ||
}, | |||
"uw-paid1": { | |||
label: "Paid editing without disclosure under the Wikimedia Terms of Use", | |||
summary: "General note: Paid editing without disclosure under the Wikimedia Terms of Use" | |||
}, | }, | ||
"uw-spam1": { | "uw-spam1": { | ||
label: "Adding | label: "Adding inappropriate external links", | ||
summary: "General note: Adding | summary: "General note: Adding inappropriate external links" | ||
} | } | ||
}, | }, | ||
Line 232: | Line 289: | ||
}, | }, | ||
"Other": { | "Other": { | ||
"uw-attempt1": { | |||
label: "Triggering the edit filter", | |||
summary: "General note: Triggering the edit filter" | |||
}, | |||
"uw-chat1": { | "uw-chat1": { | ||
label: "Using talk page as forum", | label: "Using talk page as forum", | ||
Line 298: | Line 359: | ||
summary: "Caution: Adding unreferenced controversial information about living persons" | summary: "Caution: Adding unreferenced controversial information about living persons" | ||
}, | }, | ||
"uw- | "uw-defamatory2": { | ||
label: "Addition of defamatory content", | label: "Addition of defamatory content", | ||
summary: "Caution: Addition of defamatory content" | summary: "Caution: Addition of defamatory content" | ||
Line 347: | Line 408: | ||
label: "Not adhering to neutral point of view", | label: "Not adhering to neutral point of view", | ||
summary: "Caution: Not adhering to neutral point of view" | summary: "Caution: Not adhering to neutral point of view" | ||
}, | |||
"uw-paid2": { | |||
label: "Paid editing without disclosure under the Wikimedia Terms of Use", | |||
summary: "Caution: Paid editing without disclosure under the Wikimedia Terms of Use" | |||
}, | }, | ||
"uw-spam2": { | "uw-spam2": { | ||
Line 456: | Line 521: | ||
summary: "Warning: Adding unreferenced controversial information about living persons" | summary: "Warning: Adding unreferenced controversial information about living persons" | ||
}, | }, | ||
"uw- | "uw-defamatory3": { | ||
label: "Addition of defamatory content", | label: "Addition of defamatory content", | ||
summary: "Warning: Addition of defamatory content" | summary: "Warning: Addition of defamatory content" | ||
Line 505: | Line 570: | ||
label: "Not adhering to neutral point of view", | label: "Not adhering to neutral point of view", | ||
summary: "Warning: Not adhering to neutral point of view" | summary: "Warning: Not adhering to neutral point of view" | ||
}, | |||
"uw-paid3": { | |||
label: "Paid editing without disclosure under the Wikimedia Terms of Use", | |||
summary: "Warning: Paid editing without disclosure under the Wikimedia Terms of Use" | |||
}, | }, | ||
"uw-spam3": { | "uw-spam3": { | ||
Line 606: | Line 675: | ||
summary: "Final warning: Adding unreferenced controversial information about living persons" | summary: "Final warning: Adding unreferenced controversial information about living persons" | ||
}, | }, | ||
"uw- | "uw-defamatory4": { | ||
label: "Addition of defamatory content", | label: "Addition of defamatory content", | ||
summary: "Final warning: Addition of defamatory content" | summary: "Final warning: Addition of defamatory content" | ||
Line 647: | Line 716: | ||
label: "Not adhering to neutral point of view", | label: "Not adhering to neutral point of view", | ||
summary: "Final warning: Not adhering to neutral point of view" | summary: "Final warning: Not adhering to neutral point of view" | ||
}, | |||
"uw-paid4": { | |||
label: "Paid editing without disclosure under the Wikimedia Terms of Use", | |||
summary: "Final warning: Paid editing without disclosure under the Wikimedia Terms of Use" | |||
}, | }, | ||
"uw-spam4": { | "uw-spam4": { | ||
Line 740: | Line 813: | ||
summary: "Only warning: Adding unreferenced controversial information about living persons" | summary: "Only warning: Adding unreferenced controversial information about living persons" | ||
}, | }, | ||
"uw- | "uw-defamatory4im": { | ||
label: "Addition of defamatory content", | label: "Addition of defamatory content", | ||
summary: "Only warning: Addition of defamatory content" | summary: "Only warning: Addition of defamatory content" | ||
Line 798: | Line 871: | ||
}*/ | }*/ | ||
}, | }, | ||
singlenotice: { | singlenotice: { | ||
"uw-aiv": { | "uw-aiv": { | ||
label: "Bad AIV report", | label: "Bad AIV report", | ||
summary: "Notice: Bad AIV report" | summary: "Notice: Bad AIV report" | ||
}, | }, | ||
"uw-autobiography": { | "uw-autobiography": { | ||
Line 846: | Line 910: | ||
label: "Adding speculative or unconfirmed information", | label: "Adding speculative or unconfirmed information", | ||
summary: "Notice: Adding speculative or unconfirmed information" | summary: "Notice: Adding speculative or unconfirmed information" | ||
}, | }, | ||
"uw-c&pmove": { | "uw-c&pmove": { | ||
Line 866: | Line 926: | ||
label: "Removing proper sources containing dead links", | label: "Removing proper sources containing dead links", | ||
summary: "Notice: Removing proper sources containing dead links" | summary: "Notice: Removing proper sources containing dead links" | ||
}, | }, | ||
"uw-draftfirst": { | "uw-draftfirst": { | ||
Line 882: | Line 938: | ||
label: "Not communicating in English", | label: "Not communicating in English", | ||
summary: "Notice: Not communicating in English" | summary: "Notice: Not communicating in English" | ||
}, | }, | ||
"uw-hasty": { | "uw-hasty": { | ||
label: "Hasty addition of speedy deletion tags", | label: "Hasty addition of speedy deletion tags", | ||
summary: "Notice: Allow creators time to improve their articles before tagging them for deletion" | summary: "Notice: Allow creators time to improve their articles before tagging them for deletion" | ||
}, | }, | ||
"uw-inline-el": { | "uw-inline-el": { | ||
Line 919: | Line 963: | ||
label: "Incorrect use of minor edits check box", | label: "Incorrect use of minor edits check box", | ||
summary: "Notice: Incorrect use of minor edits check box" | summary: "Notice: Incorrect use of minor edits check box" | ||
}, | }, | ||
"uw-notenglish": { | "uw-notenglish": { | ||
label: "Creating non-English articles", | label: "Creating non-English articles", | ||
summary: "Notice: Creating non-English articles" | summary: "Notice: Creating non-English articles" | ||
}, | }, | ||
"uw-notvote": { | "uw-notvote": { | ||
label: "We use consensus, not voting", | label: "We use consensus, not voting", | ||
summary: "Notice: We use consensus, not voting" | summary: "Notice: We use consensus, not voting" | ||
}, | }, | ||
"uw-plagiarism": { | "uw-plagiarism": { | ||
Line 955: | Line 979: | ||
label: "Use preview button to avoid mistakes", | label: "Use preview button to avoid mistakes", | ||
summary: "Notice: Use preview button to avoid mistakes" | summary: "Notice: Use preview button to avoid mistakes" | ||
}, | }, | ||
"uw-redlink": { | "uw-redlink": { | ||
label: "Indiscriminate removal of redlinks", | label: "Indiscriminate removal of redlinks", | ||
summary: "Notice: Be careful when removing redlinks" | summary: "Notice: Be careful when removing redlinks" | ||
}, | }, | ||
"uw-selfrevert": { | "uw-selfrevert": { | ||
Line 1,011: | Line 1,015: | ||
label: "Posting at the top of talk pages", | label: "Posting at the top of talk pages", | ||
summary: "Notice: Posting at the top of talk pages" | summary: "Notice: Posting at the top of talk pages" | ||
}, | }, | ||
"uw-userspace draft finish": { | "uw-userspace draft finish": { | ||
label: "Stale userspace draft", | label: "Stale userspace draft", | ||
summary: "Notice: Stale userspace draft" | summary: "Notice: Stale userspace draft" | ||
}, | }, | ||
"uw-vgscope": { | "uw-vgscope": { | ||
Line 1,045: | Line 1,033: | ||
singlewarn: { | singlewarn: { | ||
"uw-3rr": { | "uw-3rr": { | ||
label: " | label: "Potential three-revert rule violation; see also uw-ew", | ||
summary: "Warning: | summary: "Warning: Three-revert rule" | ||
}, | }, | ||
"uw-affiliate": { | "uw-affiliate": { | ||
Line 1,085: | Line 1,073: | ||
summary: "Notice: Avoiding copyright problems", | summary: "Notice: Avoiding copyright problems", | ||
heading: "Wikipedia and copyright" | heading: "Wikipedia and copyright" | ||
}, | }, | ||
"uw-copyright-remove": { | "uw-copyright-remove": { | ||
Line 1,117: | Line 1,101: | ||
label: "Editing while logged out", | label: "Editing while logged out", | ||
summary: "Warning: Editing while logged out" | summary: "Warning: Editing while logged out" | ||
}, | }, | ||
"uw-multipleIPs": { | "uw-multipleIPs": { | ||
Line 1,174: | Line 1,154: | ||
if( old_subvalue ) { | if( old_subvalue ) { | ||
old_subvalue = old_subvalue.replace(/\d*(im)?$/, '' ); | old_subvalue = old_subvalue.replace(/\d*(im)?$/, '' ); | ||
old_subvalue_re = new RegExp( | old_subvalue_re = new RegExp( mw.RegExp.escape( old_subvalue ) + "(\\d*(?:im)?)$" ); | ||
} | } | ||
Line 1,236: | Line 1,216: | ||
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); | ||
// hide the big red notice | // hide the big red notice | ||
$("#tw-warn-red-notice").remove(); | $("#tw-warn-red-notice").remove(); | ||
// add custom label.redWarning | |||
Twinkle.warn.callback.change_subcategory(e); | |||
}; | }; | ||
Line 1,244: | Line 1,225: | ||
var main_group = e.target.form.main_group.value; | var main_group = e.target.form.main_group.value; | ||
var value = e.target.form.sub_group.value; | var value = e.target.form.sub_group.value; | ||
// Tags that don't take a linked article, but something else (often a username). | |||
// The value of each tag is the label next to the input field | |||
var notLinkedArticle = { | |||
"uw-agf-sock": "Optional username of other account (without User:) ", | |||
"uw-bite": "Username of 'bitten' user (without User:) ", | |||
"uw-socksuspect": "Username of sock master, if known (without User:) ", | |||
"uw-username": "Username violates policy because... ", | |||
"uw-aiv": "Optional username that was reported (without User:) " | |||
}; | |||
if( main_group === 'singlenotice' || main_group === 'singlewarn' ) { | if( main_group === 'singlenotice' || main_group === 'singlewarn' ) { | ||
if( value | if( notLinkedArticle[value] ) { | ||
if(Twinkle.warn.prev_article === null) { | if(Twinkle.warn.prev_article === null) { | ||
Twinkle.warn.prev_article = e.target.form.article.value; | Twinkle.warn.prev_article = e.target.form.article.value; | ||
Line 1,252: | Line 1,243: | ||
e.target.form.article.notArticle = true; | e.target.form.article.notArticle = true; | ||
e.target.form.article.value = ''; | e.target.form.article.value = ''; | ||
// change form labels according to the warning selected | |||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, false); | |||
Morebits.quickForm.overrideElementLabel(e.target.form.article, notLinkedArticle[value]); | |||
} else if( e.target.form.article.notArticle ) { | } else if( e.target.form.article.notArticle ) { | ||
if(Twinkle.warn.prev_article !== null) { | if(Twinkle.warn.prev_article !== null) { | ||
Line 1,258: | Line 1,253: | ||
} | } | ||
e.target.form.article.notArticle = false; | e.target.form.article.notArticle = false; | ||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.article, true); | |||
Morebits.quickForm.resetElementLabel(e.target.form.article); | |||
} | } | ||
} | } | ||
Line 1,397: | Line 1,379: | ||
params.reason, params.main_group === 'custom') + " ~~~~"; | params.reason, params.main_group === 'custom') + " ~~~~"; | ||
if ( Twinkle.getPref('showSharedIPNotice') && | if ( Twinkle.getPref('showSharedIPNotice') && mw.util.isIPAddress( mw.config.get('wgTitle') ) ) { | ||
Morebits.status.info( 'Info', 'Adding a shared IP notice' ); | Morebits.status.info( 'Info', 'Adding a shared IP notice' ); | ||
text += "\n{{subst: | text += "\n{{subst:Shared IP advice}}"; | ||
} | } | ||
Line 1,433: | Line 1,415: | ||
summary = messageData.summary; | summary = messageData.summary; | ||
if ( messageData.suppressArticleInSummary !== true && params.article ) { | if ( messageData.suppressArticleInSummary !== true && params.article ) { | ||
if ( params.sub_group === "uw-socksuspect" ) { // | if ( params.sub_group === "uw-agf-sock" || | ||
summary += " of [[User:" + params.article + "]]"; | params.sub_group === "uw-socksuspect" || | ||
params.sub_group === "uw-aiv" ) { // these templates require a username | |||
summary += " of [[:User:" + params.article + "]]"; | |||
} else { | } else { | ||
summary += " on [[" + params.article + "]]"; | summary += " on [[:" + params.article + "]]"; | ||
} | } | ||
} | } | ||
Line 1,450: | Line 1,434: | ||
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 | // First, check to make sure a reason was filled in if uw-username was selected | ||
Line 1,473: | Line 1,458: | ||
Morebits.status.init( e.target ); | Morebits.status.init( e.target ); | ||
Morebits.wiki.actionCompleted.redirect = | Morebits.wiki.actionCompleted.redirect = userTalkPage; | ||
Morebits.wiki.actionCompleted.notice = "Warning complete, reloading talk page in a few seconds"; | Morebits.wiki.actionCompleted.notice = "Warning complete, reloading talk page in a few seconds"; | ||
var wikipedia_page = new Morebits.wiki.page( | var wikipedia_page = new Morebits.wiki.page( userTalkPage, 'User talk page modification' ); | ||
wikipedia_page.setCallbackParameters( params ); | wikipedia_page.setCallbackParameters( params ); | ||
wikipedia_page.setFollowRedirect( true ); | wikipedia_page.setFollowRedirect( true ); |