MediaWiki:Common.js: Difference between revisions
Fill Teammates lists from live Category:Team membership |
Empty search help; Biography wording |
||
| Line 341: | Line 341: | ||
resort(siteTitles); | resort(siteTitles); | ||
}); | }); | ||
}()); | |||
(function emptySearchHelp() { | |||
if (mw.config.get('wgCanonicalSpecialPageName') !== 'Search') { | |||
return; | |||
} | |||
var params = new URLSearchParams(window.location.search); | |||
var raw = String(params.get('search') || '').trim(); | |||
if (!raw) { | |||
return; | |||
} | |||
var $results = $('.mw-search-results').first(); | |||
var noneFound = $('.mw-search-nonefound').length > 0 | |||
|| ($('.searchresults').length && !$results.length) | |||
|| ($results.length && $results.children('li').length === 0); | |||
if (!noneFound) { | |||
return; | |||
} | |||
if ($('.rb-search-empty-help').length) { | |||
return; | |||
} | |||
var contactUrl = mw.util.getUrl('Contact Us'); | |||
var startUrl = mw.util.getUrl('Start here') + '#If_the_name_is_not_found'; | |||
var $box = $('<div class="rb-search-empty-help" role="note"></div>'); | |||
$box.append($('<p></p>').append( | |||
$('<strong></strong>').text('No soldier page matched “' + raw + '”.') | |||
)); | |||
$box.append($('<ul></ul>').append( | |||
$('<li></li>').text('Try alternate spellings, anglicized names, or maiden vs married surnames.'), | |||
$('<li></li>').text('Try the ASN with or without leading zeros.'), | |||
$('<li></li>').text('They may be missing from the Classes 1–31 roster import or not yet matched.') | |||
)); | |||
$box.append($('<p></p>').append( | |||
$('<a></a>').attr('href', startUrl).text('If the name is not found'), | |||
document.createTextNode(' · '), | |||
$('<a></a>').attr('href', contactUrl).text('Contact Us') | |||
)); | |||
var $host = $('.mw-search-nonefound').first(); | |||
if ($host.length) { | |||
$host.after($box); | |||
} else if ($('.searchresults').length) { | |||
$('.searchresults').first().prepend($box); | |||
} else { | |||
$('#mw-content-text').prepend($box); | |||
} | |||
}()); | }()); | ||
| Line 1,237: | Line 1,282: | ||
document.createTextNode(' (infobox fields), '), | document.createTextNode(' (infobox fields), '), | ||
$('<a>', { href: editUrl, text: 'Edit biography' }), | $('<a>', { href: editUrl, text: 'Edit biography' }), | ||
document.createTextNode(' (visual editor for | document.createTextNode(' (visual editor for Biography and notes), or '), | ||
$('<a>', { href: sourceUrl, text: 'Edit source' }), | $('<a>', { href: sourceUrl, text: 'Edit source' }), | ||
document.createTextNode(' (full page markup).') | document.createTextNode(' (full page markup).') | ||