Document OCR review UI and docs
Document OCR review UI and docs
Line 624: Line 624:
var $box = $('<div>', { 'class': 'soldier-upload-box' });
var $box = $('<div>', { 'class': 'soldier-upload-box' });
$box.append($('<p>').append(
$box.append($('<p>').append(
$('<strong>').text('Upload for this soldier'),
$('<strong>').text('Contribute files for this soldier'),
document.createTextNode(' — photos (infobox portrait) or documents (PDF, Word, etc.). You can also use '),
document.createTextNode(' — photos (portrait or Gallery), documents, or OCR a scan below. You can also use '),
$('<a>', { href: uploadUrl, text: 'Special:Upload' }),
$('<a>', { href: uploadUrl, text: 'Special:Upload' }),
document.createTextNode('.')
document.createTextNode('.')
));
var $photoSection = $('<div>', { 'class': 'soldier-contrib-section soldier-contrib-upload' });
$photoSection.append($('<p>', { 'class': 'soldier-contrib-heading' }).append(
$('<strong>').text('Photo or document upload')
));
));


if (!loggedIn) {
if (!loggedIn) {
$box.append($('<p>', { 'class': 'soldier-upload-login' }).html(
$photoSection.append($('<p>', { 'class': 'soldier-upload-login' }).html(
'<a href="' + mw.util.getUrl('Special:UserLogin', { returnto: pageTitle }) + '">Log in</a> to upload files.'
'<a href="' + mw.util.getUrl('Special:UserLogin', { returnto: pageTitle }) + '">Log in</a> to upload files or run document OCR.'
));
));
$box.append($photoSection);
$galleryHeading.after($box);
$galleryHeading.after($box);
return;
return;
Line 652: Line 658:


$form.append($file, $profile, $gallery, $submit, $status);
$form.append($file, $profile, $gallery, $submit, $status);
$box.append($form);
$photoSection.append($form);
$box.append($photoSection);
/* OCR tools mount into .soldier-ocr-slot (filled by the OCR init below). */
$box.append($('<div>', { 'class': 'soldier-ocr-slot' }));
$galleryHeading.after($box);
$galleryHeading.after($box);


Line 1,263: Line 1,272:
'<a href="' + mw.util.getUrl('Special:UserLogin', { returnto: pageTitle }) + '">Log in</a> to upload documents for OCR review.'
'<a href="' + mw.util.getUrl('Special:UserLogin', { returnto: pageTitle }) + '">Log in</a> to upload documents for OCR review.'
);
);
if (isSoldier) {
$('.soldier-upload-box').first().append(
$('<div>', { 'class': 'ocr-review-box' }).append(
$('<h3>').text('OCR a document for this soldier'),
$need
)
);
}
if (isInbox) {
if (isInbox) {
$('.ocr-inbox-slot').first().append($need);
$('.ocr-inbox-slot').first().append($need);
}
}
/* Soldier pages already show a combined login note in .soldier-upload-box. */
return;
return;
}
}
Line 1,281: Line 1,283:


if (isSoldier) {
if (isSoldier) {
var $box = $('<div>', { 'class': 'ocr-review-box' });
var $section = $('<div>', { 'class': 'soldier-contrib-section soldier-contrib-ocr' });
$box.append($('<h3>').text('OCR a document for this soldier'));
$section.append($('<p>', { 'class': 'soldier-contrib-heading' }).append(
$box.append($('<p>').text(
$('<strong>').text('OCR a document')
'Upload a scan or photo of a document. The site will OCR it and show proposed facts for you to review before anything is written to this profile.'
));
));
var $file = $('<input>', { type: 'file', accept: '.jpg,.jpeg,.png,.gif,.webp,.tif,.tiff,.pdf' });
$section.append($('<p>', { 'class': 'soldier-contrib-help' }).text(
'Scan or photo of a form, letter, or roster. Proposed facts appear here for review — nothing is written until Apply.'
));
var $file = $('<input>', {
type: 'file',
accept: '.jpg,.jpeg,.png,.gif,.webp,.tif,.tiff,.pdf',
'class': 'soldier-upload-file'
});
var $btn = $('<button>', { type: 'button', text: 'Upload & OCR' });
var $btn = $('<button>', { type: 'button', text: 'Upload & OCR' });
var $host = $('<div>', { 'class': 'ocr-review-host' });
var $host = $('<div>', { 'class': 'ocr-review-host' });
$box.append($file, ' ', $btn, $host);
$section.append($file, $btn, $host);
$btn.on('click', function () {
$btn.on('click', function () {
startUpload($file, pageTitle, $host, cfg);
startUpload($file, pageTitle, $host, cfg);
});
});
var $galleryBox = $('.soldier-upload-box').first();
var $slot = $('.soldier-ocr-slot').first();
if ($galleryBox.length) {
if ($slot.length) {
$galleryBox.after($box);
$slot.empty().append($section);
} else {
} else {
$('.soldier-infobox').first().after($box);
var $fallback = $('<div>', { 'class': 'soldier-upload-box' }).append($section);
$('.soldier-infobox').first().after($fallback);
}
}
}
}