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

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

selects récupération des valeurs

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