Mercurial > hg > digilib-old
comparison client/digitallibrary/navcat_n4.js @ 6:254fca7a21ce vendor
First import of client module
author | robcast |
---|---|
date | Thu, 17 Jan 2002 15:29:52 +0100 |
parents | |
children | 84a481a388bb 85126da2ae21 |
comparison
equal
deleted
inserted
replaced
5:fa22d26c02d3 | 6:254fca7a21ce |
---|---|
1 /* navcat_n4 -- JS library for digilib (Netscape4 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 | |
74 | |
75 function Backpage() { | |
76 | |
77 if (att[1] <= 1) { | |
78 att[1] = 1; | |
79 alert("You are already on the first page!"); | |
80 } | |
81 | |
82 att[1] = parseInt(att[1])-parseInt(att[2]*att[3]); | |
83 | |
84 if (att[1] < 1) { | |
85 att[1] = 1; | |
86 } | |
87 loadThumbTable(); | |
88 } | |
89 | |
90 | |
91 function Nextpage() { | |
92 | |
93 att[1] = parseInt(att[1])+parseInt(att[2]*att[3]); | |
94 loadThumbTable(); | |
95 } | |
96 | |
97 | |
98 // capturing keypresses for next and previous page | |
99 function parseKeypress(event) { | |
100 var whichCode = (window.Event) ? event.which : event.keyCode; | |
101 if (String.fromCharCode(whichCode) == "n") { | |
102 Nextpage(); | |
103 } | |
104 if (String.fromCharCode(whichCode) == "b") { | |
105 Backpage(); | |
106 } | |
107 } | |
108 | |
109 | |
110 // initialize browser specific things (keypress caputring) | |
111 function initScripts() { | |
112 window.captureEvents(Event.KEYDOWN); | |
113 window.onkeydown = parseKeypress; | |
114 } | |
115 | |
116 | |
117 // fill in the values of the "att"-array | |
118 function initPicture(picURL) { | |
119 att = picURL.split("+"); | |
120 | |
121 if (att[0].lastIndexOf("/") == att[0].length-1) { | |
122 att[0] = att[0].substring(0, att[0].length-1); | |
123 } | |
124 | |
125 if (att.length < 2 || att[1] == "") { | |
126 att[1] = 1; | |
127 } | |
128 if (att.length < 3 || att[2] == "") { | |
129 att[2] = 3; | |
130 } | |
131 | |
132 if (att.length < 4) { | |
133 att[3] = 4; | |
134 } | |
135 } |