mc_colorChoose.inc.js
12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
var var_bgColor="#f3f3f3";
var var_borderColor="#d0d1d0";
var var_target;
var var_close = true;
var colorDiv;
var dateDiv;
var var_height=2;
var var_width=16;
var var_days = new Array('Mo','Tu','We','Th','Fr','Sa','Su');
var var_month = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var var_date;
var colorChooseUrl = "include/Forest/mensch.coop/Images/colorChoose.jpg";
var colorPalette = new Array('000000','808080','800000','FF0000','008000','00FF00','808000','FFFF00','000080','0000FF','800080','FF00FF','008080','00FFFF','C0C0C0','FFFFFF');
function fnc_showChoose(name, caller, target){
var tmp_div=document.getElementById(name);
if(tmp_div.style.display == "none"){
tmp_div.style.display = "block";
tmp_div.style.top = window.document.getElementById(caller).offsetTop;
tmp_div.style.left = window.document.getElementById(caller).offsetLeft;
if(name=="colorDiv")
window.document.getElementById("colorView").updateColor(window.document.getElementById(target).value);
var_target=target;
}
else{
tmp_div.style.display = "none";
}
}
function fnc_chooseColor(){
window.document.getElementById(var_target).value="#"+window.document.getElementById("colorView").title;
fnc_borderColor(var_target);
colorDiv.style.display = "none";
}
function fnc_borderColor(param_target){
window.document.getElementById(param_target).style.borderColor=document.getElementById(param_target).value;
}
function fnc_chooseNone(){
window.document.getElementById(var_target).value='transparent';
colorDiv.style.display = "none";
}
function fnc_close(){
this.parentNode.parentNode.style.display = "none";
// colorDiv.style.display = "none";
// dateDiv.style.display = "none";
// this.style.display = "none";
}
function fnc_show(){
this.style.display = "block";
}
function fnc_mkChooserHead(param_type, param_div){
var tmp_close=window.document.createElement("div");
tmp_close.className="button close";
tmp_close.style.cssFloat = "right";
tmp_close.style.padding = "0";
tmp_close.style.margin = "0";
tmp_close.innerHTML = " ";
tmp_close.style.cursor="pointer";
tmp_close.onclick = fnc_close;
var tmp_head=window.document.createElement("div");
tmp_head.className = "jsChooserHead";
tmp_head.innerHTML= obj_lang[param_type];
param_div.insertBefore(tmp_head, param_div.firstChild);
tmp_head.insertBefore(tmp_close, tmp_head.firstChild);
}
function fnc_initChoose(type, name){
var tmp_div;
if(name != null){
tmp_div=window.document.getElementById(name);
}
else{
tmp_div=window.document.createElement('div');;
}
// <a class="bold nodecoration" href="javascript:fnc_close()"><span class="button close"><xsl:value-of select="$space"/></span><xsl:value-of select="$space"/>abbruch</a>
tmp_div.style.display = "none";
tmp_div.style.width = var_width *12.5;
tmp_div.style.height = var_width *17;
tmp_div.style.position = "absolute";
tmp_div.style.marginLeft = "50px";
tmp_div.style.marginTop = -var_width * 8 +"px";
tmp_div.style.padding="16px";
tmp_div.style.paddingTop="0";
tmp_div.style.zIndex = 10;
tmp_div.style.backgroundColor = var_bgColor;
tmp_div.style.border="2px solid "+var_borderColor;
fnc_mkChooserHead(type, tmp_div);
switch (type){
case "color" : tmp_div.style.width = var_width *25;
colorDiv=tmp_div;
fnc_mkColor();
/*fnc_mkCellColorLi();
fnc_mkHue();
fnc_mkColorQuad();
fnc_mkHueColorLi();
fnc_mkQuadColorLi();*/
break;
case "date" : tmp_div.style.height = var_width *19;
dateDiv=tmp_div;
fnc_mkCalendar();
break;
}
}
function fnc_mkCalendar(){
dateDiv.style.fontSize="1.2em";
var var_dateMenu=document.createElement('div');
var_dateMenu.style.border="2px solid " + var_borderColor;
var_dateMenu.style.marginBottom = "0.8em";
var_dateMenu.style.backgroundColor = "white";
var var_aBack = window.document.createElement('a');
var_aBack.innerHTML="<<";
var_aBack.title="vorheriger Monat";
var_aBack.style.marginRight="2em";
var_aBack.href="";
var var_aNext = window.document.createElement('a');
var_aNext.innerHTML=">>";
var_aNext.title="folgender Monat";
var_aNext.style.marginLeft="2em";
var_aBack.href="";
var var_spanMonth = window.document.createElement('span');
var_spanMonth.style.fontWeight = "bold";
var_spanMonth.innerHTML="CAL";
var_spanMonth.style.margin = "auto";
var_spanMonth.style.backgroundColor = "white";
var var_divMonth = window.document.createElement('div');
var_divMonth.style.margin = "auto";
var_divMonth.style.marginTop = "0.2em";
var_divMonth.style.marginBottom = "0.2em";
var_divMonth.style.width="12em";
var_divMonth.appendChild(var_aBack);
var_divMonth.appendChild(var_spanMonth);
var_divMonth.appendChild(var_aNext);
var_dateMenu.appendChild(var_divMonth);
dateDiv.appendChild(var_dateMenu);
var var_dateUl = window.document.createElement('ul');
var_dateUl.className="DateBC";
var_dateUl.style.width="12em";
var_dateUl.style.margin="auto";
dateDiv.appendChild(var_dateUl);
for(var i = 0; i < 7; i++){
var var_weekDay = window.document.createElement('li');
var_weekDay.className="day";
var_weekDay.appendChild(window.document.createTextNode(obj_lang[var_days[i]]));
var_dateUl.appendChild(var_weekDay);
}
for(var i = 0; i < 42; i++){
var var_weekDay = window.document.createElement('li');
var_weekDay.className="day";
var_dateUl.appendChild(var_weekDay);
}
fnc_mkMonth(new Date().getMonth(), new Date().getFullYear());
}
function fnc_mkMonth(param_month, param_year){
var tmp_date = new Date(param_year,param_month,'1');
var_date=tmp_date;
var tmp_divMenu = dateDiv.getElementsByTagName("div")[2];
var tmp_next = param_month + 1;
var tmp_back = param_month - 1;
var tmp_nextYear = param_year;
var tmp_backYear = param_year;
if(tmp_next > 11){
tmp_next = 0;
tmp_nextYear += 1;
}
if(tmp_back < 0){
tmp_back = 11;
tmp_backYear -= 1;
}
tmp_divMenu.getElementsByTagName("a")[0].href="javascript:fnc_mkMonth("+tmp_back+","+tmp_backYear+")";
tmp_divMenu.getElementsByTagName("a")[1].href="javascript:fnc_mkMonth("+tmp_next+","+tmp_nextYear+")";
tmp_divMenu.getElementsByTagName("span")[0].innerHTML=obj_lang[var_month[param_month]] + " - " + param_year;
var tmp_startDay = tmp_date.getDay() - 1;
if(tmp_startDay < 0){
tmp_startDay=6;
}
tmp_lastDay=new Date(param_year, param_month+1, 0).getDate() + 1;
tmp_startDay += 6;
var var_daysLi = dateDiv.getElementsByTagName("ul")[0].getElementsByTagName("li");
tmp_counter = 1;
var tmp_today = new Date();
var tmp_thisDay = -1;
if(tmp_today.getFullYear() == param_year && tmp_today.getMonth() == param_month){
tmp_thisDay = tmp_today.getDate();
}
for(var i = 7; i < 49; i++){
if(i > tmp_startDay && tmp_counter < tmp_lastDay){
var_daysLi[i].innerHTML = tmp_counter;
var_daysLi[i].style.backgroundColor="white";
var_daysLi[i].style.color="black";
if(tmp_thisDay == tmp_counter){
var_daysLi[i].style.color="red";
}
var_daysLi[i].onmouseover=fnc_dateMouseover;
var_daysLi[i].onmouseout=fnc_dateMouseout;
var_daysLi[i].onmousedown=fnc_dateMousedown;
var_daysLi[i].title=tmp_counter+"-"+param_month+"-"+param_year;
tmp_counter++;
}
else{
var_daysLi[i].innerHTML = " ";
var_daysLi[i].style.backgroundColor=var_bgColor;
var_daysLi[i].onmouseover='';
var_daysLi[i].onmouseout='';
var_daysLi[i].onmousedown='';
var_daysLi[i].title="";
}
}
}
function fnc_dateMousedown(){
window.document.getElementById(var_target+"day").selectedIndex = this.getAttribute("title").split("-")[0] - 1;
window.document.getElementById(var_target+"month").selectedIndex = this.getAttribute("title").split("-")[1];
window.document.getElementById(var_target+"year").selectedIndex = (this.getAttribute("title").split("-")[2] - 2006);
dateDiv.style.display = "none";
}
function fnc_dateMouseout(){
this.style.backgroundColor="white";
this.style.textDecoration="none";
}
function fnc_dateMouseover(){
this.style.backgroundColor=var_borderColor;
this.style.cursor="pointer";
this.style.textDecoration="underline";
}
function fnc_HSVtoRGB(h, s, v){
var var_r,var_g,var_b;
s = s/100.0;
v = v/100.0;
if(s==0){
var_r = var_g = var_b = v
}
else{
var hi,f,q,p,t;
h = h/60.0;
hi = Math.floor(h);
f = h - hi;
p = v * (1 - s);
q = v * (1 - (s * f));
t = v * (1 - (s * (1 - f)));
switch(hi){
case 1 : var_r=q; var_g=v; var_b=p; break;
case 2 : var_r=p; var_g=v; var_b=t; break;
case 3 : var_r=p; var_g=q; var_b=v; break;
case 4 : var_r=t; var_g=p; var_b=v; break;
case 5 : var_r=v; var_g=p; var_b=q; break;
default : var_r=v; var_g=t; var_b=p; break;
}
}
return new Array(Math.round(var_r * 255.0),Math.round(var_g * 255.0),Math.round(var_b * 255.0));
}
function fnc_toHex(value){
var hex = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F');
var h = Math.floor(value / 16);
var l = value - h * 16;
return hex[h] + hex[l];
}
function fnc_mkVColor(h,s,v,i){
if(i<75)
var var_rgb = fnc_HSVtoRGB(h,s,i*(4/3));
else
var var_rgb = fnc_HSVtoRGB(h,s - (s/75 * (i-75)),100);
return fnc_toHex(var_rgb[0]) + fnc_toHex(var_rgb[1]) + fnc_toHex(var_rgb[2]);
}
function fnc_mkColor(){
var startColor = "123456";
var colorView = window.document.createElement('div');
colorView.id = "colorView";
colorView.updateColor = function(color){
this.title=color;
this.style.backgroundColor=color;
};
colorView.style.width="360px";
colorView.style.height="20px";
colorView.style.marginTop="5px";
colorView.style.marginBottom="5px";
colorView.style.backgroundColor=startColor;
colorDiv.appendChild(colorView);
var colorChoose = window.document.createElement('div');
colorChoose.style.cssFloat="left";
colorChoose.style.clear="none";
var colorV = window.document.createElement('div');
colorV.style.width="20px";
colorV.style.height="150px";
colorV.style.marginLeft="15px";
colorV.style.cssFloat="left";
colorV.style.clear="none";
if(var_target){
startColor = window.document.getElementById(var_target).value;
}
var colorUlV = window.document.createElement('ul');
for(var i=150;i>0;i--){
tmp_li = window.document.createElement('li');
tmp_li.style.width="20px";
tmp_li.style.height="1px";
tmp_li.onclick = function(){
colorView.updateColor(this.title);
}
tmp_li.style.backgroundColor=startColor;
colorUlV.appendChild(tmp_li);
}
colorV.appendChild(colorUlV);
colorV.setColor = function(h,s,v){
var colLi=colorV.getElementsByTagName('li');
for(var i = colLi.length -1;i>=0;i--){
colLi[i].title = fnc_mkVColor(h,s,v,i);
colLi[i].style.backgroundColor = colLi[i].title;
}
}
var colorChooseImg = window.document.createElement('img');
colorChooseImg.target = colorV;
colorChooseImg.src = colorChooseUrl;
colorChooseImg.onclick = fnc_setColorBar;
colorChoose.appendChild(colorChooseImg);
var ul_colorPalette = window.document.createElement('ul');
ul_colorPalette.className = 'js_ul_colorPalette';
for(var i = colorPalette.length-1;i>=0;i--){
var li_colorPalette = window.document.createElement('li');
li_colorPalette.className = 'js_li_colorPalette';
li_colorPalette.style.backgroundColor=colorPalette[i];
li_colorPalette.title = colorPalette[i];
li_colorPalette.onclick = function(){colorView.updateColor(this.title);};
ul_colorPalette.appendChild(li_colorPalette);
}
colorDiv.appendChild(colorChoose);
colorDiv.appendChild(colorV);
colorDiv.appendChild(ul_colorPalette);
}
function fnc_setColorBar(event){
this.offLeft=this.offsetLeft+this.parentNode.parentNode.offsetLeft+window.document.getElementById("Site").offsetLeft+2;
this.offTop=this.offsetTop+this.parentNode.parentNode.offsetTop + this.parentNode.offsetTop + window.document.getElementById("Site").offsetTop+59;
if(window.document.body.className == "smallNav"){
this.offTop -=59;
}
var xCoord = event.pageX - this.offLeft;
var yCoord = event.pageY - this.offTop;
this.target.setColor(xCoord,(100-(yCoord*(2/3))),100-(yCoord/3));
var var_rgb = fnc_HSVtoRGB(xCoord,(100-(yCoord*(2/3))),100-(yCoord/3));
window.document.getElementById("colorView").updateColor(fnc_toHex(var_rgb[0]) + fnc_toHex(var_rgb[1]) + fnc_toHex(var_rgb[2]));
}