Content deleted Content added
MusikAnimal (talk | contribs) wait for document to be ready, declare mw.util dependency, spaces to tabs |
MusikAnimal (talk | contribs) use jQuery.textSelection on #wpTextbox1 |
||
(18 intermediate revisions by the same user not shown) | |||
Line 6:
mw.loader.using( ['mediawiki.util'], function() {
// show shortcuts if not editing
if (!mw.config.get('wgEditMessage') && window.responseHelperNavLinks !== false) {
mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Template:Admin dashboard', 'DASHBOARD', 'rh-dashboard');
mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Administrator intervention against vandalism', "WP:AIV");
mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Administrators%27 noticeboard/Edit warring', "WP:ANEW");
Line 13 ⟶ 14:
mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Usernames for administrator attention', "WP:UAA");
mw.util.addPortletLink('p-navigation', mw.config.get( 'wgServer' ) + '/wiki/Wikipedia:Sockpuppet investigations', "WP:SPI");
addDashboardListener();
return;
}
Line 27 ⟶ 29:
});
});
function addDashboardListener() {
$('#rh-dashboard').on('click', function (e) {
e.preventDefault();
// Use user-customized [[User:Foo/Dashboard]] if it exists, otherwise [[Template:Admin dashboard]]
var api = new mw.Api(),
userDashboardPage = 'User:' + mw.config.get('wgUserName') + '/Dashboard';
api.get({
action: 'query',
titles: userDashboardPage,
formatversion: 2
}).done(function (data) {
var pageExists = !data.query.pages[0].missing;
window.___location.href = '/wiki/' + (pageExists ? userDashboardPage : 'Template:Admin_dashboard');
});
});
}
function setResponses() {
if (/Wikipedia:Administrator_intervention_against_vandalism/.test(mw.config.get('wgPageName'))) {
indentation = "
templateName = "AIV";
inline = true;
Line 36 ⟶ 57:
"Checking" : {
code : "chk",
summary : "
},
"Warned user" : {
code : "w",
summary : "
},
"Insufficient activity" : {
code : "i",
summary : "
},
"No vand since final" : {
code : "f",
summary : "
},
"No edits since warn" : {
code : "nesw",
summary : "
},
"Stale warning" : {
code : "ow|
summary : "Stale warning. ",
prompt : "The last warning issued how long ago?"
Line 61 ⟶ 82:
"Monitoring" : {
code : "m",
summary : "
},
"Question" : {
Line 70 ⟶ 91:
"WP:ANEW" : {
code : "3rr",
summary : "
},
"WP:AN/I" : {
code : "a",
summary : "
},
"WP:UAA" : {
code : "u",
summary : "
},
"WP:RFPP" : {
code : "r",
summary : "
},
"WP:SPI" : {
code : "sp",
summary : "
},
"Note" : {
Line 108 ⟶ 129:
"4im inappropriate" : {
code : "4im",
summary : "
},
"Content dispute" : {
code : "c",
summary : "
},
"Insufficient warn." : {
code : "ns",
summary : "User
},
"Not punitive" : {
code : "np",
summary : "
},
"Not vandalism" : {
code : "nv",
summary : "
},
"False positive" : {
code : "fp",
summary : "
},
"Page protected" : {
code : "p",
summary : "
},
"Page deleted" : {
code : "d",
summary : "
},
"Stale report" : {
code : "e|
summary : "Stale report. ",
prompt : "How long since the user last edited?"
},
"Stale (was good)" : {
code : "sn|
summary : "Report was good but is now stale. ",
prompt : "How long since the user last edited?"
},
"Partially blocked" : {
code : "pb|$1",
summary : "User partially blocked. ",
prompt : "Which page(s) or namespaces was the user blocked from? (accepts wikitext)"
}
};
} else if (/Wikipedia:Usernames_for_administrator_attention/.test(mw.config.get('wgPageName'))) {
indentation = "
templateName = "UAA";
defaultPrompt = "Reason?";
inline = true;
responses = {
"Checking" : {
code : "chk",
summary : "Checking"
},
"Note" : {
code : "n",
Line 176 ⟶ 206:
"Monitor" : {
code : "m",
summary : "Keep monitoring the user, until their username is more clear
},
"Being discussed" : {
Line 184 ⟶ 214:
"Discussed, const. edits" : {
code : "dc",
summary : "Being discussed with the user, since they have edited constructively
},
"Requested change" : {
code : "rc",
summary : "User has requested a username change
},
"Changed username" : {
code : "ch",
summary : "User has changed their username
},
"Problem" : {
Line 204 ⟶ 234:
"Not violation" : {
code : "not",
summary : "Not a blatant violation of the username policy
},
"Not vio, real name" : {
Line 212 ⟶ 242:
"Not vio, watch edits" : {
code : "e",
summary : "Not a blatant violation of the username policy, but worth keeping an eye on their edits
},
"Not
code : "coi",
summary : "Not a blatant violation of the username policy. Consider filing a report at the [[WP:COI/N]]
},
"Not vio, RFCN" : {
Line 225 ⟶ 255:
code: "fp",
summary: "False positive by bot. Username is not a blatant violation of the username policy"
}
};
} else if (/Wikipedia:Requests_for_undeletion/.test(mw.config.get('wgPageName'))) {
indentation = "*";
templateName = "subst:UND";
responses = {
"Done" : {
code : "d",
summary : "Done. ",
prompt : "Additional comment?"
},
"Done (PROD)" : {
code : "prod",
summary : "Done: Contested [[WP:PROD|proposed deletion]], the article has been restored upon request."
},
"Done (G13)" : {
code : "g13",
summary : "Done: [[WP:DRAFTS|Draft]] or [[WP:AfC|AfC]] submission deleted under [[WP:G13|CSD G13]]."
},
"Done (G13 draft)" : {
code : "g13-draft",
summary : "Done: [[WP:DRAFTS|Draft]] deleted under [[WP:G13|CSD G13]]. Please continue to improve and submit for review."
},
"Done (AfC)" : {
code : "afc",
summary : "Done: [[WP:AfC|AfC]] submission deleted under [[WP:G13|CSD G13]]. Please edit to address any issues and re-submit."
},
"Done (AfC no review)" : {
code : "afc-ns",
summary : "Done: [[WP:AfC|AfC]] submission deleted under [[WP:G13|CSD G13]]. Please remember to submit the draft for review."
},
"Userfied" : {
code : "u|$1",
summary : "Userfied at [[$1]]",
prompt : "Full title of userspace page?",
valueRequired : true
},
"Userfied (notability)" : {
code : "userA7|$1|$2",
summary : "Userfied at [[$1]]",
prompt : "Full title of userspace page?",
prompt2 : "Username of admin who deleted the original page?",
valueRequired : true
},
"Not done" : {
code : "nd",
summary : "Not Done. ",
prompt : "Reason?"
},
"Not done (permanent)" : {
code : "nd2",
summary : "Not done and will not be done.",
prompt : "Additional comment?"
},
"Not done (company)" : {
code : "ndc",
summary : "Not done: does not meet [[WP:CORP|notability guideline on companies]]"
},
"Not done (person)" : {
code : "ndp",
summary : "Not done: does not meet [[WP:BIO|notability guideline on people]]"
},
"Not done (music)" : {
code : "ndb",
summary : "Not done: does not meet [[WP:NMUSIC|notability guideline on music]]"
},
"Not done (G11)" : {
code : "g11",
summary : "Not done: [[WP:G11|blatant advertising]]"
},
"Not done (A7)" : {
code : "c|a7",
summary : "Not done: page was deleted as giving [[WP:A7|no indication of importance]]"
},
"Not done (copyvio)" : {
code : "copy|$1",
summary : "Not done: page is a [[WP:COPYVIO|copyright violation]] ",
prompt : "Source URL?"
},
"Not done (unsuitable)" : {
code : "in",
summary : "Not done: inappropriate topic for Wikipedia"
},
"Not done (live)" : {
code : "nyd",
summary : "Not done: page has not yet been deleted"
},
"Not done (live, PROD)" : {
code : "nydp",
summary : "Not done: page has not yet been deleted; See [[WP:PROD]] for responding to proposed deletion."
},
"Not done (live, BLP)" : {
code : "nydb",
summary : "Not done: page has not yet been deleted; See [[WP:BLPPROD]] for responding to proposed deletion."
},
"Not done (nonexistent)" : {
code : "dne",
summary : "Not done: a deleted page with this title does not appear to exist"
},
"Not done (AfD)" : {
code : "afd|$1|$2",
summary : "Not done: page was deleted following a [[$1|deletion discussion]]",
prompt : "Full title of deletion discussion page?",
prompt2 : "Username of admin who closed the discussion?",
valueRequired : true,
value2Required : true
},
"Blocked" : {
code : "blocked",
summary : "Not done: user blocked ",
prompt : "Additional comment?"
},
"Malformed report" : {
code : "malformed",
summary : "Not done: Please repair your request"
},
"Declined (need info)" : {
code : "2nd",
summary : "Declined pending further information"
}
};
Line 373 ⟶ 522:
},
"CU no comment X" : {
code : "nc|
summary : "No comment regarding ",
prompt: "No comment regarding...?"
Line 406 ⟶ 555:
if (/Wikipedia:Requests_for_permissions\/(?!Rollback|Confirmed|Page_mover)/.test(mw.config.get('wgPageName'))) {
// base responses for permission pages
indentation = "
templateName = "";
defaultPrompt = "Reason?";
Line 412 ⟶ 561:
"Done" : {
code : "done",
summary : "
},
"Not done" : {
Line 436 ⟶ 585:
} else switch (mw.config.get('wgPageName')) {
case 'Wikipedia:Requests_for_permissions/Rollback':
indentation = "
templateName = "subst:RFPR";
defaultPrompt = "Admin's name?";
Line 442 ⟶ 591:
"Done" : {
code : "d",
summary : "
},
"Already done" : {
code : "ad|
summary : "
},
"Revoked" : {
code : "r",
summary : "
},
"Not done" : {
code : "nd",
summary : "
prompt : "Reason?"
},
"Not done (exp)" : {
code : "exp|
summary : "
prompt : "Number of mainspace edits?"
},
"Not done (rvw)" : {
code : "rvw",
summary : "
},
"Not done (nrb)" : {
code : "nrb",
summary : "
}
};
break;
case 'Wikipedia:Requests_for_permissions/Confirmed':
indentation = "
templateName = "subst:RFPC";
responses = {
"Done" : {
code : "d",
summary : "
},
"Already done" : {
code : "ad",
summary : "
id : "adc"
},
"Revoked" : {
code : "r",
summary : "
},
"Not done" : {
code : "nd",
summary : "
prompt : "Reason?"
},
"Not done (no reason)" : {
code : "ndng",
summary : "Not done: No reason given."
},
"Not done (95%)" : {
code : "nd95",
summary : "
},
"Not done (file)" : {
code : "ndf",
summary : "
},
"Not done (promoblock)" : {
code : "ndpromou",
summary : "
},
"Not done (no reply)" : {
code : "ndnr",
summary : "
},
"Not done (per above)" : {
code : "ndpa",
summary : "
},
"Not done (IP)" : {
code : "ip",
summary : "
},
"Question - why?" : {
code : "why",
summary : "
}
};
break;
case 'Wikipedia:Requests_for_permissions/Page_mover':
indentation = "
templateName = "subst:RFPPM";
responses = {
"Done" : {
code : "d",
summary : "
},
"Already done" : {
code : "ad",
summary : "
id : "adc"
},
"Revoked" : {
code : "r",
summary : "
},
"Not done" : {
code : "nd",
summary : "
prompt : "Reason?"
},
"Not done (exp)" : {
code : "exp|
summary : "
prompt : "Number of total edits?"
},
"Not done (npm)" : {
code : "npm",
summary : "
}
};
break;
case 'Wikipedia:Requests_for_page_protection':
case 'Wikipedia:Requests_for_page_protection/Increase':
case 'Wikipedia:Requests_for_page_protection/Decrease':
templateName = "subst:RFPP";
defaultPrompt = "Duration?";
responses = {
"Checking" : {
code : "ch",
summary : "
},
"Semi-protected" : {
code : "s|
summary : "
},
"Pending protected" : {
code : "pd|
summary : "
},
"Fully protected" : {
code : "p|
summary : "
},
"Move protected" : {
code : "m|
summary : "
},
"Creation protected" : {
code : "t|
summary : "
},
"Template protected" : {
code : "tp|
summary : "
},
"EC protected" : {
code : "ec|
summary : "
},
"Done" : {
code : "do",
summary : "
},
"Not done" : {
code : "no",
summary : "
},
"Declined" : {
Line 605 ⟶ 760:
summary : "Declined. ",
prompt : "Reason?"
},
"Declined co" : {
code : "co",
summary : "Declined – likely will cause collateral damage"
},
"Declined nea" : {
code : "nea",
summary : "
},
"Declined aiv" : {
code : "aiv",
summary : "
},
"Declined np" : {
code : "np",
summary : "
},
"Declined nhr" : {
code : "nhr",
summary : "
},
"Declined dr" : {
code : "dr",
summary : "
},
"Declined ut" : {
code : "ut",
summary : "
},
"Declined her" : {
code : "her",
summary : "
},
"Users blocked" : {
code : "b",
summary : "
},
"Users reblocked" : {
code : "tb",
summary : "
},
"Unprotected" : {
code : "u",
summary : "
},
"Not unprotected" : {
code : "nu",
summary : "
},
"Already unprot'd" : {
code : "au|
summary : "
prompt : "Admin's name?"
},
"Already prot'd" : {
code : "ap|
summary : "
prompt : "Admin's name?"
},
"Already done" : {
code : "ad|
summary : "
prompt : "Admin's name?"
},
"Question" : {
code : "q",
summary : "
prompt : "Question:"
},
"Note" : {
code : "n",
summary : "
prompt : "Note:"
},
"Archive" : {
code : "ar",
summary : "
},
"Withdrawn" : {
code : "w",
summary : "
},
"Edit warring" : {
code : "ew",
summary : "
}
};
Line 696 ⟶ 855:
responses = {
"Blocked" : {
code : "b|
summary : "
},
"Nom. blocked" : {
code : "nb|
summary : "
},
"Both blocked" : {
code : "bb|
summary : "
},
"Already blocked" : {
code : "ab",
summary : "
},
"No violation" : {
code : "nv",
summary : "
},
"No 3RR vio" : {
code : "nve",
summary : "
},
"Stale" : {
code : "s",
summary : "
},
"Declined" : {
code : "d",
summary : "
prompt : "Reason?"
},
"Malformed report" : {
code : "mr",
summary : "
},
"Not blocked" : {
code : "not",
summary : "
},
"Page protected" : {
code : "p",
summary : "
},
"Page prot'd dr" : {
code : "pe",
summary : "
},
"Warned" : {
code : "w",
summary : "
},
"Note" : {
Line 768 ⟶ 927:
function respondFn(e) {
var response = e.data.response;
var code = response.code, comment = "", value = "", value2 = "";
if (code.indexOf("
value = prompt((response.prompt ? response.prompt : defaultPrompt) +
(response.valueRequired ? '' : " (optional, hit OK to omit)")); if (value === null) return false;
code = code.
if (code.indexOf("$2") !== -1) {
value2 = prompt(response.prompt2 + (response.value2Required ? '' : " (optional, hit OK to omit)"));
if (value2 === null) return false;
code = code.replace('$2', value2);
}
} else if (response.prompt) {
value = prompt(response.prompt + " (optional, hit OK to omit)");
Line 781 ⟶ 947:
var $textarea = $("#wpTextbox1");
var currentText = $textarea.
var responseStr = indentation + "{{" + (templateName ? templateName + "|" : "") + code.replace(/\|$/, '') + "}}" + comment + " ~~~~";
if (inline) {
var caretPos = $textarea
$textarea.
} else if (spi) {
$textarea.
'setContents',
currentText.replace(/(\n----<\!---|$)/, responseStr + "\n$&")
);
} else {
$textarea.
}
if (anew && !unresolved) {
var textArray = $textarea.
$textarea.
'setContents',
textArray[0].replace('(Result: )','(Result: ' + (response.summary[0].toUpperCase() + response.summary.slice(1) + value).trim() + ')') +
'\n' + $textarea.
);
}
if (response.summary.indexOf('$1') !== -1) {
response.summary = response.summary.replace('$1', value.trim());
if (response.summary.indexOf('$2') !== -1) {
response.summary = response.summary.replace('$2', value2.trim());
}
} else {
response.summary = response.summary + value.trim();
}
$("#wpSummary").val($("#wpSummary").val() + response.summary + " (using [[User:MusikAnimal/responseHelper|responseHelper]])");
}
}());
|