MediaWiki:Common.js: Difference between revisions
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(' | $('<strong>').text('Contribute files for this soldier'), | ||
document.createTextNode(' — photos ( | 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) { | ||
$ | $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($ | $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 (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 $ | var $section = $('<div>', { 'class': 'soldier-contrib-section soldier-contrib-ocr' }); | ||
$ | $section.append($('<p>', { 'class': 'soldier-contrib-heading' }).append( | ||
$('<strong>').text('OCR a document') | |||
)); | )); | ||
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' }); | ||
$ | $section.append($file, $btn, $host); | ||
$btn.on('click', function () { | $btn.on('click', function () { | ||
startUpload($file, pageTitle, $host, cfg); | startUpload($file, pageTitle, $host, cfg); | ||
}); | }); | ||
var $ | var $slot = $('.soldier-ocr-slot').first(); | ||
if ($ | if ($slot.length) { | ||
$ | $slot.empty().append($section); | ||
} else { | } else { | ||
$('.soldier-infobox').first().after($ | var $fallback = $('<div>', { 'class': 'soldier-upload-box' }).append($section); | ||
$('.soldier-infobox').first().after($fallback); | |||
} | } | ||
} | } | ||