annotate client/digitallibrary/oldskin/dclib.js @ 636:7049579a0097 jquery

last and next page works now implemented redisplay function (only tested with fullscreen) parameters that are changed need to be in data.queryParams to get in the url on redisplay
author robcast
date Tue, 18 Jan 2011 21:30:03 +0100
parents a667d2952aab
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
313
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
1 /*
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
2 Copyright (C) 2003-2004 WTWG Uni Bern, MPIWG Berlin
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
3
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
4 This program is free software; you can redistribute it and/or
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
5 modify it under the terms of the GNU General Public License
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
6 as published by the Free Software Foundation; either version 2
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
7 of the License, or (at your option) any later version.
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
8
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
9 This program is distributed in the hope that it will be useful,
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
12 GNU General Public License for more details.
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
13
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
14 You should have received a copy of the GNU General Public License
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
15 along with this program; if not, write to the Free Software
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
17
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
18 Author:
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
19 Christian Luginbuehl, 07.04.2004 , Version Alcatraz 0.6
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
20 Robert Casties 28.10.2004
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
21
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
22 !! requires baselib.js !!
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
23
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
24 */
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
25
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
26 function identify() {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
27 return 'Digicat v0.4';
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
28 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
29
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
30 var cells = null;
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
31
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
32
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
33 function dc_init() {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
34 // put the query parameters (sans "?") in the parameters array
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
35 parseParameters(location.search.slice(1));
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
36 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
37
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
38 function display(detail) {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
39 // redisplay the page
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
40 if (! detail) {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
41 detail = 9;
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
42 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
43 var queryString = getAllParameters(detail);
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
44 location.href = location.protocol + "//" + location.host + location.pathname + "?" + queryString;
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
45 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
46
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
47 function dc_render(doc) {
319
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
48 // creates the HTML for the image table
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
49 var wsize = getWinSize();
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
50 var fWidth = wsize.width;
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
51 var fHeight = wsize.height;
313
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
52
319
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
53 var mx = getParameter("mx");
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
54 cells = mx.split('x');
313
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
55
319
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
56 var dw = getParameter("dw");
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
57 var dh = getParameter("dh");
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
58 var pt = getParameter("pt");
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
59 var pn = parseInt(getParameter("pn"));
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
60 var fn = getParameter("fn");
591
a667d2952aab small fix to dirInfo-xml.jsp and old digicat.jsp
robcast
parents: 319
diff changeset
61 var par_mo = (hasParameter("mo")) ? "&mo="+getParameter("mo") : "";
313
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
62
319
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
63 var picWidth = (dw != 0) ? dw : Math.floor((fWidth-30)/cells[0])-2*cells[0]-1;
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
64 var picHeight = (dh != 0) ? dh : picWidth;
313
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
65
319
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
66 if (cells.length > 1) {
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
67 picHeight = (dh != 0) ? dh : Math.floor(((fHeight-30)-12*cells[1])/cells[1])-2*cells[1]-1;
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
68 } else {
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
69 cells[1] = Math.ceil(pt/cells[0]);
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
70 }
313
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
71
319
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
72 var cellWidth = parseInt(picWidth)+8;
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
73 var cellHeight = parseInt(picHeight)+18;
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
74
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
75 doc.writeln('<table width="100%" height="100%" border="0" cellspacing="1" cellpadding="0">');
313
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
76
319
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
77 for (var j = 0; j < cells[1]; j++) {
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
78 doc.writeln('<tr>');
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
79 for (var i = 0; i < cells[0]; i++) {
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
80 var idx = pn+i+j*cells[0];
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
81 var img = baseUrl + "/servlet/Scaler?fn=" + fn + "&pn=" + idx;
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
82 img += "&dw=" + picWidth + "&dh=" + picHeight + par_mo;
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
83 doc.write('<td width="'+cellWidth+'" height="'+cellHeight+'">');
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
84 if (idx <= pt) {
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
85 doc.write('<a href="'+dl_link(idx)+'" target="_blank"><img src="'+img+'" border="0"></a><div class="number">'+idx+'</div>');
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
86 } else {
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
87 doc.write('<div class="nonumber">'+idx+'</div>');
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
88 }
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
89 doc.writeln('</td>');
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
90 }
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
91 doc.writeln(' </tr>');
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
92 }
23866acd6509 fixed bug with detecting window size in Safari 1.2
robcast
parents: 313
diff changeset
93 doc.writeln('</table>');
313
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
94 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
95
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
96
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
97 function dl_link(i) {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
98 var link = baseUrl+"/digilib.jsp?fn="+getParameter("fn")+"&pn="+i+"&mo="+getParameter("mo");
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
99 return link;
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
100 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
101
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
102
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
103 function Backpage() {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
104 var pn = parseInt(getParameter("pn"));
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
105 if (pn <= 1) {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
106 pn = 1;
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
107 alert("You are already on the first page!");
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
108 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
109
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
110 pn = pn - parseInt(cells[0]*cells[1]);
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
111
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
112 if (pn < 1) {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
113 pn = 1;
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
114 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
115 setParameter("pn", pn);
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
116 display();
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
117 }
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
118
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
119 function Nextpage() {
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
120 var pn = parseInt(getParameter("pn"));
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
121 pn = pn + parseInt(cells[0]*cells[1]);
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
122 setParameter("pn", pn);
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
123 display();
24dbc008be14 big autumn cleaning :-)
robcast
parents:
diff changeset
124 }