annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
1 /*
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
2
110
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
3 Copyright (C) 2003 WTWG, Uni Bern
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
4
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
5 This program is free software; you can redistribute it and/or
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
6 modify it under the terms of the GNU General Public License
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
7 as published by the Free Software Foundation; either version 2
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
8 of the License, or (at your option) any later version.
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
9
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
10 This program is distributed in the hope that it will be useful,
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
13 GNU General Public License for more details.
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
14
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
15 You should have received a copy of the GNU General Public License
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
16 along with this program; if not, write to the Free Software
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
18
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
19 Author: Christian Luginbuehl, 22.05.2003 , Version Alcatraz 0.4
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
20
110
489f61d9feac XUL Buttons in chrome
engler
parents: 48
diff changeset
21 */
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
22
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
23 /*************************************************************************
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
24 * pagesTotal.js : digilib-module *
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
25 * *
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
26 * desc: displaying the total number of pages in a designated frame, *
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
27 * when calling pagesTotal(). also overrides nextPage() and *
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
28 * page() functions, by adding last-page tests. *
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
29 * *
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
30 *************************************************************************/
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
32
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
33 /**
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
34 * shows 'page XX of YY' in a designated frame
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
35 */
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
36 function showTotalPages() {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
37
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
38 var pf = parent.pageFrame;
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
39
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
40 if ( pf ) {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
41 pf.document.open();
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
42 pf.document.write('<html><head></head>');
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
43 pf.document.write('<body bgcolor="#CCCCCC" topmargin="5" marginheight="5">');
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
44 pf.document.write('<p style="font-family: Verdana, Arial, Helvetica, sans-serif; text-align: center; color: #CC3333; font-size: 11px">');
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
45 pf.document.write(dlParams.pn.value + '<b> of </b>' + dlParams.pt.value + '</p></body></html>');
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
46 pf.document.close();
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
47 }
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
48
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
49 }
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
50
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
51
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
52 /**
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
53 * extending init from novaigation.js
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
54 */
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
55 function init_pagesTotal() {
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
56
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
57 init();
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
58
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
59 showTotalPages();
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
60
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
61 }
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
62
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
63
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
64 /**
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
65 * overriding 'page' in navigation.js
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
66 */
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
67 function page(page, details) {
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
68
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
69 if ( details == null ) {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
70 details = 1;
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
71 }
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
72
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
73 if ( page && page.indexOf('-') == 0 ) {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
74 if ( dlParams.pn.value > 1 ) {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
75 page = Math.max(parseInt(dlParams.pn.value) - parseInt(page.slice(1)), 1);
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
76 dlParams.pn.value = page;
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
77 display(details);
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
78 } else {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
79 alert("You are already on the first page!");
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
80 }
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
81
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
82 } else if ( page && page.indexOf('+') == 0 ) {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
83 if ( parseInt(dlParams.pn.value) < parseInt(dlParams.pt.value) ) {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
84 page = Math.min(parseInt(dlParams.pn.value) + parseInt(page.slice(1)), dlParams.pt.value);
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
85 dlParams.pn.value = page;
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
86 display(details);
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
87 } else {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
88 alert("You are already on the last page!");
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
89 }
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
90 } else if ( page && page == parseInt(page) ) {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
91 if ( (page > 0) && (page <= parseInt(dlParams.pt.value)) ) {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
92 dlParams.pn.value = parseInt(page);
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
93 display(details);
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
94 } else {
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
95 alert ("Illegal page number (1 - " + dlParams.pt.value + ")!");
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
96 }
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
97 }
31
904f2b2f0cf5 cleaning up a bit - more follows
luginbue
parents:
diff changeset
98
134
1a0496201c75 unified scripts, nice xul sidebar, bugfixes
luginbue
parents: 110
diff changeset
99 }