Mercurial > hg > digilib-old
comparison client/digitallibrary/navcat.js @ 224:b51840f2ff75
new digicat version with only one js file
author | luginbue |
---|---|
date | Fri, 09 Jul 2004 02:15:54 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
223:41de43a00bf8 | 224:b51840f2ff75 |
---|---|
1 /* | |
2 | |
3 Copyright (C) 2003 WTWG, Uni Bern | |
4 | |
5 This program is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU General Public License | |
7 as published by the Free Software Foundation; either version 2 | |
8 of the License, or (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
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 Author: Christian Luginbuehl, 07.04.2004 , Version Alcatraz 0.6 | |
20 | |
21 */ | |
22 | |
23 function identify() { | |
24 return 'Digicat v0.3'; | |
25 } | |
26 | |
27 | |
28 dcParams = new Object(); | |
29 | |
30 function newParameter(name, value, defaultValue, detail) { | |
31 | |
32 if ( !dcParams[name] ) { | |
33 | |
34 dcParams[name] = new Object(); | |
35 | |
36 dcParams[name].value = value; | |
37 dcParams[name].defaultValue = defaultValue; | |
38 dcParams[name].detail = detail; | |
39 | |
40 return dcParams[name]; | |
41 | |
42 } else { | |
43 | |
44 alert("Fatal: An object with name '" + name + "' already exists - cannot recreate!"); | |
45 return false; | |
46 | |
47 } | |
48 } | |
49 | |
50 function getParameter(name) { | |
51 | |
52 if ( dcParams[name] ) { | |
53 return dcParams[name].value; | |
54 } else { | |
55 return false; | |
56 } | |
57 } | |
58 | |
59 | |
60 | |
61 function listParametersAsString() { | |
62 | |
63 var params = new Array(); | |
64 | |
65 for ( param in dcParams ) { | |
66 params.push(param); | |
67 } | |
68 | |
69 return params.join(","); | |
70 | |
71 } | |
72 | |
73 | |
74 function listParameters() { | |
75 | |
76 var params = new Array(); | |
77 | |
78 for ( param in dcParams ) { | |
79 params.push(param); | |
80 } | |
81 | |
82 return params; | |
83 | |
84 } | |
85 | |
86 | |
87 function init() { | |
88 | |
89 var fWidth = document.body ? document.body.clientWidth : innerWidth; | |
90 var fHeight = document.body ? document.body.clientHeight : innerHeight; | |
91 | |
92 if (!dcParams.mo.value) { | |
93 dcParams.mo.value = dcParams.mo.defaultValue; | |
94 } | |
95 | |
96 var cells = dcParams.mo.value.split('x'); | |
97 | |
98 var picWidth = (dcParams.dw.value != 0) ? dcParams.dw.value : Math.floor((fWidth-30)/cells[0])-2*cells[0]-1; | |
99 var picHeight = (dcParams.dh.value != 0) ? dcParams.dh.value : picWidth; | |
100 | |
101 if (cells.length > 1) { | |
102 picHeight = (dcParams.dh.value != 0) ? dcParams.dh.value : Math.floor(((fHeight-30)-12*cells[1])/cells[1])-2*cells[1]-1; | |
103 } else { | |
104 cells[1] = Math.ceil(dcParams.pt.value/cells[0]); | |
105 } | |
106 | |
107 var cellWidth = parseInt(picWidth)+8; | |
108 var cellHeight = parseInt(picHeight)+18; | |
109 | |
110 document.write('<table border="0" cellspacing="1" cellpadding="0">'); | |
111 | |
112 for (var j = 0; j < cells[1]; j++) { | |
113 document.write(' <tr>'); | |
114 for (var i = 0; i < cells[0]; i++) { | |
115 var idx = parseInt(dcParams.pn.value)+i+j*cells[0]; | |
116 var img = baseUrl + "/servlet/Scaler/?fn=" + dcParams.fn.value + "&pn=" + idx; | |
117 img += "&dw=" + picWidth + "&dh=" + picHeight + "&mo=q0"; | |
118 document.write(' <td width="' + cellWidth + '" height="' + cellHeight + '">'); | |
119 if (idx <= dcParams.pt.value) { | |
120 document.write(' <a href="javascript:load(' + idx + ')"><img src="' + img + '" border="0"></a><br>' + idx); | |
121 } else { | |
122 document.write(' '); | |
123 } | |
124 document.write(' </td>'); | |
125 | |
126 } | |
127 document.write(' </tr>'); | |
128 } | |
129 | |
130 document.write('</table>'); | |
131 } | |
132 | |
133 | |
134 function load(i) { | |
135 var link = baseUrl + "/digilib.jsp?fn=" + dcParams.fn.value + "&pn=" + i + "&lv=3"; | |
136 | |
137 if (typeof(top.loadFocusedFrame) == 'function') { | |
138 top.loadFocusedFrame(link); | |
139 } else { | |
140 var win = window.open(link, 'digilib'); | |
141 win.focus(); | |
142 } | |
143 } | |
144 | |
145 | |
146 function Backpage() { | |
147 | |
148 if (att[1] <= 1) { | |
149 att[1] = 1; | |
150 alert("You are already on the first page!"); | |
151 } | |
152 | |
153 att[1] = parseInt(att[1])-parseInt(att[2]*att[3]); | |
154 | |
155 if (att[1] < 1) { | |
156 att[1] = 1; | |
157 } | |
158 loadThumbTable(); | |
159 } | |
160 | |
161 | |
162 | |
163 function Nextpage() { | |
164 | |
165 att[1] = parseInt(att[1])+parseInt(att[2]*att[3]); | |
166 loadThumbTable(); | |
167 } | |
168 | |
169 | |
170 // capturing keypresses for next and previous page | |
171 // ascii-values of n = 110, b = 98 | |
172 function parseKeypress (event) { | |
173 if (event.charCode == 110) { | |
174 Nextpage(); | |
175 } | |
176 if (event.charCode == 98) { | |
177 Backpage(); | |
178 } | |
179 } | |
180 | |
181 | |
182 // initialize browser specific things (keypress caputring) | |
183 function initScripts() { | |
184 for (var f = 0; f < frames.length; f++) { | |
185 frames[f].document.addEventListener('keypress', parseKeypress, true); | |
186 } | |
187 whichFrame.focus(); | |
188 } |