MediaWiki:Gadget-friendlytalkback.js: Difference between revisions

Jump to navigation Jump to search
Trying an old version
(SV)
(Trying an old version)
Line 16: Line 16:
Twinkle.talkback = function() {
Twinkle.talkback = function() {


if ( !mw.config.get('wgRelevantUserName') ) {
if ( Morebits.getPageAssociatedUser() === false ) {
return;
return;
}
}
Line 24: Line 24:


Twinkle.talkback.callback = function( ) {
Twinkle.talkback.callback = function( ) {
if( mw.config.get('wgRelevantUserName') === mw.config.get("wgUserName") && !confirm("Is it really so bad that you're talking back to yourself?") ){
if( Morebits.getPageAssociatedUser() === 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 85: Line 81:


// Check whether the user has opted out from talkback
// Check whether the user has opted out from talkback
var query = {
// TODO: wgCategories is only set on action=view (bug 45033)
action: 'query',
var wgcat = mw.config.get("wgCategories");
prop: 'extlinks',
if (wgcat.length && wgcat.indexOf("Users who do not wish to receive talkbacks") === -1) {
titles: mw.config.get('wgPageName'),
Twinkle.talkback.optout = false;
elquery: 'userjs.invalid/noTalkback',
} else {
ellimit: '1'
var query = {
};
action: 'query',
var wpapi = new Morebits.wiki.api("Fetching talkback opt-out status", query, Twinkle.talkback.callback.optoutStatus);
prop: 'extlinks',
wpapi.post();
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 103: Line 105:


if ($el.length) {
if ($el.length) {
Twinkle.talkback.optout = mw.config.get('wgRelevantUserName') + " prefers not to receive talkbacks";
Twinkle.talkback.optout = Morebits.getPageAssociatedUser() + " prefers not to receive talkbacks";
var url = $el.text();
var url = $el.text();
if (url.indexOf("reason=") > -1) {
if (url.indexOf("reason=") > -1) {
Line 177: Line 179:
value: prev_page
value: prev_page
});
});
 
work_area.append({
work_area.append({
type:"input",
type:"input",
Line 190: Line 192:
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 209: Line 202:
type: "option",
type: "option",
label: "WP:AN3 (Administrators' noticeboard/Edit warring)",
label: "WP:AN3 (Administrators' noticeboard/Edit warring)",
selected: true,
value: "an3"
value: "an3"
});
});
Line 216: Line 210:
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 235: Line 223:
noticeboard.append({
noticeboard.append({
type: "option",
type: "option",
label: "WP:HD (Help desk)",
label: "WP:OTRS/N (OTRS noticeboard)",
value: "hd"
value: "otrs"
});
});
noticeboard.append({
noticeboard.append({
type: "option",
type: "option",
label: "WP:OTRS/N (OTRS noticeboard)",
label: "WP:HD (Help desk)",
value: "otrs"
value: "hd"
});
});
noticeboard.append({
noticeboard.append({
Line 270: Line 258:
value: prev_page
value: prev_page
});
});
 
work_area.append({
work_area.append({
type:"input",
type:"input",
Line 285: Line 273:
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 325: Line 297:
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 ] + ":" + mw.config.get('wgRelevantUserName');
var fullUserTalkPageName = mw.config.get("wgFormattedNamespaces")[ mw.config.get("wgNamespaceIds").user_talk ] + ":" + Morebits.getPageAssociatedUser();


if( tbtarget === "usertalk" || tbtarget === "other" || tbtarget === "see" ) {
if( tbtarget === "usertalk" || tbtarget === "other" ) {
page = e.target.page.value;
page = e.target.page.value;
 
if( tbtarget === "usertalk" ) {
if( tbtarget === "usertalk" ) {
if( !page ) {
if( !page ) {
Line 362: Line 334:
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 [[SarkarverseAFCHD|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=SarkarverseAdministrators' noticeboard}} ~~~~";
text += "{{subst:ANI-notice|thread=" + section + "|noticeboard=Sarkarverse:Administrators' noticeboard}} ~~~~";
talkpage.setEditSummary( "Notice of discussion at [[SarkarverseAdministrators' noticeboard]]" + Twinkle.getPref("summaryAd") );
talkpage.setEditSummary( "Notice of discussion at [[Sarkarverse: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 [[SarkarverseAdministrators' noticeboard/Edit warring]]" + Twinkle.getPref("summaryAd") );
talkpage.setEditSummary( "Notice of discussion at [[Sarkarverse: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=SarkarverseAdministrators' noticeboard/Incidents}} ~~~~";
text += "{{subst:ANI-notice|thread=" + section + "|noticeboard=Sarkarverse:Administrators' noticeboard/Incidents}} ~~~~";
talkpage.setEditSummary( "Notice of discussion at [[SarkarverseAdministrators' noticeboard/Incidents]]" + Twinkle.getPref("summaryAd") );
talkpage.setEditSummary( "Notice of discussion at [[Sarkarverse: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 [[SarkarverseConflict of interest noticeboard]]" + Twinkle.getPref("summaryAd") );
talkpage.setEditSummary( "Notice of discussion at [[Sarkarverse: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 [[SarkarverseDispute resolution noticeboard]]" + Twinkle.getPref("summaryAd") );
talkpage.setEditSummary( "Notice of discussion at [[Sarkarverse: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 [[SarkarverseHelp desk|Wikipedia help desk]]" + Twinkle.getPref("summaryAd") );
talkpage.setEditSummary( "You have replies at the [[Sarkarverse: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 [[SarkarverseOTRS noticeboard|OTRS noticeboard]]" + Twinkle.getPref("summaryAd") );
talkpage.setEditSummary( "You have replies at the [[Sarkarverse: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 [[SarkarverseTeahouse/Questions|Teahouse question board]]" + Twinkle.getPref("summaryAd") );
talkpage.setEditSummary( "You have replies at the [[Sarkarverse:Teahouse/Questions|Teahouse question board]]" + Twinkle.getPref("summaryAd") );
break;
break;
default:
default:
Line 417: Line 385:
talkpage.setEditSummary("Notification: You've got mail" + Twinkle.getPref("summaryAd"));
talkpage.setEditSummary("Notification: You've got mail" + Twinkle.getPref("summaryAd"));


} else if ( tbtarget === "see" ) {
} else {
text = "\n\n{{subst:Please see|location=" + tbPageName;
//clean talkback heading: strip section header markers, were erroneously suggested in the documentation
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 443: Line 402:
}
}


var editSummary = "Talkback ([[:";
talkpage.setEditSummary("Talkback ([[" + (tbtarget === "other" ? "" : "User talk:") + tbPageName +
if (tbtarget !== "other" && !/^\s*user talk:/i.test(tbPageName)) {
(section ? ("#" + section) : "") + "]])" + Twinkle.getPref("summaryAd"));
editSummary += "User talk:";
}
editSummary += tbPageName + (section ? ("#" + section) : "") + "]])";
talkpage.setEditSummary(editSummary + Twinkle.getPref("summaryAd"));
}
}


14,061

edits

Navigation menu