14,061
edits
(Trying an old version) |
(Reverted to revision 64657 by Tito Dutta (talk): Imported version. (TW)) |
||
Line 16: | Line 16: | ||
Twinkle.talkback = function() { | Twinkle.talkback = function() { | ||
if ( | if ( !mw.config.get('wgRelevantUserName') ) { | ||
return; | return; | ||
} | } | ||
Line 24: | Line 24: | ||
Twinkle.talkback.callback = function( ) { | Twinkle.talkback.callback = function( ) { | ||
if( | if( mw.config.get('wgRelevantUserName') === mw.config.get("wgUserName") && !confirm("Is it really so bad that you're talking back to yourself?") ){ | ||
return; | return; | ||
} | } | ||
Line 50: | Line 50: | ||
label: "Talkback: other page", | label: "Talkback: other page", | ||
value: "other" | value: "other" | ||
}, | |||
{ | |||
label: "\"Please see\"", | |||
value: "see" | |||
}, | }, | ||
{ | { | ||
Line 81: | Line 85: | ||
// Check whether the user has opted out from talkback | // Check whether the user has opted out from talkback | ||
var query = { | |||
var | action: 'query', | ||
prop: 'extlinks', | |||
titles: mw.config.get('wgPageName'), | |||
elquery: 'userjs.invalid/noTalkback', | |||
ellimit: '1' | |||
}; | |||
var wpapi = new Morebits.wiki.api("Fetching talkback opt-out status", query, Twinkle.talkback.callback.optoutStatus); | |||
wpapi.post(); | |||
}; | }; | ||
Line 105: | Line 103: | ||
if ($el.length) { | if ($el.length) { | ||
Twinkle.talkback.optout = | Twinkle.talkback.optout = mw.config.get('wgRelevantUserName') + " prefers not to receive talkbacks"; | ||
var url = $el.text(); | var url = $el.text(); | ||
if (url.indexOf("reason=") > -1) { | if (url.indexOf("reason=") > -1) { | ||
Line 179: | Line 177: | ||
value: prev_page | value: prev_page | ||
}); | }); | ||
work_area.append({ | work_area.append({ | ||
type:"input", | type:"input", | ||
Line 192: | Line 190: | ||
type: "select", | type: "select", | ||
name: "noticeboard", | name: "noticeboard", | ||
label: "Noticeboard:" | label: "Noticeboard:", | ||
event: function(e) { | |||
if (e.target.value === "afchd") { | |||
Morebits.quickForm.overrideElementLabel(e.target.form.section, "Title of draft (excluding the prefix): "); | |||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.section, false); | |||
} else { | |||
Morebits.quickForm.resetElementLabel(e.target.form.section); | |||
Morebits.quickForm.setElementTooltipVisibility(e.target.form.section, true); | |||
} | |||
} | |||
}); | }); | ||
noticeboard.append({ | noticeboard.append({ | ||
Line 202: | Line 209: | ||
type: "option", | type: "option", | ||
label: "WP:AN3 (Administrators' noticeboard/Edit warring)", | label: "WP:AN3 (Administrators' noticeboard/Edit warring)", | ||
value: "an3" | value: "an3" | ||
}); | }); | ||
Line 210: | Line 216: | ||
selected: true, | selected: true, | ||
value: "ani" | value: "ani" | ||
}); | |||
// let's keep AN and its cousins at the top | |||
noticeboard.append({ | |||
type: "option", | |||
label: "WP:AFCHD (Articles for creation/Help desk)", | |||
value: "afchd" | |||
}); | }); | ||
noticeboard.append({ | noticeboard.append({ | ||
Line 223: | Line 235: | ||
noticeboard.append({ | noticeboard.append({ | ||
type: "option", | type: "option", | ||
label: "WP: | label: "WP:HD (Help desk)", | ||
value: " | value: "hd" | ||
}); | }); | ||
noticeboard.append({ | noticeboard.append({ | ||
type: "option", | type: "option", | ||
label: "WP: | label: "WP:OTRS/N (OTRS noticeboard)", | ||
value: " | value: "otrs" | ||
}); | }); | ||
noticeboard.append({ | noticeboard.append({ | ||
Line 258: | Line 270: | ||
value: prev_page | value: prev_page | ||
}); | }); | ||
work_area.append({ | work_area.append({ | ||
type:"input", | type:"input", | ||
Line 273: | Line 285: | ||
label:"Subject of email (optional)", | label:"Subject of email (optional)", | ||
tooltip:"The subject line of the email you sent." | tooltip:"The subject line of the email you sent." | ||
}); | |||
break; | |||
case "see": | |||
work_area.append({ | |||
type:"input", | |||
name:"page", | |||
label:"Full page name", | |||
tooltip:"The full page name of where the discussion is being held. For example: 'Wikipedia talk:Twinkle'.", | |||
value: prev_page | |||
}); | |||
work_area.append({ | |||
type:"input", | |||
name:"section", | |||
label:"Linked section (optional)", | |||
tooltip:"The section heading where the discussion is being held. For example: 'Merge proposal'.", | |||
value: prev_section | |||
}); | }); | ||
break; | break; | ||
Line 297: | Line 325: | ||
var page = null; | var page = null; | ||
var section = e.target.section.value; | var section = e.target.section.value; | ||
var fullUserTalkPageName = mw.config.get("wgFormattedNamespaces")[ mw.config.get("wgNamespaceIds").user_talk ] + ":" + | var fullUserTalkPageName = mw.config.get("wgFormattedNamespaces")[ mw.config.get("wgNamespaceIds").user_talk ] + ":" + mw.config.get('wgRelevantUserName'); | ||
if( tbtarget === "usertalk" || tbtarget === "other" ) { | if( tbtarget === "usertalk" || tbtarget === "other" || tbtarget === "see" ) { | ||
page = e.target.page.value; | page = e.target.page.value; | ||
if( tbtarget === "usertalk" ) { | if( tbtarget === "usertalk" ) { | ||
if( !page ) { | if( !page ) { | ||
Line 334: | Line 362: | ||
if ( tbtarget === "notice" ) { | if ( tbtarget === "notice" ) { | ||
switch (page) { | switch (page) { | ||
case "afchd": | |||
text = "\n\n{{subst:AFCHD/u|" + section + "}} ~~~~"; | |||
talkpage.setEditSummary( "You have replies at the [[Wikipedia:AFCHD|Articles for Creation Help Desk]]" + Twinkle.getPref("summaryAd") ); | |||
break; | |||
case "an": | case "an": | ||
text = "\n\n== " + Twinkle.getFriendlyPref("adminNoticeHeading") + " ==\n"; | text = "\n\n== " + Twinkle.getFriendlyPref("adminNoticeHeading") + " ==\n"; | ||
text += "{{subst:ANI-notice|thread=" + section + "|noticeboard= | text += "{{subst:ANI-notice|thread=" + section + "|noticeboard=Wikipedia:Administrators' noticeboard}} ~~~~"; | ||
talkpage.setEditSummary( "Notice of discussion at [[ | talkpage.setEditSummary( "Notice of discussion at [[Wikipedia:Administrators' noticeboard]]" + Twinkle.getPref("summaryAd") ); | ||
break; | break; | ||
case "an3": | case "an3": | ||
text = "\n\n{{subst:An3-notice|" + section + "}} ~~~~"; | text = "\n\n{{subst:An3-notice|" + section + "}} ~~~~"; | ||
talkpage.setEditSummary( "Notice of discussion at [[ | talkpage.setEditSummary( "Notice of discussion at [[Wikipedia:Administrators' noticeboard/Edit warring]]" + Twinkle.getPref("summaryAd") ); | ||
break; | break; | ||
case "ani": | case "ani": | ||
text = "\n\n== " + Twinkle.getFriendlyPref("adminNoticeHeading") + " ==\n"; | text = "\n\n== " + Twinkle.getFriendlyPref("adminNoticeHeading") + " ==\n"; | ||
text += "{{subst:ANI-notice|thread=" + section + "|noticeboard= | text += "{{subst:ANI-notice|thread=" + section + "|noticeboard=Wikipedia:Administrators' noticeboard/Incidents}} ~~~~"; | ||
talkpage.setEditSummary( "Notice of discussion at [[ | talkpage.setEditSummary( "Notice of discussion at [[Wikipedia:Administrators' noticeboard/Incidents]]" + Twinkle.getPref("summaryAd") ); | ||
break; | break; | ||
case "coin": | case "coin": | ||
text = "\n\n{{subst:Coin-notice|thread=" + section + "}} ~~~~"; | text = "\n\n{{subst:Coin-notice|thread=" + section + "}} ~~~~"; | ||
talkpage.setEditSummary( "Notice of discussion at [[ | talkpage.setEditSummary( "Notice of discussion at [[Wikipedia:Conflict of interest noticeboard]]" + Twinkle.getPref("summaryAd") ); | ||
break; | break; | ||
case "drn": | case "drn": | ||
text = "\n\n{{subst:DRN-notice|thread=" + section + "}} ~~~~"; | text = "\n\n{{subst:DRN-notice|thread=" + section + "}} ~~~~"; | ||
talkpage.setEditSummary( "Notice of discussion at [[ | talkpage.setEditSummary( "Notice of discussion at [[Wikipedia:Dispute resolution noticeboard]]" + Twinkle.getPref("summaryAd") ); | ||
break; | break; | ||
case "hd": | case "hd": | ||
text = "\n\n== Your question at the Help desk ==\n"; | text = "\n\n== Your question at the Help desk ==\n"; | ||
text += "{{helpdeskreply|1=" + section + "|ts=~~~~~}}"; | text += "{{helpdeskreply|1=" + section + "|ts=~~~~~}}"; | ||
talkpage.setEditSummary( "You have replies at the [[ | talkpage.setEditSummary( "You have replies at the [[Wikipedia:Help desk|Wikipedia help desk]]" + Twinkle.getPref("summaryAd") ); | ||
break; | break; | ||
case "otrs": | case "otrs": | ||
text = "\n\n{{OTRSreply|1=" + section + "|2=~~~~}}"; | text = "\n\n{{OTRSreply|1=" + section + "|2=~~~~}}"; | ||
talkpage.setEditSummary( "You have replies at the [[ | talkpage.setEditSummary( "You have replies at the [[Wikipedia:OTRS noticeboard|OTRS noticeboard]]" + Twinkle.getPref("summaryAd") ); | ||
break; | break; | ||
case "th": | case "th": | ||
text = "\n\n== Teahouse talkback: you've got messages! ==\n{{WP:Teahouse/Teahouse talkback|WP:Teahouse/Questions|" + section + "|ts=~~~~}}"; | text = "\n\n== Teahouse talkback: you've got messages! ==\n{{WP:Teahouse/Teahouse talkback|WP:Teahouse/Questions|" + section + "|ts=~~~~}}"; | ||
talkpage.setEditSummary( "You have replies at the [[ | talkpage.setEditSummary( "You have replies at the [[Wikipedia:Teahouse/Questions|Teahouse question board]]" + Twinkle.getPref("summaryAd") ); | ||
break; | break; | ||
default: | default: | ||
Line 385: | Line 417: | ||
talkpage.setEditSummary("Notification: You've got mail" + Twinkle.getPref("summaryAd")); | talkpage.setEditSummary("Notification: You've got mail" + Twinkle.getPref("summaryAd")); | ||
} else { | } else if ( tbtarget === "see" ) { | ||
//clean talkback heading: strip section header markers | text = "\n\n{{subst:Please see|location=" + tbPageName; | ||
if (section) { | |||
text += "#" + section; | |||
} | |||
text += "|more=" + message.trim() + "}}"; | |||
talkpage.setEditSummary("Please check the discussion at [[:" + tbPageName + | |||
(section ? ("#" + section) : "") + "]]" + Twinkle.getPref("summaryAd")); | |||
} else { // tbtarget one of mytalk, usertalk, other | |||
// clean talkback heading: strip section header markers that were erroneously suggested in the documentation | |||
text = "\n\n==" + Twinkle.getFriendlyPref("talkbackHeading").replace( /^\s*=+\s*(.*?)\s*=+$\s*/, "$1" ) + "==\n{{talkback|"; | text = "\n\n==" + Twinkle.getFriendlyPref("talkbackHeading").replace( /^\s*=+\s*(.*?)\s*=+$\s*/, "$1" ) + "==\n{{talkback|"; | ||
text += tbPageName; | text += tbPageName; | ||
Line 402: | Line 443: | ||
} | } | ||
var editSummary = "Talkback ([[:"; | |||
if (tbtarget !== "other" && !/^\s*user talk:/i.test(tbPageName)) { | |||
editSummary += "User talk:"; | |||
} | |||
editSummary += tbPageName + (section ? ("#" + section) : "") + "]])"; | |||
talkpage.setEditSummary(editSummary + Twinkle.getPref("summaryAd")); | |||
} | } | ||