6
|
1 // these two global variables have to be initialised before the frist use of the functions below
|
|
2 // to fill in the attributes you can use the function initPicture provided below
|
|
3 // - array with all attributes
|
|
4 var att = new Array();
|
|
5
|
|
6 // - variable to store the path to the frame, in which the pictures should be created
|
|
7 var whichFrame = parent.mainFrame;
|
|
8
|
|
9 // give a name to the window containing digicat - this way one can test if there is already a
|
|
10 // digicat-window open and replace the contents of it (ex. digilib)
|
|
11 window.name = "digicat";
|
|
12
|
|
13 function loadThumbTable() {
|
|
14 tableWidth = whichFrame.innerWidth-30;
|
|
15 tableHeight = whichFrame.innerHeight-30;
|
|
16
|
|
17 cellWidth = Math.floor(tableWidth/att[3])-6;
|
|
18 cellHeight = Math.floor(tableHeight/att[2])-4;
|
|
19
|
|
20 // alert(tableWidth + " " + tableHeight + "\n" + cellWidth + " " +cellHeight);
|
|
21
|
|
22 whichFrame.document.open();
|
|
23 whichFrame.document.write('<html><head>');
|
|
24 whichFrame.document.write('<style type="text/css">.myFont {font-family: sans-serif, Arial; font-size: 11px; color: #FFFFFF}</style>');
|
|
25 whichFrame.document.write('<script language="Javascript">');
|
|
26 whichFrame.document.write('function loadDigilib(idx) {');
|
107
|
27 whichFrame.document.write('linkRef = "' + parent.baseUrl + '/digilib.jsp?' + parent.att[0] + '+" + idx;');
|
6
|
28 whichFrame.document.write('win = window.open(linkRef, "digilib");');
|
|
29 whichFrame.document.write('win.focus();');
|
|
30 whichFrame.document.write('}');
|
|
31 whichFrame.document.write('</script>');
|
|
32
|
|
33
|
|
34 whichFrame.document.write('</head><body bgcolor="#666666">');
|
|
35 whichFrame.document.write('<table border="1" width="' + tableWidth + '" height="' + tableHeight + '">');
|
|
36 for (i = 0; i < att[2]; i++) {
|
|
37 whichFrame.document.write('<tr>');
|
|
38 for (j = 0; j < att[3]; j++) {
|
|
39 indexNr = parseInt(att[1])+i*parseInt(att[3])+j;
|
107
|
40 thumb = parent.baseUrl + "/servlet/Scaler/";
|
6
|
41 thumb += att[0] + "?" + "pn=" + indexNr + "&ws=1.0&mo=fit&dw=" + cellWidth + "&dh=" + (cellHeight-25);
|
|
42 whichFrame.document.write('<td align="center" valign="middle" width="' + cellWidth + '" height="' + cellHeight + '" class="myFont">');
|
|
43 whichFrame.document.write('<a href="javascript:loadDigilib(' + indexNr + ')">');
|
|
44 whichFrame.document.write('<img src="' + thumb + '" border="0">');
|
|
45 whichFrame.document.write('</a><br>');
|
|
46 whichFrame.document.write(indexNr + '</td>');
|
|
47 }
|
|
48 whichFrame.document.write('</tr>');
|
|
49 }
|
|
50 whichFrame.document.write('</table></body></html>');
|
|
51 whichFrame.document.close();
|
|
52 }
|
|
53
|
|
54
|
|
55 function Backpage() {
|
|
56
|
|
57 if (att[1] <= 1) {
|
|
58 att[1] = 1;
|
|
59 alert("You are already on the first page!");
|
|
60 }
|
|
61
|
|
62 att[1] = parseInt(att[1])-parseInt(att[2]*att[3]);
|
|
63
|
|
64 if (att[1] < 1) {
|
|
65 att[1] = 1;
|
|
66 }
|
|
67 loadThumbTable();
|
|
68 }
|
|
69
|
|
70
|
|
71 function Nextpage() {
|
|
72
|
|
73 att[1] = parseInt(att[1])+parseInt(att[2]*att[3]);
|
|
74 loadThumbTable();
|
|
75 }
|
|
76
|
|
77
|
|
78 // capturing keypresses for next and previous page
|
|
79 function parseKeypress(event) {
|
|
80 var whichCode = (window.Event) ? event.which : event.keyCode;
|
|
81 if (String.fromCharCode(whichCode) == "n") {
|
|
82 Nextpage();
|
|
83 }
|
|
84 if (String.fromCharCode(whichCode) == "b") {
|
|
85 Backpage();
|
|
86 }
|
|
87 }
|
|
88
|
|
89
|
|
90 // initialize browser specific things (keypress caputring)
|
|
91 function initScripts() {
|
|
92 window.captureEvents(Event.KEYDOWN);
|
|
93 window.onkeydown = parseKeypress;
|
|
94 }
|
|
95
|
|
96
|
|
97 // fill in the values of the "att"-array
|
|
98 function initPicture(picURL) {
|
|
99 att = picURL.split("+");
|
|
100
|
|
101 if (att[0].lastIndexOf("/") == att[0].length-1) {
|
|
102 att[0] = att[0].substring(0, att[0].length-1);
|
|
103 }
|
|
104
|
|
105 if (att.length < 2 || att[1] == "") {
|
|
106 att[1] = 1;
|
|
107 }
|
|
108 if (att.length < 3 || att[2] == "") {
|
|
109 att[2] = 3;
|
|
110 }
|
|
111
|
|
112 if (att.length < 4) {
|
|
113 att[3] = 4;
|
|
114 }
|
|
115 }
|