annotate client/digitallibrary/navcat_n6.js @ 16:270e1127c65f vendor

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