summaryrefslogtreecommitdiff
path: root/support/pdbf-toolkit/data/imagesJS.js
blob: 3f7a12af3e0a3a5f0ded2b1329241d8e18b7f6d3 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//redirect alerts to console
function alert(e) {
	throw "" + e;
}

// Load pdbf-dim.json
var json;
json = JSON.parse(UTF8ArrToStr(base64DecToArr(dim_base64)));
tmpw = json.width / 655 / 60;
tmph = json.height / 655 / 60;

function replaceAll(str, s, r) {
	return str.split(s).join(r);
}

// Load the database
var tmp = UTF8ArrToStr(base64DecToArr(db_base64));
var tmp2 = dbjson_base64;

if (tmp2 != "") {
	if (typeof notCompressed != 'undefined') {
		alasql.databases = JSON.parse(tmp2);
	} else {
		alasql.databases = JSON.parse(LZString.decompressFromBase64(tmp2));
	}
}

if (tmp != "") {
	alasql(tmp);
}

// Load pdbf-config.json
json = JSON.parse(UTF8ArrToStr(base64DecToArr(json_base64)));
var width = (json.type.I.x2 - json.type.I.x1);
var height = (json.type.I.y1 - json.type.I.y2);
outw = tmpw * width;
outh = tmph * height;

$(document.body).css('width', outw);
$(document.body).css('height', outh);

var pageOverlays = [];
parse(json);

function parse(json) {
	page = 0;
	pageOverlay = pageOverlays[page];
	if (typeof pageOverlay == 'undefined') {
		pageOverlay = [];
		pageOverlays[page] = pageOverlay;
	}
	pageOverlay[pageOverlay.length] = json;
}

var zoomFactor = 1.30 * (json.type.I.fontsize/12.0) * json.type.I.quality;
var rawZoomFactor = 1.30 * (json.type.I.fontsize/12.0) * json.type.I.quality;

function overlay() {
	var subContainer = document.getElementById("subContainer");
	subContainer.innerHTML = '';
	var pageNr = 0;
	for (var i = 0; i < pageOverlays[pageNr].length; ++i) {
		var json = pageOverlays[pageNr][i];
		PDFViewerApplication.page = json.type.I.page;
		display(json, subContainer, true);
	}
}