comparison client/digitallibrary/navcat_n6.js @ 20:d407cb901df4

Initial revision
author robcast
date Thu, 17 Jan 2002 15:29:55 +0100
parents
children 84a481a388bb 85126da2ae21
comparison
equal deleted inserted replaced
1:0ff3ede32060 20:d407cb901df4
1 /* navcat_n6 -- JS library for digilib (Mozilla version)
2
3 Digital Image Library servlet components
4
5 Copyright (C) 2001, 2002 Christian Luginbuehl (luginbuehl@student.unibe.ch)
6
7 This program is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 2 of the License, or (at your
10 option) any later version.
11
12 Please read license.txt for the full details. A copy of the GPL
13 may be found at http://www.gnu.org/copyleft/lgpl.html
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
19 */
20
21 // these two global variables have to be initialised before the frist use of the functions below
22 // to fill in the attributes you can use the function initPicture provided below
23 // - array with all attributes
24 var att = new Array();
25
26 // - variable to store the path to the frame, in which the pictures should be created
27 var whichFrame = parent.mainFrame;
28
29 // give a name to the window containing digicat - this way one can test if there is already a
30 // digicat-window open and replace the contents of it (ex. digilib)
31 window.name = "digicat";
32
33 function loadThumbTable() {
34 tableWidth = whichFrame.innerWidth-30;
35 tableHeight = whichFrame.innerHeight-30;
36
37 cellWidth = Math.floor(tableWidth/att[3])-6;
38 cellHeight = Math.floor(tableHeight/att[2])-4;
39
40 // alert(tableWidth + " " + tableHeight + "\n" + cellWidth + " " +cellHeight);
41
42 whichFrame.document.open();
43 whichFrame.document.write('<html><head>');
44 whichFrame.document.write('<style type="text/css">.myFont {font-family: sans-serif, Arial; font-size: 11px; color: #FFFFFF}</style>');
45 whichFrame.document.write('<script language="Javascript">');
46 whichFrame.document.write('function loadDigilib(idx) {');
47 whichFrame.document.write('linkRef = "http://' + location.host + '/docuserver/digitallibrary/digilib.html?' + parent.att[0] + '+" + idx;');
48 whichFrame.document.write('win = window.open(linkRef, "digilib");');
49 whichFrame.document.write('win.focus();');
50 whichFrame.document.write('}');
51 whichFrame.document.write('</script>');
52
53
54 whichFrame.document.write('</head><body bgcolor="#666666">');
55 whichFrame.document.write('<table border="1" width="' + tableWidth + '" height="' + tableHeight + '">');
56 for (i = 0; i < att[2]; i++) {
57 whichFrame.document.write('<tr>');
58 for (j = 0; j < att[3]; j++) {
59 indexNr = parseInt(att[1])+i*parseInt(att[3])+j;
60 thumb = "http://" + location.host + "/docuserver/digitallibrary/servlet/Scaler/"
61 thumb += att[0] + "?" + "pn=" + indexNr + "&ws=1.0&mo=fit&dw=" + cellWidth + "&dh=" + (cellHeight-25);
62 whichFrame.document.write('<td align="center" valign="middle" width="' + cellWidth + '" height="' + cellHeight + '" class="myFont">');
63 whichFrame.document.write('<a href="javascript:loadDigilib(' + indexNr + ')">');
64 whichFrame.document.write('<img src="' + thumb + '" border="0">');
65 whichFrame.document.write('</a><br>');
66 whichFrame.document.write(indexNr + '</td>');
67 }
68 whichFrame.document.write('</tr>');
69 }
70 whichFrame.document.write('</table></body></html>');
71 whichFrame.document.close();
72
73 initScripts();
74 }
75
76
77 function Backpage() {
78
79 if (att[1] <= 1) {
80 att[1] = 1;
81 alert("You are already on the first page!");
82 }
83
84 att[1] = parseInt(att[1])-parseInt(att[2]*att[3]);
85
86 if (att[1] < 1) {
87 att[1] = 1;
88 }
89 loadThumbTable();
90 }
91
92
93
94 function Nextpage() {
95
96 att[1] = parseInt(att[1])+parseInt(att[2]*att[3]);
97 loadThumbTable();
98 }
99
100
101 // capturing keypresses for next and previous page
102 // ascii-values of n = 110, b = 98
103 function parseKeypress (event) {
104 if (event.charCode == 110) {
105 Nextpage();
106 }
107 if (event.charCode == 98) {
108 Backpage();
109 }
110 }
111
112
113 // initialize browser specific things (keypress caputring)
114 function initScripts() {
115 for (var f = 0; f < frames.length; f++) {
116 frames[f].document.addEventListener('keypress', parseKeypress, true);
117 }
118 whichFrame.focus();
119 }
120
121
122 // fill in the values of the "att"-array
123 function initPicture(picURL) {
124 att = picURL.split("+");
125
126 if (att[0].lastIndexOf("/") == att[0].length-1) {
127 att[0] = att[0].substring(0, att[0].length-1);
128 }
129
130 if (att.length < 2 || att[1] == "") {
131 att[1] = 1;
132 }
133
134 if (att.length < 3 || att[2] == "") {
135 att[2] = 3;
136 }
137
138 if (att.length < 4) {
139 att[3] = 4;
140 }
141 }