source: ether_visual/trunk/select_date.jsp @ 17

Last change on this file since 17 was 17, checked in by cbipsl, 18 years ago

ajout V3

  • Property svn:executable set to *
File size: 11.8 KB
Line 
1<%@ page import="fr.acri.norm.*" %>
2
3<%@ page import="java.io.*" %>
4<%@ page import="java.util.*" %>
5<%@ page import="java.lang.*" %>
6<%
7send_request req = new send_request();
8String date_max_file="",date_min_file="",sav_sel_date_max="", sel_date_max="",sel_date_min="",periode="",op=""; 
9
10int nreq=-1, k=0;
11
12sav_sel_date_max=request.getParameter("sav_sel_date_max");
13if (sav_sel_date_max=="" || sav_sel_date_max==null) {
14        sav_sel_date_max="";
15}
16
17date_max_file=request.getParameter("date_max_file");
18if (date_max_file=="" || date_max_file==null) {
19        date_max_file="";
20}
21
22date_min_file=request.getParameter("date_min_file");
23if (date_min_file=="" || date_min_file==null) {
24        date_min_file="";
25}
26
27sel_date_min=request.getParameter("sel_date_min");
28if (sel_date_min=="" || sel_date_min==null) {
29        sel_date_min="";
30}
31
32sel_date_max=request.getParameter("sel_date_max");
33if (sel_date_max=="" || sel_date_max==null) {
34        sel_date_max=sav_sel_date_max;
35}
36
37op=request.getParameter("op");
38if (op=="" || op==null) {
39        op="";
40}
41
42periode=request.getParameter("periode");
43if (periode=="" || periode==null) {
44        periode="-1";
45}
46
47String def_date_max=date_max_file;
48if (!periode.equals("-1")) {
49        calNRecouv pnrecouv = new calNRecouv((new calDate()).invers(sel_date_min),Integer.parseInt(periode),"jour");
50        def_date_max=pnrecouv.date_cal;
51}
52
53if (op.equals("1")) {
54if (!periode.equals("-1")) {
55        calNRecouv pnrecouv = new calNRecouv((new calDate()).invers(sel_date_min),Integer.parseInt(periode),"jour");
56        sel_date_max=pnrecouv.date_cal;
57        if ((new calDate()).invers(sel_date_max) > (new calDate()).invers(date_max_file)) sel_date_max=date_max_file;
58}
59}
60       
61
62req.close_connection();
63%>
64<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
65<html>
66  <head>
67    <meta http-equiv="pragma" content="no-cache">
68    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
69    <title>Visualisation V3</title>
70    <link rel="stylesheet" href="ether.css" type="text/css">
71        <script language="Javascript">
72        //<!--
73var longdate="";
74var regExpEmpty=/^(\s)*$/g;
75
76function setVal(mind,maxd) {
77retour=false;
78
79mind=trim(mind);
80maxd=trim(maxd);
81if (document.thisForm.op.value=='1') {
82        checkDate(mind,maxd,'1');
83}
84else if (document.thisForm.op.value=='2') retour=false;
85else retour=true;
86
87if (retour==true) {
88document.thisForm.op.value='';
89window.opener.document.thisForm.mindate.value=document.thisForm.sel_date_min.value;
90window.opener.document.thisForm.maxdate.value=document.thisForm.sel_date_max.value;
91window.opener.document.thisForm.temp_mindate.value=document.thisForm.sel_date_min.value;
92window.opener.document.thisForm.temp_maxdate.value=document.thisForm.sel_date_max.value;
93
94window.opener.updateTitle('clear');
95
96window.close();
97}
98
99}
100
101function trim(chaine) {
102        while(chaine.charAt(0) == " ") chaine = chaine.substring(1);
103        while(chaine.charAt(chaine.length-1) == " ") chaine = chaine.substring(0, chaine.length-1);
104        return chaine;
105}
106
107
108function Newfen (URL,NAME,W,H) {
109  var wconf = 'scrollbars=yes,toolbar=no,location=no,directories=no,status=yes,menubar=no,resizable=yes,width=' + W + ',height=' + H;
110  var w = window.open (URL, NAME, wconf);
111}
112
113function isDate(s) {
114        var a0=s.split("-");
115        if ((a0.length!=2)){
116                e=false;
117        }else{
118                // Verification de la date
119
120                var a1=a0[0].split("/");
121                var a2=a0[1].split(":");
122                var e=true;
123               if( (a1.length!=3) && (a2.length!=4) && (a1[0].length!=4 || a1[1].length!=2 || a1[2].length!=2 || a2[0].length!=2 || a2[1].length!=2 || a2[2].length!=2 || a2[3].length!=3 )){
124                        e=false;
125                }else{
126                        var y=a1[0],m=a1[1],d=a1[2];
127                        if (isPositiveInteger(a1[0]) && isPositiveInteger(a1[1]) && isPositiveInteger(a1[2])){
128                                if ( (y<1000)||(y.length>4) ) {
129                                        e=false;       
130                                }
131                                if (e) {
132                                        v=new Date(m+"/"+d+"/"+y);
133                                        if (v.getMonth()!=m-1) {
134                                                e=false;
135                                        }
136                                }
137                        }else{
138                                e=false;
139                        }
140                        // Verification de l'heure
141                        if( e ){
142                                if (isPositiveInteger(a2[0]) && isPositiveInteger(a2[1]) && isPositiveInteger(a2[2])){
143                                        var hh=a2[0],mm=a2[1],ss=a2[2],ms=a2[3];
144                                        if( ms.length<3 ) {
145                                                e=false;
146                                                //alert('6');
147                                        }
148                                        if (e) {
149                                                v=new Date(m+"/"+d+"/"+y+" "+hh+":"+mm+":"+ss);
150                                                longdate=y+m+d+hh+mm+ss+ms;
151                                                /*if (v.getMonth()!=m-1) {
152                                                        e=false;
153                                                        //alert(m);
154                                                        alert(v.getMonth());
155                                                }*/
156                                        }
157                                }else{
158                                        e=false;
159                                }
160                        }
161                }
162        }
163        return e
164}
165
166
167function isPositiveInteger(theString){
168        var theData = new String(theString)
169
170        if (!isDigit(theData.charAt(0)))
171                if (!(theData.charAt(0)== '+'))return false
172
173        for (var i = 1; i < theData.length; i++)
174                if (!isDigit(theData.charAt(i)))return false
175        return true
176}
177
178function isDigit(theDigit)
179{
180        var digitArray = new Array('0','1','2','3','4','5','6','7','8','9'),j;
181
182        for (j = 0; j < digitArray.length; j++)
183        {
184                if (theDigit == digitArray[j])return true
185        }
186        return false
187
188}
189
190function checkDate(minDT,maxDT,sub) {
191        var minD="";
192
193        document.thisForm.sel_date_min.value=trim(document.thisForm.sel_date_min.value);
194        document.thisForm.sel_date_max.value=trim(document.thisForm.sel_date_max.value);
195
196       
197        if (document.thisForm.sel_date_min.value.length>23) {
198                alert("Warning : The format of the Date min is not correct, it should be YYYY/MM/DD-HH:MM:SS:MSC");
199                return false;
200        }
201
202        if (document.thisForm.sel_date_max.value.length>23) {
203                alert("Warning : The format of the Date max is not correct, it should be YYYY/MM/DD-HH:MM:SS:MSC");
204                return false;
205        }
206               
207
208        if (sub=='0') document.thisForm.sel_date_max.disabled=true;
209
210        mindate=document.thisForm.sel_date_min.value;
211
212        isDate(minDT);
213        long_minDT=longdate;
214
215        isDate(maxDT);
216        long_maxDT=longdate;
217
218        if( !isDate(mindate) ){
219                alert("Warning : The format of the Date min is not correct, it should be YYYY/MM/DD-HH:MM:SS:MSC");
220                document.thisForm.sel_date_min.value=minDT;
221                return false;
222        }
223        longdatemin=longdate;
224        maxdate=document.thisForm.sel_date_max.value;
225        if( !isDate(maxdate) ){
226                alert("Warning : The format of the Date max is not correct, it should be YYYY/MM/DD-HH:MM:SS:MSC");
227                document.thisForm.sel_date_max.value=document.thisForm.sav_sel_date_max.value;
228                return false;
229        }
230        longdatemax=longdate;
231        if (parseFloat(longdatemin)<parseFloat(long_minDT)) {
232                alert("Warning: Date min can not be less than the Date min of the experiment files ("+minDT+")");
233                document.thisForm.sel_date_min.value=document.thisForm.sav_sel_date_min.value;
234                return false;
235        }
236
237        if (parseFloat(longdatemax)>parseFloat(long_maxDT)) {
238                alert("Warning: Date max can not be greater than the Date max of the experiment files ("+maxDT+")");
239                document.thisForm.sel_date_max.value=document.thisForm.sav_sel_date_max.value;
240                //return false;
241        }
242
243        if( parseFloat(longdatemin)>parseFloat(long_maxDT)) {
244                alert("Warning : Date min can not be greater than the Date max of the experiment files ("+maxDT+")");
245                document.thisForm.sel_date_min.value=document.thisForm.sav_sel_date_min.value;
246                //return false;
247        }
248
249if (sub=='1') {
250        document.thisForm.op.value='1';
251        document.thisForm.submit();
252}
253else if(sub=='2') {
254        checkDate2();   
255
256}
257
258document.thisForm.sel_date_max.disabled=false;
259return true;
260
261}
262
263function checkDate2() {
264        document.thisForm.op.value='2';
265        mindate=document.thisForm.sel_date_min.value;
266
267        isDate(mindate);
268        longdatemin=longdate;
269
270        maxdate=document.thisForm.sel_date_max.value;
271        isDate(maxdate);
272        longdatemax=longdate;
273
274/*      isDate(document.thisForm.sav_sel_date_max.value);
275        alert(document.thisForm.sav_sel_date_max.value);*/
276
277        isDate(document.thisForm.def_date_max.value);
278        longdatemaxsav=longdate;
279
280        if (parseFloat(longdatemax)<parseFloat(longdatemin)) {
281                alert("Warning: Date max can not be less than the Date min.");
282                document.thisForm.sel_date_max.value=document.thisForm.sav_sel_date_max.value;
283                return false;
284        }
285
286        if (parseFloat(longdatemax)>parseFloat(longdatemaxsav)) {
287                alert("Warning: Your selection limits the date max to : "+document.thisForm.def_date_max.value);
288                document.thisForm.sel_date_max.value=document.thisForm.def_date_max.value;
289                return false;
290        }
291        document.thisForm.op.value='0';
292        return true;
293}
294
295
296        //-->
297        </script>       
298  </head>
299  <body onLoad="" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
300<form name="thisForm">
301<table border="0" align=center width="100%" cellpadding="2" cellspacing="2">
302<input type="hidden" name="date_min_file" value="<%=date_min_file%>">
303<input type="hidden" name="date_max_file" value="<%=date_max_file%>">
304<input type="hidden" name="sav_sel_date_max" value="<%=sel_date_max%>">
305<input type="hidden" name="sav_sel_date_min" value="<%=sel_date_min%>">
306<input type="hidden" name="periode" value="<%=periode%>">
307<input type="hidden" name="op" value="<%=0%>">
308<input type="hidden" name="def_date_max" value="<%=def_date_max%>">
309<tr><td colspan=4 class="titreN">DATE SETTINGS</td></tr>
310<tr><td colspan=4 class="rubrique">Date range of the dataset</td></tr>
311<tr>
312<td nowrap class="ssrubrique">Date</td>
313<td nowrap><input onClick="document.thisForm.sel_date_max.disabled=true" onChange="document.thisForm.op.value='1'" type="text" name="sel_date_min" size="25" value="<%=sel_date_min%>"></td>
314<td nowrap class="normal">to<input type="button" value=">>" onClick=checkDate('<%=date_min_file%>','<%=date_max_file%>','1')></td>
315<td width="100%"><input onChange="checkDate('<%=date_min_file%>','<%=date_max_file%>','2');" type="text" name="sel_date_max" size="25" value="<%=sel_date_max%>"></td>
316</tr>
317<tr>
318<td class="normal" colspan=4 valign="top">
319<%
320if (date_max_file!="" && date_min_file!=null) { %>
321<span class="normal">Files time range :&nbsp;[&nbsp;<%=date_min_file%>&nbsp;-&nbsp;<%=date_max_file%>&nbsp;]</span>
322<%
323}
324else {
325%>
326&nbsp;
327<%}%>
328</td>
329
330</tr>
331<tr>
332<td class="normal" colspan=4 valign="top">
333<%if (!periode.equals("-1")) {%>
334Period of no data overlapping : <%=periode%> days<%}
335else {%>
336Period of no data overlapping : None
337<%}%>
338</td>
339</tr>
340<tr>
341<td class="normal" colspan=4 valign="top">
342<i>To modify the interval of measured data, please set the start date in the left field and click on the button <input type="button" value=">>"> in order to calculate automatically the end date associated.
343<br>
344Then, if you want to reduce more the interval between the two dates please change the end date. </i> 
345</td>
346</tr>
347
348<tr><td>&nbsp;</td></tr> 
349<tr><td colspan=5 align="center"><a href=# onClick="setVal('<%=date_min_file%>','<%=date_max_file%>');"><img src="Icons/valid.gif" width="75" height="25" border=0></a>&nbsp;
350<a href=# onClick="window.close();"><img src="Icons/cancel.gif" width="75" height="25" border=0></a>
351</td>
352
353</tr>
354</table>
355</form>
356</body>
357</html>
358
Note: See TracBrowser for help on using the repository browser.