MediaWiki:Gadget-find-archived-section.js: Difference between revisions

Content deleted Content added
sync in update, requested on talk
+case "Wikipedia:Teahouse":
 
(4 intermediate revisions by 3 users not shown)
Line 34:
case "Wikipedia:Administrators' noticeboard":
return "Wikipedia:Administrators' noticeboard/Archive";
case "Wikipedia:Reference desk/Science":
return "Wikipedia:Reference desk/Archives/Science";
case "Wikipedia:Reference desk/Miscellaneous":
return "Wikipedia:Reference desk/Archives/Miscellaneous";
case "Wikipedia:Reference desk/Mathematics":
return "Wikipedia:Reference desk/Archives/Mathematics";
case "Wikipedia:Reference desk/Language":
return "Wikipedia:Reference desk/Archives/Language";
case "Wikipedia:Reference desk/Humanities":
return "Wikipedia:Reference desk/Archives/Humanities";
case "Wikipedia:Reference desk/Entertainment":
return "Wikipedia:Reference desk/Archives/Entertainment";
case "Wikipedia:Reference desk/Computing":
return "Wikipedia:Reference desk/Archives/Computing";
case "Wikipedia:Reference desk":
return "Wikipedia:Reference desk/Archives";
case "Wikipedia:Teahouse":
return "Wikipedia:Teahouse/Questions";
default:
return prefix;
Line 48 ⟶ 66:
 
// Show only on discussion pages (pages with "add section" button)
// On minerva skin (which doesn't use the add section button) show on all talk & project space pages
if (!addsection && (!correctNs || !minerva)) {
return;
Line 65 ⟶ 83:
if (!sectionName || // no section name in URL
sectionName.indexOf('/media/') === 0 || // URLs used by MediaViewer
/^c-/.test(sectionName) || //URLs used by DiscussionTools
/^\d{12} /.test(sectionName) || // URLs used by convenientDiscussions
/^noticeApplied-/.test(sectionName) || // URLs used by RedWarn
document.getElementById(sectionName.replace(/ /g, '_')) !== null) { // section exists on page
return;
Line 123 ⟶ 143:
// obtain the the first exact section title match (which would be from the most recent archive)
// this loop iterates over just one item in the vast majority of cases
var sectionName_ = sectionName.replace(/ /g, '_');
var sectionNameDotDecoded_ = sectionNameDotDecoded.replace(/ /g, '_');
for (var i in results) {
var result = results[i];
// sectiontitle in API output has spaces encoded as underscores
if (
result.sectiontitle &&
(result.sectiontitle === sectionName_sectionName || result.sectiontitle === sectionNameDotDecoded_sectionNameDotDecoded)
) {
pageTitle = result.title;
sectionNameFound = result.sectiontitle.replace(/_/g, ' ');
break;
}
Line 144 ⟶ 161:
});
 
var escapedSectionName = mw.html.escape(sectionNameFound || sectionName);
 
if (pageTitle) { // if a section with the same name was found