Mercurial > hg > digilib
comparison client/digitallibrary/modules/imago.js @ 102:26e6b2715a15
Initial revision
author | engler |
---|---|
date | Tue, 13 May 2003 21:02:16 +0200 |
parents | |
children | 7dc74e541d7c |
comparison
equal
deleted
inserted
replaced
100:4986e0e80625 | 102:26e6b2715a15 |
---|---|
1 /* | |
2 Copyright (C) 2003 WTWG, Uni Bern | |
3 | |
4 This program is free software; you can redistribute it and/or | |
5 modify it under the terms of the GNU General Public License | |
6 as published by the Free Software Foundation; either version 2 | |
7 of the License, or (at your option) any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 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 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
17 | |
18 Author: Christian Luginbuehl, 01.05.2003 , Version Alcatraz 0.3 | |
19 */ | |
20 /**************************************************************************** | |
21 * - imago module for digilib * | |
22 * * | |
23 * adds brightness and color manipulation to digilib * | |
24 * * | |
25 * christian luginbuehl (luginbuehl@student.unibe.ch) * | |
26 ****************************************************************************/ | |
27 | |
28 // overriding (some kind of inheriting) init in navigation_XX.js | |
29 function init_imago(pu, pn, ws, mo, mk, wx, wy, ww, wh, pt, brgt, cont, rot, rgba, rgbm) { | |
30 | |
31 // debug window to check the parameters passed | |
32 //alert ("DEBUG message (parameters in init imago.js):\n\npu = " + pu + "\npn = " + pn + "\nws = " + ws + "\nmo = " + mo + "\nmk = " + mk + "\nwx = " + wx + "\nwy = " + wy + "\nww = " + ww + "\nwh = " + wh + "\npt = " + pt + "\nbrgt = " + brgt + "\ncont = " + cont + "\nrot = " + rot + "\nrgba = " + rgba + "\nrgbm = " + rgbm); | |
33 | |
34 // calling original init | |
35 init_pagesTotal(pu, pn, ws, mo, mk, wx, wy, ww, wh, pt); | |
36 | |
37 att.brgt = parseInt(brgt); | |
38 att.cont = parseFloat(cont); | |
39 att.rot = parseFloat(rot); | |
40 att.rgba = rgba; | |
41 att.rgbm = rgbm; | |
42 | |
43 focus(); | |
44 } | |
45 | |
46 | |
47 /** | |
48 * overriding 'loadPicture' in navigation | |
49 */ | |
50 function loadPicture(detailGrade, keepArea) { | |
51 | |
52 // the different detailGrades: | |
53 // 0 -> back, next, page | |
54 // 1 -> zoomout | |
55 // 2 -> zoomarea, zoompoint, moveto, scaledef | |
56 | |
57 var newQuery = "fn=" + att.fn + "&pn=" + att.pn + "&ws=" + att.ws + "&mo=" + att.mo; | |
58 | |
59 if (detailGrade == 0) { | |
60 att.mk = "0/0"; | |
61 att.brgt = 0; | |
62 att.cont = 0; | |
63 } | |
64 | |
65 if ((detailGrade == 1) || (detailGrade == 0 && !keepArea)) { | |
66 att.wx = 0; | |
67 att.wy = 0; | |
68 att.ww = 1; | |
69 att.wh = 1; | |
70 } | |
71 | |
72 newQuery += "&mk=" + att.mk + "&wx=" + att.wx + "&wy=" + att.wy + "&ww=" + att.ww + "&wh=" + att.wh; | |
73 | |
74 if (navigator.appName.toLowerCase() == "netscape") { // mozilla-browsers (netscape 4.xx, netscape 6.xx, etc.) | |
75 newQuery += "&dw=" + (innerWidth-30) + "&dh=" + (innerHeight-30); | |
76 } else { // ie, opera | |
77 newQuery += "&dw=" + (document.body.clientWidth-30) + "&dh=" + (document.body.clientHeight-30); | |
78 } | |
79 | |
80 newQuery += "&pt=" + att.pt; | |
81 | |
82 newQuery += "&brgt=" + att.brgt; | |
83 newQuery += "&cont=" + att.cont; | |
84 newQuery += "&rot=" + att.rot; | |
85 newQuery += "&rgba=" + att.rgba; | |
86 newQuery += "&rgbm=" + att.rgbm; | |
87 | |
88 newQuery += "&lv=1"; | |
89 | |
90 // debug window - checking the parameters passed to the next image | |
91 //alert ("DEBUG MESSAGE (query-string in loadPicture):\n\n" + newQuery); | |
92 //alert(location.host + ":" + location.port + location.pathname); | |
93 location.href = location.protocol + "//" + location.host + location.pathname + "?" + newQuery; | |
94 } | |
95 | |
96 | |
97 /** | |
98 * brightness (value of brightness between -255 - +255) | |
99 */ | |
100 function brightness(value) { | |
101 | |
102 if ((value < -255) || (value > 255)) { | |
103 | |
104 alert ("Illegal brightness value (-255 to +255)"); | |
105 | |
106 } else { | |
107 | |
108 att.brgt = value; | |
109 | |
110 loadPicture(2); | |
111 } | |
112 | |
113 } | |
114 | |
115 /** | |
116 * contrast (value of contrast - range?) | |
117 */ | |
118 function contrast(value) { | |
119 | |
120 att.cont = parseFloat(value); | |
121 | |
122 loadPicture(2); | |
123 | |
124 } | |
125 | |
126 /** | |
127 * rotation (value from 0 to 360 degrees) | |
128 */ | |
129 function rotation(value) { | |
130 | |
131 value = parseFloat(value) % 360; | |
132 | |
133 if (value < 0) { | |
134 value += 360; | |
135 } | |
136 | |
137 att.rot = value; | |
138 | |
139 loadPicture(2); | |
140 | |
141 } | |
142 | |
143 /** | |
144 * rgb add (r/g/b, each value from -255 to +255) | |
145 */ | |
146 function rgba(value) { | |
147 | |
148 values = value.split("/"); | |
149 | |
150 if (values.length != 3) { | |
151 alert ("Illegal parameter format (r/g/b)"); | |
152 } else if ((values[0] < -255) || (values[0] > 255)) { | |
153 alert ("Illegal red additioner (-255 to 255)"); | |
154 } else if ((values[1] < -255) || (values[1] > 255)) { | |
155 alert ("Illegal green additioner (-255 to 255)"); | |
156 } else if ((values[2] < -255) || (values[2] > 255)) { | |
157 alert ("Illegal blue additioner (-255 to 255)"); | |
158 } else { | |
159 | |
160 att.rgba = value; | |
161 loadPicture(2); | |
162 | |
163 } | |
164 } | |
165 | |
166 /** | |
167 * rgb multiply (r/g/b, each value from ??? ) | |
168 */ | |
169 function rgbm(value) { | |
170 | |
171 values = value.split("/"); | |
172 | |
173 if (values.length != 3) { | |
174 alert ("Illegal parameter format (r/g/b)"); | |
175 } else { | |
176 | |
177 att.rgbm = value; | |
178 loadPicture(2); | |
179 | |
180 } | |
181 } |