forked from not-implemented/hocr-proofreader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js~
45 lines (35 loc) · 1.37 KB
/
main.js~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
Util.onReady(function () {
var hocrProofreader = new HocrProofreader({
layoutContainer: 'layout-container',
editorContainer: 'editor-container'
});
document.getElementById('toggle-layout-image').addEventListener('click', function () {
hocrProofreader.toggleLayoutImage();
});
document.getElementById('zoom-page-full').addEventListener('click', function () {
hocrProofreader.setZoom('page-full');
});
document.getElementById('zoom-page-width').addEventListener('click', function () {
hocrProofreader.setZoom('page-width');
});
document.getElementById('zoom-original').addEventListener('click', function () {
hocrProofreader.setZoom('original');
});
document.getElementById('button-save').addEventListener('click', function () {
var hocr = hocrProofreader.getHocr();
var request = new XMLHttpRequest();
request.open('POST', 'save.php');
request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=utf-8');
request.send('hocr=' + encodeURIComponent(hocr));
});
var hocrBaseUrl = '.data/pdf2images/';
var hocrUrl = hocrBaseUrl + 'out.hocr';
Util.get(hocrUrl, function (err, hocr) {
if (err){
alert(err)
return Util.handleError(err);
}
hocrProofreader.setHocr(hocr, hocrBaseUrl);
});
});