1 /*=====================================================================*\
2 || ################################################################### ||
3 || # RGB Converter Widget [#]version[#]
4 || # --------------------------------------------------------------- # ||
5 || # Copyright ©2002-[#]year[#] by Iris Studios, Inc. All Rights Reserved. # ||
6 || # This file may not be reproduced in any way without permission. # ||
7 || # --------------------------------------------------------------- # ||
8 || # User License Agreement at http://www.iris-studios.com/license/ # ||
9 || ################################################################### ||
10 \*=====================================================================*/
19 var lastinput
= 'rgb';
21 // ###################################################################
22 // watches the three RGB fields to make sure they don't go over the limites
23 function rgbwatcher(colour
)
25 field
= document
.getElementById(colour
+ "inputf");
27 // sanitize the number
28 var newval
= field
.value
.replace(/[^0-9\-\.]*/g
, "");
29 newval
= Math
.floor(newval
);
31 // make sure we don't go over 255
41 // update the text field
45 fields
[colour] = newval
;
55 // ###################################################################
56 // update the hex value
59 var hexstr
= dec2hex(fields
['red']) + dec2hex(fields
['green']) + dec2hex(fields
['blue']);
60 fields
['hex'] = hexstr
;
63 // ###################################################################
64 // update the colour swatch
65 function update_swatch()
67 document
.getElementById("swatch").style
.backgroundColor
= "#" + fields
['hex'];
70 // ###################################################################
71 // convert a decimal to a hexidecimal
74 var hexstr
= "0123456789ABCDEF";
76 var high
= (dec
- low
) / 16;
77 hex
= "" + hexstr
.charAt(high
) + hexstr
.charAt(low
);
79 return hex
.toString();
82 // ###################################################################
83 // converts a hexidecimal to a decimal
86 return parseInt(hex
, 16);
89 // ###################################################################
90 // ###################################################################
91 // ###################################################################
97 var front
= document
.getElementById("front");
98 var back
= document
.getElementById("back");
102 widget
.prepareForTransition("ToBack");
105 front
.style
.display
= "none";
106 back
.style
.display
= "block";
110 setTimeout("widget.performTransition();", 0);
113 document
.getElementById("fliprollie").style
.display
= "none";
118 var front
= document
.getElementById("front");
119 var back
= document
.getElementById("back");
123 widget
.prepareForTransition("ToFront");
126 back
.style
.display
= "none";
127 front
.style
.display
= "block";
131 setTimeout("widget.performTransition();", 0);
135 var flipShown
= false;
147 function mousemove(event
)
151 if (animation
.timer
!= null)
153 clearInterval(animation
.timer
);
154 animation
.timer
= null;
157 var starttime
= (new Date
).getTime() - 13;
159 animation
.duration
= 500;
160 animation
.starttime
= starttime
;
161 animation
.firstElement
= document
.getElementById("flip");
162 animation
.timer
= setInterval("animate();", 13);
163 animation
.from
= animation
.now
;
170 function mouseexit(event
)
174 // fade in the flip widget
175 if (animation
.timer
!= null)
177 clearInterval (animation
.timer
);
178 animation
.timer
= null;
181 var starttime
= (new Date
).getTime() - 13;
183 animation
.duration
= 500;
184 animation
.starttime
= starttime
;
185 animation
.firstElement
= document
.getElementById("flip");
186 animation
.timer
= setInterval("animate();", 13);
187 animation
.from
= animation
.now
;
199 var time
= (new Date
).getTime();
201 T
= limit_3(time
- animation
.starttime
, 0, animation
.duration
);
203 if (T
>= animation
.duration
)
205 clearInterval(animation
.timer
);
206 animation
.timer
= null;
207 animation
.now
= animation
.to
;
211 ease
= 0.5 - (0.5 * Math
.cos(Math
.PI
* T
/ animation
.duration
));
212 animation
.now
= compute_next_float(animation
.from
, animation
.to
, ease
);
215 animation
.firstElement
.style
.opacity
= animation
.now
;
218 function limit_3 (a
, b
, c
)
220 return a
< b
? b
: (a
> c
? c
: a
);
223 function compute_next_float(from
, to
, ease
)
225 return from
+ (to
- from
) * ease
;
228 function enterflip(event
)
230 document
.getElementById("fliprollie").style
.display
= "block";
233 function exitflip(event
)
235 document
.getElementById("fliprollie").style
.display
= "none";
238 /*=====================================================================*\
239 || ###################################################################
242 || ###################################################################
243 \*=====================================================================*/