MediaWiki:Gadget-find-archived-section.js: Difference between revisions
Content deleted Content added
ensure execution after document ready |
cleanup code, move l10n stuff to the top |
||
Line 1:
}▼
}
};
$(function() {
Line 26 ⟶ 54:
return;
}
var sanitiseString = function(str, escapeHtml) {
▲ // START EDITING HERE FOR LOCALISATION
// if str contains $ signs, we don't want String.prototype.replace to treat them with special meaning
▲ // Messages: translate these strings if porting to a non-English language wiki
return (escapeHtml ? mw.html.escape(str) : str).replace(/\$/g, '$$$$');
▲ var msg = {
▲ "starter-text": "Looks like the discussion \"$1\" has been archived. ",
▲ "finding": "Finding archived discussion...",
▲ "click-link": "Click to see archived discussion",
▲ "no-search-results": "No search results found for section \"$1\" in archives. It may have been removed or renamed, or you may have followed a malformed link.",
▲ "search-link-found": "(or search in archives)", // link to search results when an exact match was obtained.
▲ "search-link-notfound": "Click to search in archives" // link to search results when an exact match was NOT obtained.
▲ };
▲ var config = {
▲ // Function to introduce arbitrary changes to prefix.
▲ // Used here as archive page names used for admin noticeboards on enwiki are unusual
▲ prefixNormaliser: function(prefix) {
▲ switch (prefix) {
▲ case "Wikipedia:Administrators' noticeboard/Incidents":
▲ return "Wikipedia:Administrators' noticeboard/IncidentArchive";
▲ case "Wikipedia:Administrators' noticeboard/Edit warring":
▲ return "Wikipedia:Administrators' noticeboard/3RRArchive";
▲ case "Wikipedia:Administrators' noticeboard":
▲ return "Wikipedia:Administrators' noticeboard/Archive";
▲ default:
▲ return prefix;
▲ }
};
▲ // STOP EDITING HERE FOR LOCALISATION
$('#mw-content-text').before(
$('<div>')
.text(msg['starter-text'].replace('$1',
.addClass('archived-section-prompt')
.css({
Line 97 ⟶ 102:
var results = json.query.search;
if (results.length === 0) {
divHtml = msg['no-search-results'].replace('$1',
} else {
Line 127 ⟶ 132:
});
divHtml = msg['starter-text'].replace('$1',
if (pageTitle) { // if a section with the same name was found
|