source: tapas/web/project/formTapas_script.jsp @ 495

Last change on this file since 495 was 495, checked in by vmipsl, 12 years ago

ouaaahhhhh

File size: 29.6 KB
Line 
1<script type="text/javascript">
2
3
4var InterfaceTapas = Class.create( {
5
6    //initialize: function( jsonFileFormats, jsonYesNos, jsonObservatories, jsonSpectralUnits, jsonInstrumentalFunctions, jsonClimatoReferences )
7    initialize: function( jsonFileFormats, jsonYesNos, jsonSpectralUnits, jsonInstrumentalFunctions, jsonClimatoReferences )
8    {
9        /** *********** CONTAINERS *********** **/
10        this.containerForm = $( "#formulaire" );
11        //this.containerErrors = $( "#errors" );
12        this.containerErrors = $( "#errForm" );
13        this.containerCenter = $( "#containerCenter" );
14        this.containerTabs = $( "#tab" );
15
16        this.jSonFileFormats = jsonFileFormats || null;
17        this.jSonYesNos = jsonYesNos || null;
18        //this.jSonObservatories = jsonObservatories || false;
19        this.jSonObservatories = false;
20        this.jSonSpectralUnits = jsonSpectralUnits || null;
21        this.jSonInstrumentalFunctions = jsonInstrumentalFunctions || null;
22        this.jSonClimatoReferences = jsonClimatoReferences || null;
23        this.nbRequest = 1;
24        this.tabActive = false;
25        this.numRequest = 1;
26
27
28        this.containerErrors.show();
29
30        var submitButton = new Button( {value:tapasTexts["label.submitButton"], parent:this.containerCenter, id:"button_submit", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickSubmit, this )} );
31        this.addRequestButton = new Button( {value:tapasTexts["label.addButton"], parent:this.containerCenter, id:"button_add", className: "positive", onClick:jQuery.proxy( this.onClickAdd, this )} );
32        this.delRequestButton = new Button( {value:tapasTexts["label.delButton"], parent:this.containerCenter, id:"button_del", className: "negative", onClick:jQuery.proxy( this.onClickDel, this )} );
33        this.delRequestButton.disable();
34
35        this.createForm();
36        this.tabActive = this.createTab();
37
38    },
39
40
41    // CREATES ********************************************************
42    createTab:function()
43    {
44
45        var ntab = new Tab( {value:tapasTexts["label.requete"] + " " + this.nbRequest, parent:this.containerTabs, numTab: this.nbRequest, id:"tab_request" + this.nbRequest, className: "tab_class", onClick:jQuery.proxy( this.onClickTab, this )} );
46        ntab.active();
47        return ntab;
48
49    },
50
51
52    createCalendar: function( containerCalendar, texte, inputDateId, currentDate, isTrToCreate )
53    {
54        if( isTrToCreate )
55        {
56            // Create input for date text
57            var tr = $( document.createElement( "tr" ) );
58            var td1 = $( document.createElement( "td" ) );
59            var td2 = $( document.createElement( "td" ) );
60            var inputDate = $( document.createElement( "input" ) );
61            inputDate.attr( {id:inputDateId, size:"17"} );
62
63            td1.html( texte );
64            td1.attr( { class:"containerLabel" } );
65            tr.append( td1 );
66
67            td2.attr( {colspan:4} );
68            td2.append( inputDate );
69            tr.append( td2 );
70            containerCalendar.append( tr );
71        }
72
73        // Calendar
74        this.calendarFormat = "%Y-%m-%d %H:%i:%s";
75        this.calendarConverter = new AnyTime.Converter( { format: this.calendarFormat } );
76
77        AnyTime.picker( inputDateId, { format: this.calendarFormat, firstDOW: 1,
78            labelTitle: "Select Date", labelYear: "Year", labelMonth: "Month", labelDayOfMonth: "Day",
79            labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second"
80        } );
81
82        // Ajout de la date courrante ds le calendrier SI currentDate non précisée
83        if( !currentDate )
84            currentDate = new Date();
85        $( "#" + inputDateId ).val( this.calendarConverter.format( currentDate ) );
86        $( "#" + inputDateId ).addClass( "calendar" );
87
88    },
89
90
91    // CREATES ********************************************************
92    createTime: function( containerCalendar, texte, inputDateId, currentTime, isTrToCreate )
93    {
94        if( isTrToCreate )
95        {
96            // Create input for date text
97            var tr = $( document.createElement( "tr" ) );
98            var td1 = $( document.createElement( "td" ) );
99            var td2 = $( document.createElement( "td" ) );
100            var inputDate = $( document.createElement( "input" ) );
101            inputDate.attr( {id:inputDateId, size:"10"} );
102
103            td1.html( texte );
104            td1.attr( { class:"containerLabel" } );
105
106            tr.append( td1 );
107
108
109            td2.attr( {colspan:3} );
110            td2.append( inputDate );
111            tr.append( td2 );
112            containerCalendar.append( tr );
113        }
114
115        // Time
116        this.timeFormat = "%H:%i:%s";
117        this.timeConverter = new AnyTime.Converter( { format: this.timeFormat } );
118
119        AnyTime.picker( inputDateId, { format: this.timeFormat, firstDOW: 1,
120            labelTitle: "Select hour", labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second"
121        } );
122
123        if( !currentTime )
124            currentTime = "00:00:00";
125//        $( "#" + inputDateId ).val( this.timeConverter.format( currentTime ) );
126        $( "#" + inputDateId ).val( currentTime );
127        $( "#" + inputDateId ).addClass( "time" );
128    },
129
130
131    createTr: function( texte, inputId, container, textesup )
132    {
133        var tr = $( document.createElement( "tr" ) );
134        var td1 = $( document.createElement( "td" ) );
135        var td2 = $( document.createElement( "td" ) );
136        var td3 = $( document.createElement( "td" ) );
137        var input = $( document.createElement( "input" ) );
138
139        input.attr( {id: inputId, class:"containerText", size:11} );
140
141        td1.html( texte );
142        td1.attr( {class:"containerLabel"} );
143
144        td3.html( textesup );
145        td3.attr( {class:"containerLabel2", colspan:3} );
146        tr.append( td1 );
147        td2.append( input );
148
149        tr.append( td2 );
150        tr.append( td3 );
151        container.append( tr );
152
153    },
154
155    createSelectYesNo: function( container, name )
156    {
157        var paramSelect = new Object();
158        paramSelect.id = "select_" + name;
159        paramSelect.parent = container;
160        var selectYesNos = new Select( paramSelect );
161        jQuery.each( this.jSonYesNos, jQuery.proxy( function ( i, jsonYesNo )
162        {
163            selectYesNos.add( jsonYesNo.value, tapasTexts[jsonYesNo.text] );
164        }, this ) );
165        selectYesNos.selectFirst( false );
166        return selectYesNos;
167    },
168
169
170
171    createTr2Input: function( texte1, texte2, inputId1, inputId2, container, textesup )
172    {
173        var tr = $( document.createElement( "tr" ) );
174        var td1 = $( document.createElement( "td" ) );
175        var td2 = $( document.createElement( "td" ) );
176        var td3 = $( document.createElement( "td" ) );
177        var td4 = $( document.createElement( "td" ) );
178        var td5 = $( document.createElement( "td" ) );
179        var input1 = $( document.createElement( "input" ) );
180        var input2 = $( document.createElement( "input" ) );
181
182
183        input1.attr( {id: inputId1,class:"containerText",size:11} );
184        input2.attr( {id: inputId2,class:"containerText",size:11} );
185
186        td1.html( texte1 );
187        td3.html( texte2 );
188        td5.html( textesup );
189        td1.attr( {class:"containerLabel"} );
190        td3.attr( {class:"containerLabel3"} );
191        td5.attr( {class:"containerLabel2"} );
192
193        td2.append( input1 );
194        //td2.html( texte2 );
195        td4.append( input2 );
196
197        tr.append( td1 );
198        tr.append( td2 );
199        tr.append( td3 );
200        tr.append( td4 );
201        tr.append( td5 );
202        container.append( tr );
203    },
204
205
206
207    createTrList: function( texte, inputId, container, type )
208    {
209        var tr = $( document.createElement( "tr" ) );
210        var td1 = $( document.createElement( "td" ) );
211        var td2 = $( document.createElement( "td" ) );
212        var input = $( document.createElement( "input" ) );
213
214        input.attr( {id: inputId} );
215
216        td1.html( texte );
217        td1.attr( {class:"containerLabel"} );
218
219        tr.append( td1 );
220        if( type == 'format' ) this.displayFileFormats( td2, inputId );
221        else if( type == 'yesno' )
222        {
223            if( (/^(ih2oe_[1-9]+)$/.test( inputId )  ) ) this.select_ih2oe = this.createSelectYesNo( td2, inputId );
224            else if( (/^(io2e_[1-9]+)$/.test( inputId )  ) ) this.select_io2e = this.createSelectYesNo( td2, inputId );
225            else if( (/^(io3e_[1-9]+)$/.test( inputId )  ) ) this.select_io3e = this.createSelectYesNo( td2, inputId );
226            else if( (/^(ico2e_[1-9]+)$/.test( inputId )  ) ) this.select_ico2e = this.createSelectYesNo( td2, inputId );
227            else if( (/^(irextinction_[1-9]+)$/.test( inputId )  ) ) this.select_irextinction = this.createSelectYesNo( td2, inputId );
228        }
229        else if( type == 'observatories' ) this.displayObservatories( td2, inputId );
230        else if( type == 'spectralUnit' )
231        {
232            this.displaySpectralUnits( td2, inputId );
233            //td2.attr({colspan:3});
234        }
235        else if( type == 'ilsf' ) this.displayInstrumentalFunctions( td2, inputId );
236        else if( type == 'climatoReference' )
237        {
238            this.displayClimatoReferences( td2, inputId );
239        }
240
241        td2.attr( {colspan:3} );
242        tr.append( td2 );
243        container.append( tr );
244    },
245
246
247    // REQUESTS ********************************************************
248    requestCreateXML: function()
249    {
250        var tapasForm = this.createTapasObject();
251        //passage de javascript a json grace au jquery
252        var jsonTapasForm = $.toJSON( tapasForm );
253
254
255        if( jsonTapasForm )
256            $.ajax( {
257                url: "data?methodName=createUserRequest&jsonTapas=" + jsonTapasForm,
258                success:jQuery.proxy( this.handleCreateXML, this ),
259                error: jQuery.proxy( this.showErrors, this )
260            } );
261    },
262
263
264    // HANDLES ******************************************************** = retours ajax
265    handleCreateXML: function( result )
266    {
267        var bob = jQuery.parseJSON( result ).result;
268        alert( bob );
269    },
270
271
272    // EVENTS ********************************************************
273    onClickSubmit: function()
274    {
275        // if( this.validFields() )
276        // {
277        if( confirm( tapasTexts["confirm"] ) )
278        {
279            this.containerErrors.hide();
280            this.requestCreateXML();
281        }
282        // }
283    },
284
285
286    onClickAdd: function()
287    {
288        //if( this.validFields() )
289        if( true )
290        {
291            this.containerErrors.hide();
292            this.nbRequest++;
293
294            //tabs
295            $( ".tab_class" ).removeClass( "activated" );
296            this.tabActive = this.createTab();
297            this.numRequest = this.tabActive.numTab;
298
299            //formulaires
300            $( ".divAll" ).hide();
301            this.createForm();
302
303            this.delRequestButton.enable();
304            if( 9 == this.nbRequest ) this.addRequestButton.disable();
305            else this.addRequestButton.enable();
306        }
307    },
308
309
310    onClickDel: function()
311    {
312        //if( this.validFields() )
313        if( true )
314        {
315            var numCurrent = this.numRequest;
316            var z = 1;
317
318            //suppression onglet et form et controles calendrier caché
319            $( "#all_" + numCurrent ).remove();
320            $( "#tab_request" + numCurrent ).remove();
321            AnyTime.noPicker( "iobservation_date_" + numCurrent );
322            AnyTime.noPicker( "ira_" + numCurrent );
323
324            this.tabActive.numTab = "1";
325            this.numRequest = "1";
326            // this.nbRequest--;
327            if( 1 >= this.nbRequest )
328                this.delRequestButton.disable();
329
330            if( 9 == this.nbRequest ) this.addRequestButton.disable();
331            else this.addRequestButton.enable();
332
333            for( var i = 1; i <= this.nbRequest; i++ )
334            {
335                if( i > numCurrent )
336                {
337                    z = i - 1;
338                    document.getElementById( "all_" + i ).id = "all_" + z;
339                    $( "#tab_request" + i ).html( "Request " + z );
340                    $( "#tab_request" + i ).attr( {name:z} );
341                    //document.getElementById("tab_request"+i).name=z;
342                    document.getElementById( "tab_request" + i ).id = "tab_request" + z;
343                    document.getElementById( "tabObservation_" + i ).id = "tabObservation_" + z;
344                    document.getElementById( "select_iobservatory_" + i ).id = "select_iobservatory_" + z;
345                    document.getElementById( "select_ispectral_choice_" + i ).id = "select_ispectral_choice_" + z;
346                    document.getElementById( "iminspectral_ranger_" + i ).id = "iminspectral_ranger_" + z;
347                    document.getElementById( "imaxspectral_ranger_" + i ).id = "imaxspectral_ranger_" + z;
348                    document.getElementById( "select_ifunction_" + i ).id = "select_ifunction_" + z;
349                    document.getElementById( "select_icr_" + i ).id = "select_icr_" + z;
350                    document.getElementById( "ide_" + i ).id = "ide_" + z;
351                    document.getElementById( "iza_" + i ).id = "iza_" + z;
352                    document.getElementById( "irp_" + i ).id = "irp_" + z;
353                    document.getElementById( "isr_" + i ).id = "isr_" + z;
354                    document.getElementById( "select_iformat_" + i ).id = "select_iformat_" + z;
355                    document.getElementById( "select_irextinction_" + i ).id = "select_irextinction_" + z;
356                    document.getElementById( "select_ih2oe_" + i ).id = "select_ih2oe_" + z;
357                    document.getElementById( "select_io2e_" + i ).id = "select_io2e_" + z;
358                    document.getElementById( "select_io3e_" + i ).id = "select_io3e_" + z;
359                    document.getElementById( "select_ico2e_" + i ).id = "select_ico2e_" + z;
360
361                    // Supression du calendrier puis re-création en insérant l'ancienne date
362                    var oldDate = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() );
363                    AnyTime.noPicker( "iobservation_date_" + i );
364                    this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, oldDate, false );
365                    document.getElementById( "iobservation_date_" + i ).id = "iobservation_date_" + z;
366
367                    // Idem pour les heures !!!
368                    // TODO : voir si besoin de parser les heures ou non
369//                    var oldTime = this.timeConverter.parse( $( "#ira_" + i ).val() );
370                    var oldTime = $( "#ira_" + i ).val();
371                    AnyTime.noPicker( "ira_" + i );
372                    this.createTime( $( "#tabObservation_" + z ), tapasTexts["label.ira"], "ira_" + z, oldTime, false );
373                    document.getElementById( "ira_" + i ).id = "ira_" + z;
374//                    z++;
375                }
376            }
377
378            this.nbRequest--;
379
380            //tabs
381            $( ".tab_class" ).removeClass( "activated" );
382            $( "#tab_request1" ).addClass( "activated" );
383
384            //formulaires
385            $( ".divAll" ).hide();
386            $( "#all_1" ).show();
387        }
388    },
389
390
391    onClickTab: function( event )
392    {
393        var realTabId = $( "#" + event.currentTarget.id ).attr( "name" );
394        var clickedDiv = event.data;
395
396        //tabs
397        $( ".tab_class" ).removeClass( "activated" );
398        clickedDiv.divContainer.addClass( "activated" );
399
400        //forms
401        $( ".divAll" ).hide();
402        $( "#all_" + realTabId ).show();
403
404        this.numRequest = realTabId;
405        this.tabActive.numTab = realTabId;
406
407        if( 1 == realTabId ) this.delRequestButton.disable();
408        else this.delRequestButton.enable();
409    },
410
411
412    // OTHERS ********************************************************
413    displayFileFormats: function( container, id )
414    {
415        var paramSelect = new Object();
416        paramSelect.id = "select_" + id;
417        paramSelect.parent = container;
418        this.selectFormats = new Select( paramSelect );
419        jQuery.each( this.jSonFileFormats, jQuery.proxy( function ( i, jsonFileFormat )
420        {
421            this.selectFormats.add( jsonFileFormat.value, jsonFileFormat.text );
422        }, this ) );
423        this.selectFormats.selectFirst( false );
424    },
425
426
427    displayObservatories: function( container, id )
428    {
429        var paramSelect = new Object();
430        paramSelect.id = "select_" + id;
431        paramSelect.parent = container;
432        this.selectObservatories = new Select( paramSelect );
433        //ajouter select vide avec add
434        this.selectObservatories.add( "-1", "-- " + tapasTexts["text.select"] + " --" );
435        jQuery.each( this.jSonObservatories, jQuery.proxy( function ( i, jsonObservatory )
436        {
437            this.selectObservatories.add( jsonObservatory.id, jsonObservatory.name );
438        }, this ) );
439        this.selectObservatories.selectFirst( true );
440    },
441
442
443    displaySpectralUnits: function( container, id )
444    {
445        var paramSelect = new Object();
446        paramSelect.id = "select_" + id;
447        paramSelect.parent = container;
448        this.selectSpectralUnits = new Select( paramSelect );
449        //ajouter select vide avec add
450        this.selectSpectralUnits.add( "-1", "-- " + tapasTexts["text.select"] + " --" );
451        jQuery.each( this.jSonSpectralUnits, jQuery.proxy( function ( i, jsonSpectralUnit )
452        {
453            this.selectSpectralUnits.add( jsonSpectralUnit.value, tapasTexts[jsonSpectralUnit.value] );
454            //this.selectSpectralUnits.add( jsonSpectralUnit.value, jsonSpectralUnit.value );
455        }, this ) );
456        this.selectSpectralUnits.selectFirst( true );
457    },
458
459    displayInstrumentalFunctions: function( container, id )
460    {
461        var paramSelect = new Object();
462        paramSelect.id = "select_" + id;
463        paramSelect.parent = container;
464        this.selectInstrumentalFunctions = new Select( paramSelect );
465        //ajouter select vide avec add
466        jQuery.each( this.jSonInstrumentalFunctions, jQuery.proxy( function ( i, jsonInstrumentalFunction )
467        {
468            this.selectInstrumentalFunctions.add( jsonInstrumentalFunction.value, tapasTexts[jsonInstrumentalFunction.text] );
469        }, this ) );
470        this.selectInstrumentalFunctions.selectFirst( true );
471    },
472
473
474    displayClimatoReferences: function( container, id )
475    {
476        var paramSelect = new Object();
477        paramSelect.id = "select_" + id;
478        paramSelect.parent = container;
479        this.selectClimatoReferences = new Select( paramSelect );
480        //ajouter select vide avec add
481        jQuery.each( this.jSonClimatoReferences, jQuery.proxy( function ( i, jsonClimatoReference )
482        {
483            this.selectClimatoReferences.add( jsonClimatoReference.value, tapasTexts[jsonClimatoReference.text] );
484        }, this ) );
485        this.selectClimatoReferences.selectFirst( true );
486    },
487
488
489    showErrors: function( result )
490    {
491        //this.containerErrors.show();
492        // this.containerErrors.html( tapasTexts[result.responseText] );
493    },
494
495
496
497    createForm: function()
498    {
499        this.divErreurs = $( document.createElement( "div" ) );
500        this.divErreurs.addClass( "errorsForm" );
501        this.divErreurs.hide();
502
503        var divAll = $( document.createElement( "div" ) );
504        divAll.attr( {id:"all_" + this.nbRequest, class:"divAll"} );
505
506
507        //Creation div
508        var divPreference = $( document.createElement( "div" ) );
509        var tabPreference = $( document.createElement( "table" ) );
510        tabPreference.attr( {cellspacing:3} );
511
512        var divObservation = $( document.createElement( "div" ) );
513        var tabObservation = $( document.createElement( "table" ) );
514        //tabObservation.attr({border:1});
515        tabObservation.attr( {id:"tabObservation_" + this.nbRequest, cellspacing:3} );
516
517
518        var divAtmosphere = $( document.createElement( "div" ) );
519        var tabAtmosphere = $( document.createElement( "table" ) );
520
521
522        var fieldSetObservation = $( document.createElement( "fieldset" ) );
523        fieldSetObservation.addClass( "cfs1" );
524        divObservation.append( fieldSetObservation );
525
526        var legendObservation = $( document.createElement( "legend" ) );
527        legendObservation.html( "Observation" );
528        fieldSetObservation.append( legendObservation );
529        legendObservation.addClass( "containerField" );
530
531        var fieldSetPreference = $( document.createElement( "fieldset" ) );
532        fieldSetPreference.addClass( "cfs2" );
533        divPreference.append( fieldSetPreference );
534
535        var legendPreference = $( document.createElement( "legend" ) );
536        legendPreference.html( tapasTexts["label.preferences"] );
537        fieldSetPreference.append( legendPreference );
538        legendPreference.addClass( "containerField" );
539
540        fieldSetObservation.append( tabObservation );
541        divObservation.addClass( "divObservation" );
542        divAll.append( divObservation );
543
544
545        divAtmosphere.append( tabAtmosphere );
546        //divAtmosphere.addClass("divAtmosphere");
547        //this.containerForm.append( divAtmosphere );
548        fieldSetObservation.append( divAtmosphere );
549
550        fieldSetPreference.append( tabPreference );
551        divPreference.addClass( "divPreference" );
552        divAll.append( divPreference );
553
554        this.containerForm.append( divAll );
555        this.containerForm.append( this.divErreurs );
556        //this.tabInput = new Array(3);
557
558        this.createTrList( tapasTexts["label.format"], "iformat_" + this.nbRequest, tabPreference, 'format' );
559        this.createTrList( tapasTexts["label.era"], "irextinction_" + this.nbRequest, tabPreference, 'yesno' );
560        this.createTrList( tapasTexts["label.eh2o"], "ih2oe_" + this.nbRequest, tabPreference, 'yesno' );
561        this.createTrList( tapasTexts["label.eo3"], "io3e_" + this.nbRequest, tabPreference, 'yesno' );
562        this.createTrList( tapasTexts["label.eo2"], "io2e_" + this.nbRequest, tabPreference, 'yesno' );
563        this.createTrList( tapasTexts["label.eco2"], "ico2e_" + this.nbRequest, tabPreference, 'yesno' );
564
565        this.createTrList( tapasTexts["label.observatory"], "iobservatory_" + this.nbRequest, tabObservation, 'observatories' );
566        this.createCalendar( tabObservation, tapasTexts["label.datemesure"], "iobservation_date_" + this.nbRequest, false, true );
567
568        //unite
569        this.createTrList( tapasTexts["label.spectralUnit"], "ispectral_choice_" + this.nbRequest, tabObservation, 'spectralUnit' );
570        this.createTr2Input( tapasTexts["label.spectralRange"], tapasTexts["label.to"], "iminspectral_ranger_" + this.nbRequest, "imaxspectral_ranger_" + this.nbRequest, tabObservation, "[350,2500] nm" );
571
572        //fonction instrumentale
573        this.createTrList( tapasTexts["label.ifunction"], "ifunction_" + this.nbRequest, tabObservation, "ilsf" );
574        //reference climato
575        //this.createTrList( tapasTexts["label.climato"], "icr", tabAtmosphere, "climatoReference" );
576        this.createTrList( tapasTexts["label.climato"], "icr_" + this.nbRequest, tabObservation, "climatoReference" );
577
578
579        //this.createTr( tapasTexts["label.ira"], "ira", tabObservation );
580        this.createTime( tabObservation, tapasTexts["label.ira"], "ira_" + this.nbRequest, false, true );
581        this.createTr( tapasTexts["label.ide"], "ide_" + this.nbRequest, tabObservation, "hh:mm:ss.ms [-90,90] &deg;" );
582        this.createTr( tapasTexts["label.iza"], "iza_" + this.nbRequest, tabObservation, "[0,90] &deg;" );
583
584        this.createTr( tapasTexts["label.resolution"], "irp_" + this.nbRequest, tabObservation, "" );
585        this.createTr( tapasTexts["label.ratio"], "isr_" + this.nbRequest, tabObservation, "" );
586
587
588        //jQuery.proxy permet d'envoyer le contexte this courant
589
590    },
591
592
593
594    createTapasObject: function()
595    {
596
597        var requests = new Array();
598
599        for( var i = 1; i <= this.nbRequest; i++ )
600        {
601            // PREFERENCE
602            var preference = new Object();
603
604            preference.format = new Object();
605            //toutes les valeurs possibles
606            preference.format.firstValue = this.selectFormats.getValuesInString();
607
608            //la valeur selectionnee
609            preference.format.secondValue = this.selectFormats.getValue();
610
611            preference.rayleighExtinction = new Object();
612            preference.rayleighExtinction.firstValue = this.select_ih2oe.getValuesInString();
613            preference.rayleighExtinction.secondValue = this.select_irextinction.getValue();
614
615
616            preference.h2oExtinction = new Object();
617            preference.h2oExtinction.firstValue = this.select_ih2oe.getValuesInString();
618            preference.h2oExtinction.secondValue = this.select_ih2oe.getValue();
619
620
621            preference.o3Extinction = new Object();
622            preference.o3Extinction.firstValue = this.select_io3e.getValuesInString();
623            preference.o3Extinction.secondValue = this.select_io3e.getValue();
624
625            preference.o2Extinction = new Object();
626            preference.o2Extinction.firstValue = this.select_io2e.getValuesInString();
627            preference.o2Extinction.secondValue = this.select_io2e.getValue();
628
629            preference.co2Extinction = new Object();
630            preference.co2Extinction.firstValue = this.select_ico2e.getValuesInString();
631            preference.co2Extinction.secondValue = this.select_ico2e.getValue();
632
633
634            // OBSERVATION
635            var observatory = new Object();
636
637            //observatory.id = this.selectObservatories.getValue();
638            observatory.id = "3";
639
640            // Los
641            var los = new Object();
642
643
644            los.raJ2000 = $( "#ira_" + i ).val();
645            los.decJ2000 = $( "#ide_" + i ).val();
646
647
648            los.zenithAngle = $( "#iza_" + i ).val();
649
650
651            // Instrument
652            var instrument = new Object();
653
654            instrument.ilsfChoice = new Object();
655            instrument.ilsfChoice.firstValue = this.selectInstrumentalFunctions.getValuesInString();
656            instrument.ilsfChoice.secondValue = this.selectInstrumentalFunctions.getValue();
657
658            instrument.spectralChoice = new Object();
659
660            this.selectSpectralUnits.remove( "-1" );
661            instrument.spectralChoice.firstValue = this.selectSpectralUnits.getValuesInString();
662            instrument.spectralChoice.secondValue = this.selectSpectralUnits.getValue();
663
664            instrument.spectralRange = $( "#iminspectral_ranger_" + i ).val() + ' ' + $( "#imaxspectral_ranger_" + i ).val();
665
666
667            instrument.resolvingPower = new Object();
668            instrument.resolvingPower.firstValue = "0";
669            instrument.resolvingPower.secondValue = $( "#irp_" + i ).val();
670
671            instrument.samplingRatio = new Object();
672            instrument.samplingRatio.firstValue = "0";
673            instrument.samplingRatio.secondValue = $( "#isr_" + i ).val();
674
675            var observation = new Object();
676            observation.date = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() );
677            observation.observatory = observatory;
678
679            observation.los = los;
680            observation.instrument = instrument;
681
682
683            // ATMOSPHERE
684            var atmosphere = new Object();
685
686            atmosphere.reference = new Object();
687            atmosphere.reference.firstValue = this.selectClimatoReferences.getValuesInString();
688            atmosphere.reference.secondValue = this.selectClimatoReferences.getValue();
689
690
691            // REQUEST
692            var request = new Object();
693            request.id = i;
694            request.preference = preference;
695            request.observation = observation;
696            request.atmosphere = atmosphere;
697
698            requests[i] = request;
699        }
700
701        // TAPAS
702        var tapas = new Object();
703        tapas.requests = requests;
704
705
706        return tapas;
707    },
708
709    validFields: function()
710    {
711        return (
712                isSup( this.selectObservatories.getValue(), 0, tapasTexts["label.observatory"], tapasTexts["text.toselect"], this.containerErrors ) &&
713                        isDiff( this.selectSpectralUnits.getValue(), -1, tapasTexts["label.spectralUnit"], tapasTexts["text.toselect"] ) &&
714                        isValidRange( $( "#iminspectral_ranger" ).val(), $( "#imaxspectral_ranger" ).val(), this.selectSpectralUnits.getValue(), tapasTexts["label.spectralRange"], tapasTexts["text.badvalue"] ) &&
715                        isDeg( $( "#ide" ).val(), tapasTexts["label.ide"], tapasTexts["text.badvalue"] ) &&
716                        isValidNum( $( "#iza" ).val(), tapasTexts["label.iza"], tapasTexts["text.badvalue"] ) && isBetween( $( "#iza" ).val(), 0, 90, tapasTexts["label.iza"], tapasTexts["text.badvalue"] ) &&
717                        isValidNum( $( "#irp" ).val(), tapasTexts["label.resolution"], tapasTexts["text.badvalue"] ) && isSup( $( "#irp" ).val(), 1, tapasTexts["label.resolution"], tapasTexts["text.badvalue"] ) &&
718                        isValidNum( $( "#isr" ).val(), tapasTexts["label.ratio"], tapasTexts["text.badvalue"] ) && isSup( $( "#isr" ).val(), 1, tapasTexts["label.ratio"], tapasTexts["text.badvalue"] )
719                )
720    }
721
722
723    /*,
724
725     isEmpty: function(string){
726     return (string.trim()=='');
727     },
728
729
730     isMail: function(email){
731     return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email));
732     },
733
734
735     isInt: function(number){
736     return (/^[0-9]+$/.test(number));
737     },
738
739
740     isFloat: function(number){
741     return (/^[0-9]+(\.[0-9]+)?$/.test(number));
742     },
743
744
745     isIP: function(ip){
746     return (/^(([0-2]*[0-9]+[0-9]+)\.([0-2]*[0-9]+[0-9]+)\.([0-2]*[0-9]+[0-9]+)\.([0-2]*[0-9]+[0-9]+))$/.test(ip));
747     },
748
749
750
751     isURL: function(string){
752     return (/^(((ht|f)tp(s?))\:\/\/)([0-9a-zA-Z\-]+\.)+[a-zA-Z]{2,6}(\:[0-9]+)?(\/\S*)?$/.test(string.toLowerCase()));
753     },
754
755     isValidNum: function(number) {
756     if (!this.isEmpty(number) && this.isFloat(number)) return true;
757     else return false;
758     }*/
759
760
761} );
762
763
764</script>
Note: See TracBrowser for help on using the repository browser.