Code

Updated FAQ
[gosa.git] / gosa-core / html / include / calendar.js
1         function populate(objForm,resultForm) {
2                 if(objForm.year) {
3                         yearSel=objForm.year.options[objForm.year.selectedIndex].text;
4                 
5                         monthIx=objForm.month.selectedIndex;
6                         nextMonthIx=0;
7                         if(monthIx!=11) {
8                                 nextMonthIx=monthIx+1;
9                         }
11                         nextMonthSel=objForm.month.options[nextMonthIx].value;
12                         monthSel=objForm.month.options[monthIx].value;
14                         daySel=1;
15                         if(objForm.day.selectedIndex!=-1) {
16                                 daySel=objForm.day.options[objForm.day.selectedIndex].text;
17                         }
19                         timeOfDayOne = new Date(yearSel, nextMonthSel, 1);
20                         timeDifference = timeOfDayOne - 86400000;
21                         timeOfLastDay = new Date(timeDifference);
23                         var daysInMonth = timeOfLastDay.getDate();
25                         if(daySel>daysInMonth) daySel=daysInMonth;
27                         selectedDate= new Date(yearSel,monthSel,daySel);
28                         for (var i = 0; i < objForm.day.length; i++) {
29                                 objForm.day.options[0] = null;
30                         }
31                         for (var i = 0; i < daysInMonth; i++) {
32                                 objForm.day.options[i] = new Option(i+1);
33                         }
34                         objForm.day.selectedIndex=daySel-1;
35                         saveResult(selectedDate,resultForm);
36                 }
37         }
39         function createResult(objForm,resultForm){
40                 yearSel=objForm.year.options[objForm.year.selectedIndex].text;
41                 monthIx=objForm.month.selectedIndex;
42                 monthSel=objForm.month.options[monthIx].value;
43                 daySel=objForm.day.options[objForm.day.selectedIndex].value;
44                 selectedDate= new Date(yearSel,monthSel,daySel);
45                 saveResult(selectedDate,resultForm);
46         }
48         function saveResult(selectedDate,resultForm){
49                 timeInSeconds=Math.floor((selectedDate.getTime() - selectedDate.getTimezoneOffset() * 60000 ) / 1000);
50                 resultForm.value=timeInSeconds;
51         }
52         
53         function populate_sambaLogonTime(objForm,resultForm) {
54                 var yearSel=objForm.sambaLogonTime_year.options[objForm.sambaLogonTime_year.selectedIndex].text;
55                 var monthIx=objForm.sambaLogonTime_month.selectedIndex;
56                 var nextMonthIx=0;
57                 if(monthIx!=11)
58                         nextMonthIx=monthIx+1;
60                 var nextMonthSel=objForm.sambaLogonTime_month.options[nextMonthIx].value;
61                 var monthSel=objForm.sambaLogonTime_month.options[monthIx].value;
63                 var daySel=1;
64                 if(objForm.sambaLogonTime_day.selectedIndex!=-1)
65                         daySel=objForm.sambaLogonTime_day.options[objForm.sambaLogonTime_day.selectedIndex].value;
67                 var timeOfDayOne = new Date(yearSel, nextMonthSel, 1);
68                 var timeDifference = timeOfDayOne - 86400000;
69                 var timeOfLastDay = new Date(timeDifference);
71                 var daysInMonth = timeOfLastDay.getDate();
73                 if(daySel>daysInMonth) daySel=daysInMonth;
75                 var selectedDate= new Date(yearSel,monthSel,daySel);
76                 for (var i = 0; i < objForm.sambaLogonTime_day.length; i++) {
77                         objForm.sambaLogonTime_day.options[0] = null;
78                 }
79                 for (var i = 0; i < daysInMonth; i++) {
80                         objForm.sambaLogonTime_day.options[i] = new Option(i+1);
81                 }
82                 objForm.sambaLogonTime_day.selectedIndex=daySel-1;
83                 saveResult(selectedDate,resultForm);
84         }
85         function populate_sambaLogoffTime(objForm,resultForm) {
86                 var yearSel=objForm.sambaLogoffTime_year.options[objForm.sambaLogoffTime_year.selectedIndex].text;
87                 var monthIx=objForm.sambaLogoffTime_month.selectedIndex;
88                 var nextMonthIx=0;
89                 if(monthIx!=11)
90                         nextMonthIx=monthIx+1;
92                 var nextMonthSel=objForm.sambaLogoffTime_month.options[nextMonthIx].value;
93                 var monthSel=objForm.sambaLogoffTime_month.options[monthIx].value;
95                 var daySel=1;
96                 if(objForm.sambaLogoffTime_day.selectedIndex!=-1)
97                         daySel=objForm.sambaLogoffTime_day.options[objForm.sambaLogoffTime_day.selectedIndex].value;
99                 var timeOfDayOne = new Date(yearSel, nextMonthSel, 1);
100                 var timeDifference = timeOfDayOne - 86400000;
101                 var timeOfLastDay = new Date(timeDifference);
103                 var daysInMonth = timeOfLastDay.getDate();
105                 if(daySel>daysInMonth) daySel=daysInMonth;
107                 var selectedDate= new Date(yearSel,monthSel,daySel);
108                 for (var i = 0; i < objForm.sambaLogoffTime_day.length; i++) {
109                         objForm.sambaLogoffTime_day.options[0] = null;
110                 }
111                 for (var i = 0; i < daysInMonth; i++) {
112                         objForm.sambaLogoffTime_day.options[i] = new Option(i+1);
113                 }
114                 objForm.sambaLogoffTime_day.selectedIndex=daySel-1;
115                 saveResult(selectedDate,resultForm);
116         }
117         function populate_sambaKickoffTime(objForm,resultForm) {
118                 var yearSel=objForm.sambaKickoffTime_year.options[objForm.sambaKickoffTime_year.selectedIndex].text;
119                 var monthIx=objForm.sambaKickoffTime_month.selectedIndex;
120                 var nextMonthIx=0;
121                 if(monthIx!=11)
122                         nextMonthIx=monthIx+1;
124                 var nextMonthSel=objForm.sambaKickoffTime_month.options[nextMonthIx].value;
125                 var monthSel=objForm.sambaKickoffTime_month.options[monthIx].value;
127                 var daySel=1;
128                 if(objForm.sambaKickoffTime_day.selectedIndex!=-1)
129                         daySel=objForm.sambaKickoffTime_day.options[objForm.sambaKickoffTime_day.selectedIndex].value;
131                 var timeOfDayOne = new Date(yearSel, nextMonthSel, 1);
132                 var timeDifference = timeOfDayOne - 86400000;
133                 var timeOfLastDay = new Date(timeDifference);
135                 var daysInMonth = timeOfLastDay.getDate();
137                 if(daySel>daysInMonth) daySel=daysInMonth;
139                 var selectedDate= new Date(yearSel,monthSel,daySel);
140                 for (var i = 0; i < objForm.sambaKickoffTime_day.length; i++) {
141                         objForm.sambaKickoffTime_day.options[0] = null;
142                 }
143                 for (var i = 0; i < daysInMonth; i++) {
144                         objForm.sambaKickoffTime_day.options[i] = new Option(i+1);
145                 }
146                 objForm.sambaKickoffTime_day.selectedIndex=daySel-1;
147                 saveResult(selectedDate,resultForm);
148         }
150         function populate_sambaPwdCanChange(objForm,resultForm) {
152                 var yearSel=objForm.sambaPwdCanChange_year.options[objForm.sambaPwdCanChange_year.selectedIndex].text;
153                 var monthIx=objForm.sambaPwdCanChange_month.selectedIndex;
154                 var nextMonthIx=0;
155                 if(monthIx!=11)
156                         nextMonthIx=monthIx+1;
158                 var nextMonthSel=objForm.sambaPwdCanChange_month.options[nextMonthIx].value;
159                 var monthSel=objForm.sambaPwdCanChange_month.options[monthIx].value;
161                 var daySel=1;
162                 if(objForm.sambaPwdCanChange_day.selectedIndex!=-1)
163                         daySel=objForm.sambaPwdCanChange_day.options[objForm.sambaPwdCanChange_day.selectedIndex].value;
165                 var timeOfDayOne = new Date(yearSel, nextMonthSel, 1);
166                 var timeDifference = timeOfDayOne - 86400000;
167                 var timeOfLastDay = new Date(timeDifference);
169                 var daysInMonth = timeOfLastDay.getDate();
171                 if(daySel>daysInMonth) daySel=daysInMonth;
173                 var selectedDate= new Date(yearSel,monthSel,daySel);
174                 for (var i = 0; i < objForm.sambaPwdCanChange_day.length; i++) {
175                         objForm.sambaPwdCanChange_day.options[0] = null;
176                 }
177                 for (var i = 0; i < daysInMonth; i++) {
178                         objForm.sambaPwdCanChange_day.options[i] = new Option(i+1);
179                 }
180                 objForm.sambaPwdCanChange_day.selectedIndex=daySel-1;
181                 saveResult(selectedDate,resultForm);
182         }
184         function createResult_sambaLogonTime(objForm,resultForm){
185                 yearSel=objForm.sambaLogonTime_year.options[objForm.sambaLogonTime_year.selectedIndex].text;
186                 monthIx=objForm.sambaLogonTime_month.selectedIndex;
187                 monthSel=objForm.sambaLogonTime_month.options[monthIx].value;
188                 daySel=objForm.sambaLogonTime_day.options[objForm.sambaLogonTime_day.selectedIndex].value;
189                 selectedDate= new Date(yearSel,monthSel,daySel);
190                 saveResult(selectedDate,resultForm);
191         }
192         function createResult_sambaLogoffTime(objForm,resultForm){
193                 yearSel=objForm.sambaLogoffTime_year.options[objForm.sambaLogoffTime_year.selectedIndex].text;
194                 monthIx=objForm.sambaLogoffTime_month.selectedIndex;
195                 monthSel=objForm.sambaLogoffTime_month.options[monthIx].value;
196                 daySel=objForm.sambaLogoffTime_day.options[objForm.sambaLogoffTime_day.selectedIndex].value;
197                 selectedDate= new Date(yearSel,monthSel,daySel);
198                 saveResult(selectedDate,resultForm);
199         }
200         function createResult_sambaKickoffTime(objForm,resultForm){
201                 yearSel=objForm.sambaKickoffTime_year.options[objForm.sambaKickoffTime_year.selectedIndex].text;
202                 monthIx=objForm.sambaKickoffTime_month.selectedIndex;
203                 monthSel=objForm.sambaKickoffTime_month.options[monthIx].value;
204                 daySel=objForm.sambaKickoffTime_day.options[objForm.sambaKickoffTime_day.selectedIndex].value;
205                 selectedDate= new Date(yearSel,monthSel,daySel);
206                 saveResult(selectedDate,resultForm);
207         }
208         function createResult_sambaPwdCanChange(objForm,resultForm){
209                 yearSel=objForm.sambaPwdCanChange_year.options[objForm.sambaPwdCanChange_year.selectedIndex].text;
210                 monthIx=objForm.sambaPwdCanChange_month.selectedIndex;
211                 monthSel=objForm.sambaPwdCanChange_month.options[monthIx].value;
212                 daySel=objForm.sambaPwdCanChange_day.options[objForm.sambaPwdCanChange_day.selectedIndex].value;
213                 selectedDate= new Date(yearSel,monthSel,daySel);
214                 saveResult(selectedDate,resultForm);
215         }
217     function createResult2(objForm,resultForm){
218         yearSel=objForm.syear.options[objForm.syear.selectedIndex].text;
219         monthIx=objForm.smonth.selectedIndex;
220         monthSel=objForm.smonth.options[monthIx].value;
221         daySel=objForm.sday.options[objForm.sday.selectedIndex].value;
222         selectedDate= new Date(yearSel,monthSel,daySel);
223         saveResult(selectedDate,resultForm);
224     }
226 function populate2(objForm,resultForm) {
227         if(objForm.syear) {
228             yearSel=objForm.syear.options[objForm.syear.selectedIndex].text;
230             monthIx=objForm.smonth.selectedIndex;
231             nextMonthIx=0;
232             if(monthIx!=11) {
233                 nextMonthIx=monthIx+1;
234             }
236             nextMonthSel=objForm.smonth.options[nextMonthIx].value;
237             monthSel=objForm.smonth.options[monthIx].value;
239             daySel=1;
240             if(objForm.sday.selectedIndex!=-1) {
241                 daySel=objForm.sday.options[objForm.sday.selectedIndex].text;
242             }
244             timeOfDayOne = new Date(yearSel, nextMonthSel, 1);
245             timeDifference = timeOfDayOne - 86400000;
246             timeOfLastDay = new Date(timeDifference);
248             var daysInMonth = timeOfLastDay.getDate();
250             if(daySel>daysInMonth) daySel=daysInMonth;
252             selectedDate= new Date(yearSel,monthSel,daySel);
253             for (var i = 0; i < objForm.sday.length; i++) {
254                 objForm.sday.options[0] = null;
255             }
256             for (var i = 0; i < daysInMonth; i++) {
257                 objForm.sday.options[i] = new Option(i+1);
258             }
259             objForm.sday.selectedIndex=daySel-1;
260             saveResult(selectedDate,resultForm);
261         }
262     }