]> err.no Git - scalable-opengroupware.org/blob - UI/WebServerResources/UIxAppointmentEditor.js
added default to disable etag caching in mail objects
[scalable-opengroupware.org] / UI / WebServerResources / UIxAppointmentEditor.js
1 /*
2  Copyright (C) 2005 SKYRIX Software AG
3  
4  This file is part of OpenGroupware.org.
5  
6  OGo is free software; you can redistribute it and/or modify it under
7  the terms of the GNU Lesser General Public License as published by the
8  Free Software Foundation; either version 2, or (at your option) any
9  later version.
10  
11  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12  WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14  License for more details.
15  
16  You should have received a copy of the GNU Lesser General Public
17  License along with OGo; see the file COPYING.  If not, write to the
18  Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19  02111-1307, USA.
20 */
21
22 function uixEarlierDate(date1, date2) {
23   // can this be done in a sane way?
24   if (date1.getYear()  < date2.getYear()) return date1;
25   if (date1.getYear()  > date2.getYear()) return date2;
26   // same year
27   if (date1.getMonth() < date2.getMonth()) return date1;
28   if (date1.getMonth() > date2.getMonth()) return date2;
29   // same month
30   if (date1.getDate() < date2.getDate()) return date1;
31   if (date1.getDate() > date2.getDate()) return date2;
32   // same day
33   return null;
34 }
35
36 function validateAptEditor() {
37   var e, startdate, enddate, tmpdate;
38       
39   e = document.getElementById('summary');
40   if (e.value.length == 0) {
41     if (!confirm(labels.validate_notitle))
42       return false;
43   }
44
45   e = document.getElementById('startTime_date');
46   if (e.value.length != 10) {
47     alert(labels.validate_invalid_startdate);
48     return false;
49   }
50   startdate = calendar_startTime_date.prs_date(e.value);
51   if (startdate == null) {
52     alert(labels.validate_invalid_startdate);
53     return false;
54   }
55       
56   e = document.getElementById('endTime_date');
57   if (e.value.length != 10) {
58     alert(labels.validate_invalid_enddate);
59     return false;
60   }
61   enddate = calendar_endTime_date.prs_date(e.value);
62   if (enddate == null) {
63     alert(labels.validate_invalid_enddate);
64     return false;
65   }
66   
67   tmpdate = uixEarlierDate(startdate, enddate);
68   if (tmpdate == enddate) {
69     alert(labels.validate_endbeforestart);
70     return false;
71   }
72   else if (tmpdate == null /* means: same date */) {
73     // TODO: check time
74     var start, end;
75     
76     start = document.forms[0]['startTime_time_hour'].value;
77     end   = document.forms[0]['endTime_time_hour'].value;
78     if (start > end) {
79       alert(labels.validate_endbeforestart);
80       return false;
81     }
82     else if (start == end) {
83       start = document.forms[0]['startTime_time_minute'].value;
84       end   = document.forms[0]['endTime_time_minute'].value;
85       if (start > end) {
86         alert(labels.validate_endbeforestart);
87         return false;
88       }
89     }
90   }
91
92   return true;
93 }