Mercurial > hg > digilib-old
comparison client/digitallibrary/modules/pagesTotal.js @ 134:1a0496201c75
unified scripts, nice xul sidebar, bugfixes
author | luginbue |
---|---|
date | Tue, 08 Jul 2003 03:00:57 +0200 |
parents | 489f61d9feac |
children |
comparison
equal
deleted
inserted
replaced
133:28f96364040f | 134:1a0496201c75 |
---|---|
1 /* | 1 /* |
2 | |
2 Copyright (C) 2003 WTWG, Uni Bern | 3 Copyright (C) 2003 WTWG, Uni Bern |
3 | 4 |
4 This program is free software; you can redistribute it and/or | 5 This program is free software; you can redistribute it and/or |
5 modify it under the terms of the GNU General Public License | 6 modify it under the terms of the GNU General Public License |
6 as published by the Free Software Foundation; either version 2 | 7 as published by the Free Software Foundation; either version 2 |
13 | 14 |
14 You should have received a copy of the GNU General Public License | 15 You should have received a copy of the GNU General Public License |
15 along with this program; if not, write to the Free Software | 16 along with this program; if not, write to the Free Software |
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
17 | 18 |
18 Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.3 | 19 Author: Christian Luginbuehl, 22.05.2003 , Version Alcatraz 0.4 |
20 | |
19 */ | 21 */ |
20 /**************************************************************************** | |
21 * - sample module for digilib * | |
22 * * | |
23 * christian luginbuehl (luginbuehl@student.unibe.ch) * | |
24 ****************************************************************************/ | |
25 | 22 |
26 // overriding (some kind of inheriting) init in navigation13_XX.js | 23 /************************************************************************* |
27 function init_pagesTotal(pu, pn, ws, mo, mk, wx, wy, ww, wh, pt) { | 24 * pagesTotal.js : digilib-module * |
25 * * | |
26 * desc: displaying the total number of pages in a designated frame, * | |
27 * when calling pagesTotal(). also overrides nextPage() and * | |
28 * page() functions, by adding last-page tests. * | |
29 * * | |
30 *************************************************************************/ | |
28 | 31 |
29 // debug window to check the parameters passed | |
30 //alert ("DEBUG message (parameters in init pagesTotal.js):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh + "\npt = " + pt); | |
31 | 32 |
32 // calling original init | 33 /** |
33 init(pu, pn, ws, mo, mk, wx, wy, ww, wh); | 34 * shows 'page XX of YY' in a designated frame |
35 */ | |
36 function showTotalPages() { | |
34 | 37 |
35 att.pt = parseInt(pt); | 38 var pf = parent.pageFrame; |
36 | |
37 pagesTotal(); | |
38 | 39 |
39 focus(); | 40 if ( pf ) { |
41 pf.document.open(); | |
42 pf.document.write('<html><head></head>'); | |
43 pf.document.write('<body bgcolor="#CCCCCC" topmargin="5" marginheight="5">'); | |
44 pf.document.write('<p style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; color: #CC3333; font-size: 11px">'); | |
45 pf.document.write(dlParams.pn.value + '<b> of </b>' + dlParams.pt.value + '</p></body></html>'); | |
46 pf.document.close(); | |
47 } | |
48 | |
40 } | 49 } |
41 | 50 |
42 | 51 |
43 /** | 52 /** |
44 * shows page XX of YY in a dedicated frame | 53 * extending init from novaigation.js |
45 * | |
46 * ATTENTION: some stuff is still to do, because of some incompatibilities between servlet and client | |
47 * i should be able to read the total number of pages in dlImage.jsp | |
48 */ | 54 */ |
49 function pagesTotal() { | 55 function init_pagesTotal() { |
50 | 56 |
51 if (parent.pageFrame) { | 57 init(); |
52 parent.pageFrame.document.open(); | 58 |
53 parent.pageFrame.document.write('<html><head></head><body bgcolor="#CCCCCC" topmargin="5" marginheight="5">'); | 59 showTotalPages(); |
54 parent.pageFrame.document.write('<p style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; color: #CC3333; font-size: 11px">'); | 60 |
55 parent.pageFrame.document.write(att.pn + '<b> of </b>' + att.pt + '</p></body></html>'); | |
56 parent.pageFrame.document.close(); | |
57 } | |
58 } | 61 } |
59 | 62 |
60 | 63 |
61 /** | 64 /** |
62 * overriding nextPage in navigation | 65 * overriding 'page' in navigation.js |
63 */ | 66 */ |
64 function nextPage(keepArea) { | 67 function page(page, details) { |
65 | 68 |
66 att.pn = parseInt(att.pn) + 1; | 69 if ( details == null ) { |
70 details = 1; | |
71 } | |
72 | |
73 if ( page && page.indexOf('-') == 0 ) { | |
74 if ( dlParams.pn.value > 1 ) { | |
75 page = Math.max(parseInt(dlParams.pn.value) - parseInt(page.slice(1)), 1); | |
76 dlParams.pn.value = page; | |
77 display(details); | |
78 } else { | |
79 alert("You are already on the first page!"); | |
80 } | |
67 | 81 |
68 if (att.pn <= att.pt || isNaN(att.pt)) { | 82 } else if ( page && page.indexOf('+') == 0 ) { |
69 loadPicture(0, keepArea); | 83 if ( parseInt(dlParams.pn.value) < parseInt(dlParams.pt.value) ) { |
84 page = Math.min(parseInt(dlParams.pn.value) + parseInt(page.slice(1)), dlParams.pt.value); | |
85 dlParams.pn.value = page; | |
86 display(details); | |
70 } else { | 87 } else { |
71 att.pn = parseInt(att.pn) - 1; | 88 alert("You are already on the last page!"); |
72 alert("You are already on the last page!"); | |
73 } | 89 } |
90 } else if ( page && page == parseInt(page) ) { | |
91 if ( (page > 0) && (page <= parseInt(dlParams.pt.value)) ) { | |
92 dlParams.pn.value = parseInt(page); | |
93 display(details); | |
94 } else { | |
95 alert ("Illegal page number (1 - " + dlParams.pt.value + ")!"); | |
96 } | |
97 } | |
98 | |
74 } | 99 } |
75 | |
76 | |
77 /** | |
78 * overriding 'page' in navigation | |
79 */ | |
80 function page(keepArea) { | |
81 | |
82 do { | |
83 var page = prompt("Goto Page (1 - " + att.pt + "):", 1); | |
84 | |
85 } while ((page != null) && ((isNaN(page)) || (page < 1) || (page > att.pt))); | |
86 | |
87 if ((page != null) && (page != att.pn)) { | |
88 att.pn = page; | |
89 loadPicture(0, keepArea); | |
90 } | |
91 } | |
92 | |
93 | |
94 /** | |
95 * overriding 'loadPicture' in navigation | |
96 */ | |
97 function loadPicture(detailGrade, keepArea) { | |
98 | |
99 // the different detailGrades: | |
100 // 0 -> back, next, page | |
101 // 1 -> zoomout | |
102 // 2 -> zoomarea, zoompoint, moveto, scaledef | |
103 | |
104 var newQuery = "fn=" + att.fn + "&pn=" + att.pn + "&ws=" + att.ws + "&mo=" + att.mo; | |
105 | |
106 if (detailGrade == 0) { | |
107 att.mk = "0/0"; | |
108 } | |
109 | |
110 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { | |
111 att.wx = 0; | |
112 att.wy = 0; | |
113 att.ww = 1; | |
114 att.wh = 1; | |
115 } | |
116 | |
117 newQuery += "&mk=" + att.mk + "&wx=" + att.wx + "&wy=" + att.wy + "&ww=" + att.ww + "&wh=" + att.wh; | |
118 | |
119 if (navigator.appName.toLowerCase() == "netscape") { // mozilla-browsers (netscape 4.xx, netscape 6.xx, etc.) | |
120 newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); | |
121 } else { // ie, opera | |
122 newQuery += "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30); | |
123 } | |
124 | |
125 newQuery += "&pt=" + att.pt; | |
126 newQuery += "&lv=1"; | |
127 | |
128 // debug window - checking the parameters passed to the next image | |
129 //alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); | |
130 | |
131 location.href = location.protocol + "//" + location.host + location.pathname + "?" + newQuery; | |
132 } |