|
|
| Line 3,035: |
Line 3,035: |
| }()); | | }()); |
|
| |
|
| (function rbSoldierNeeds() {
| |
| var $out = $('.mw-parser-output').first();
| |
| if (!$out.length || !$out.find('table.soldier-infobox, table.infobox').length) return;
| |
| if ($out.find('.soldier-needs').length) return;
| |
| var bioText = '';
| |
| $out.find('h2').each(function () {
| |
| var t = $.trim($(this).find('.mw-headline').text() || $(this).text());
| |
| if (!/^Biography\b/i.test(t)) return;
| |
| var $n = $(this).next();
| |
| while ($n.length && !$n.is('h2')) {
| |
| bioText += ' ' + $n.text();
| |
| $n = $n.next();
| |
| }
| |
| });
| |
| bioText = $.trim(bioText);
| |
| var thinBio = !bioText || bioText.length < 280 || /add a biography|placeholder|coming soon/i.test(bioText);
| |
| var hasPhoto = $out.find('table.soldier-infobox img, table.infobox img').length > 0;
| |
| var needs = [];
| |
| if (!hasPhoto) needs.push('A confirmed portrait for the profile photo');
| |
| if (thinBio) needs.push('A short sourced Biography paragraph (and Sources bullet)');
| |
| var box = ($out.find('table.soldier-infobox, table.infobox').first().text() || '');
| |
| if (!/\b\d{1,2} (January|February|March|April|May|June|July|August|September|October|November|December) \d{4}\b/.test(box)) {
| |
| needs.push('Full birth and/or death dates when publicly known');
| |
| }
| |
| if (!/Team|IPW/i.test(box)) {
| |
| needs.push('Team / IPW assignment if known from a roster');
| |
| }
| |
| if (!needs.length) return;
| |
| var $lead = $out.find('.soldier-lead, .page-lead').first();
| |
| var $box = $('<div class="soldier-needs"></div>');
| |
| $box.append($('<div class="soldier-needs-title"></div>').text('Still needed for this profile'));
| |
| var $ul = $('<ul></ul>');
| |
| needs.forEach(function (n) { $ul.append($('<li></li>').text(n)); });
| |
| $box.append($ul);
| |
| $box.append($('<p></p>').html('Families: see <a href="/index.php?title=For_families">For families</a>. Editors: <a href="/index.php?title=Contribute">Contribute</a>.'));
| |
| if ($lead.length) $lead.after($box);
| |
| else $out.prepend($box);
| |
| }());
| |
|
| |
|
| (function rbRelatedMediaWrap() { | | (function rbRelatedMediaWrap() { |
| Line 3,080: |
Line 3,042: |
| if ($cues.length < 1) return; | | if ($cues.length < 1) return; |
| if ($out.find('.soldier-related-media').length) return; | | if ($out.find('.soldier-related-media').length) return; |
| var $wrap = $('<div class="soldier-related-media"><div class="soldier-needs-title">Related media</div></div>'); | | var $wrap = $('<div class="soldier-related-media"><div class="soldier-related-media-title">Related media</div></div>'); |
| $cues.first().before($wrap); | | $cues.first().before($wrap); |
| $cues.appendTo($wrap); | | $cues.appendTo($wrap); |
| }()); | | }()); |