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

Last change on this file since 500 was 500, checked in by rboipsl, 12 years ago

modif onglet + erreurs

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.name = id;
417        paramSelect.parent = container;
418        this.selectObservatories = new Select( paramSelect );
419        //ajouter select vide avec add
420        this.selectObservatories.add( "-1", "-- " + tapasTexts["text.select"] + " --" );
421        jQuery.each( this.jSonObservatories, jQuery.proxy( function ( i, jsonObservatory )
422        {
423            this.selectObservatories.add( jsonObservatory.id, jsonObservatory.name );
424        }, this ) );
425        this.selectObservatories.selectFirst( true );
426    },
427
428
429    displaySpectralUnits: function( container, id )
430    {
431        var paramSelect = new Object();
432        paramSelect.id = "select_" + id;
433        paramSelect.parent = container;
434        this.selectSpectralUnits = new Select( paramSelect );
435        //ajouter select vide avec add
436        this.selectSpectralUnits.add( "-1", "-- " + tapasTexts["text.select"] + " --" );
437        jQuery.each( this.jSonSpectralUnits, jQuery.proxy( function ( i, jsonSpectralUnit )
438        {
439            this.selectSpectralUnits.add( jsonSpectralUnit.value, tapasTexts[jsonSpectralUnit.value] );
440            //this.selectSpectralUnits.add( jsonSpectralUnit.value, jsonSpectralUnit.value );
441        }, this ) );
442        this.selectSpectralUnits.selectFirst( true );
443    },
444
445    displayInstrumentalFunctions: function( container, id )
446    {
447        var paramSelect = new Object();
448        paramSelect.id = "select_" + id;
449        paramSelect.parent = container;
450        this.selectInstrumentalFunctions = new Select( paramSelect );
451        //ajouter select vide avec add
452        jQuery.each( this.jSonInstrumentalFunctions, jQuery.proxy( function ( i, jsonInstrumentalFunction )
453        {
454            this.selectInstrumentalFunctions.add( jsonInstrumentalFunction.value, tapasTexts[jsonInstrumentalFunction.text] );
455        }, this ) );
456        this.selectInstrumentalFunctions.selectFirst( true );
457    },
458
459
460    displayClimatoReferences: function( container, id )
461    {
462        var paramSelect = new Object();
463        paramSelect.id = "select_" + id;
464        paramSelect.parent = container;
465        this.selectClimatoReferences = new Select( paramSelect );
466        //ajouter select vide avec add
467        jQuery.each( this.jSonClimatoReferences, jQuery.proxy( function ( i, jsonClimatoReference )
468        {
469            this.selectClimatoReferences.add( jsonClimatoReference.value, tapasTexts[jsonClimatoReference.text] );
470        }, this ) );
471        this.selectClimatoReferences.selectFirst( true );
472    },
473
474
475    showErrors: function( result )
476    {
477        //this.containerErrors.show();
478        // this.containerErrors.html( tapasTexts[result.responseText] );
479    },
480
481
482
483    createForm: function()
484    {
485        this.divErreurs = $( document.createElement( "div" ) );
486        this.divErreurs.addClass( "errorsForm" );
487        this.divErreurs.hide();
488
489        var divAll = $( document.createElement( "div" ) );
490        divAll.attr( {id:"all_" + this.nbRequest, class:"divAll"} );
491
492
493        //Creation div
494        var divPreference = $( document.createElement( "div" ) );
495        var tabPreference = $( document.createElement( "table" ) );
496        tabPreference.attr( {cellspacing:3} );
497
498        var divObservation = $( document.createElement( "div" ) );
499        var tabObservation = $( document.createElement( "table" ) );
500        //tabObservation.attr({border:1});
501        tabObservation.attr( {id:"tabObservation_" + this.nbRequest, cellspacing:3} );
502
503
504        var divAtmosphere = $( document.createElement( "div" ) );
505        var tabAtmosphere = $( document.createElement( "table" ) );
506
507
508        var fieldSetObservation = $( document.createElement( "fieldset" ) );
509        fieldSetObservation.addClass( "cfs1" );
510        divObservation.append( fieldSetObservation );
511
512        var legendObservation = $( document.createElement( "legend" ) );
513        legendObservation.html( "Observation" );
514        fieldSetObservation.append( legendObservation );
515        legendObservation.addClass( "containerField" );
516
517        var fieldSetPreference = $( document.createElement( "fieldset" ) );
518        fieldSetPreference.addClass( "cfs2" );
519        divPreference.append( fieldSetPreference );
520
521        var legendPreference = $( document.createElement( "legend" ) );
522        legendPreference.html( tapasTexts["label.preferences"] );
523        fieldSetPreference.append( legendPreference );
524        legendPreference.addClass( "containerField" );
525
526        fieldSetObservation.append( tabObservation );
527        divObservation.addClass( "divObservation" );
528        divAll.append( divObservation );
529
530
531        divAtmosphere.append( tabAtmosphere );
532        //divAtmosphere.addClass("divAtmosphere");
533        //this.containerForm.append( divAtmosphere );
534        fieldSetObservation.append( divAtmosphere );
535
536        fieldSetPreference.append( tabPreference );
537        divPreference.addClass( "divPreference" );
538        divAll.append( divPreference );
539
540        this.containerForm.append( divAll );
541        this.containerForm.append( this.divErreurs );
542        //this.tabInput = new Array(3);
543
544        this.createTrList( tapasTexts["label.format"], "iformat_" + this.nbRequest, tabPreference, 'format' );
545        this.createTrList( tapasTexts["label.era"], "irextinction_" + this.nbRequest, tabPreference, 'yesno' );
546        this.createTrList( tapasTexts["label.eh2o"], "ih2oe_" + this.nbRequest, tabPreference, 'yesno' );
547        this.createTrList( tapasTexts["label.eo3"], "io3e_" + this.nbRequest, tabPreference, 'yesno' );
548        this.createTrList( tapasTexts["label.eo2"], "io2e_" + this.nbRequest, tabPreference, 'yesno' );
549        this.createTrList( tapasTexts["label.eco2"], "ico2e_" + this.nbRequest, tabPreference, 'yesno' );
550
551        this.createTrList( tapasTexts["label.observatory"], "iobservatory_" + this.nbRequest, tabObservation, 'observatories' );
552        this.createCalendar( tabObservation, tapasTexts["label.datemesure"], "iobservation_date_" + this.nbRequest, false, true );
553
554        //unite
555        this.createTrList( tapasTexts["label.spectralUnit"], "ispectral_choice_" + this.nbRequest, tabObservation, 'spectralUnit' );
556        this.createTr2Input( tapasTexts["label.spectralRange"], tapasTexts["label.to"], "iminspectral_ranger_" + this.nbRequest, "imaxspectral_ranger_" + this.nbRequest, tabObservation, "[350,2500] nm" );
557
558        //fonction instrumentale
559        this.createTrList( tapasTexts["label.ifunction"], "ifunction_" + this.nbRequest, tabObservation, "ilsf" );
560        //reference climato
561        //this.createTrList( tapasTexts["label.climato"], "icr", tabAtmosphere, "climatoReference" );
562        this.createTrList( tapasTexts["label.climato"], "icr_" + this.nbRequest, tabObservation, "climatoReference" );
563
564
565        //this.createTr( tapasTexts["label.ira"], "ira", tabObservation );
566        this.createTime( tabObservation, tapasTexts["label.ira"], "ira_" + this.nbRequest, false, true );
567        this.createTr( tapasTexts["label.ide"], "ide_" + this.nbRequest, tabObservation, "hh:mm:ss.ms [-90,90] &deg;" );
568        this.createTr( tapasTexts["label.iza"], "iza_" + this.nbRequest, tabObservation, "[0,90] &deg;" );
569
570        this.createTr( tapasTexts["label.resolution"], "irp_" + this.nbRequest, tabObservation, "" );
571        this.createTr( tapasTexts["label.ratio"], "isr_" + this.nbRequest, tabObservation, "" );
572
573
574        //jQuery.proxy permet d'envoyer le contexte this courant
575
576    },
577
578
579
580    createTapasObject: function()
581    {
582
583        var requests = new Array();
584
585        for( var i = 1; i <= this.nbRequest; i++ )
586        {
587            // PREFERENCE
588            var preference = new Object();
589
590            preference.format = new Object();
591            //toutes les valeurs possibles
592            preference.format.firstValue = this.selectFormats.getValuesInString();
593
594            //la valeur selectionnee
595//            preference.format.secondValue = this.selectFormats.getValue();
596            preference.format.secondValue = $( "#select_iformat_" + i )[0].textContent;
597
598            preference.rayleighExtinction = new Object();
599            preference.rayleighExtinction.firstValue = this.select_irextinction.getValuesInString();
600//            preference.rayleighExtinction.secondValue = this.select_irextinction.getValue();
601            preference.rayleighExtinction.secondValue = $( "#select_irextinction_" + i )[0].textContent;
602
603            preference.h2oExtinction = new Object();
604            preference.h2oExtinction.firstValue = this.select_ih2oe.getValuesInString();
605//            preference.h2oExtinction.secondValue = this.select_ih2oe.getValue();
606            preference.h2oExtinction.secondValue = $( "#select_ih2oe_" + i )[0].textContent;
607
608            preference.o3Extinction = new Object();
609            preference.o3Extinction.firstValue = this.select_io3e.getValuesInString();
610//            preference.o3Extinction.secondValue = this.select_io3e.getValue();
611            preference.o3Extinction.secondValue = $( "#select_io3e_" + i )[0].textContent;
612
613            preference.o2Extinction = new Object();
614            preference.o2Extinction.firstValue = this.select_io2e.getValuesInString();
615//            preference.o2Extinction.secondValue = this.select_io2e.getValue();
616            preference.o2Extinction.secondValue = $( "#select_io2e_" + i )[0].textContent;
617
618            preference.co2Extinction = new Object();
619            preference.co2Extinction.firstValue = this.select_ico2e.getValuesInString();
620//            preference.co2Extinction.secondValue = this.select_ico2e.getValue();
621            preference.co2Extinction.secondValue = $( "#select_ico2e_" + i )[0].textContent;
622
623
624            // OBSERVATION
625            var observatory = new Object();
626//            observatory.id = this.selectObservatories.getValue();
627            observatory.id = $( "#select_iobservatory_" + i )[0].textContent;
628
629            // Los
630            var los = new Object();
631            los.raJ2000 = $( "#ira_" + i ).val();
632            los.decJ2000 = $( "#ide_" + i ).val();
633            los.zenithAngle = $( "#iza_" + i ).val();
634
635            // Instrument
636            var instrument = new Object();
637            instrument.ilsfChoice = new Object();
638            instrument.ilsfChoice.firstValue = this.selectInstrumentalFunctions.getValuesInString();
639            instrument.ilsfChoice.secondValue = this.selectInstrumentalFunctions.getValue();
640
641            this.selectSpectralUnits.remove( "-1" );
642            instrument.spectralChoice = new Object();
643            instrument.spectralChoice.firstValue = this.selectSpectralUnits.getValuesInString();
644            instrument.spectralChoice.secondValue = this.selectSpectralUnits.getValue();
645
646            instrument.spectralRange = $( "#iminspectral_ranger_" + i ).val() + ' ' + $( "#imaxspectral_ranger_" + i ).val();
647
648            instrument.resolvingPower = new Object();
649            instrument.resolvingPower.firstValue = "0";
650            instrument.resolvingPower.secondValue = $( "#irp_" + i ).val();
651
652            instrument.samplingRatio = new Object();
653            instrument.samplingRatio.firstValue = "0";
654            instrument.samplingRatio.secondValue = $( "#isr_" + i ).val();
655
656            var observation = new Object();
657            observation.date = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() );
658            observation.observatory = observatory;
659
660            observation.los = los;
661            observation.instrument = instrument;
662
663            // ATMOSPHERE
664            var atmosphere = new Object();
665
666            atmosphere.reference = new Object();
667            atmosphere.reference.firstValue = this.selectClimatoReferences.getValuesInString();
668            atmosphere.reference.secondValue = this.selectClimatoReferences.getValue();
669
670
671            // REQUEST
672            var request = new Object();
673            request.id = i;
674            request.preference = preference;
675            request.observation = observation;
676            request.atmosphere = atmosphere;
677
678            requests[i-1] = request;
679        }
680
681        // TAPAS
682        var tapas = new Object();
683        tapas.requests = requests;
684        return tapas;
685    },
686
687    validFields: function()
688    {
689        var testOk = isSup( this.selectObservatories.getValue(), 0 );
690        if( !testOk )
691        {
692            this.containerErrors.html( tapasTexts["label.observatory"] + " : " + tapasTexts["text.toselect"] );
693            this.containerErrors.show();
694            return false;
695        }
696
697        testOk = isDiff( this.selectSpectralUnits.getValue(), -1 );
698        if( !testOk )
699        {
700            this.containerErrors.html( tapasTexts["label.spectralUnit"] + " : " + tapasTexts["text.toselect"] );
701            this.containerErrors.show();
702            return false;
703        }
704
705        testOk = isValidRange( $( "#iminspectral_ranger" ).val(), $( "#imaxspectral_ranger" ).val(), this.selectSpectralUnits.getValue() );
706        if( !testOk )
707        {
708            this.containerErrors.html( tapasTexts["label.spectralRange"] + " : " + tapasTexts["text.badvalue"] );
709            this.containerErrors.show();
710            return false;
711        }
712
713        testOk = isDeg( $( "#ide" ).val() );
714        if( !testOk )
715        {
716            this.containerErrors.html( tapasTexts["label.ide"] + " : " + tapasTexts["text.badvalue"] );
717            this.containerErrors.show();
718            return false;
719        }
720
721        testOk = isValidNum( $( "#iza" ).val() );
722        if( !testOk )
723        {
724            this.containerErrors.html( tapasTexts["label.iza"] + " : " + tapasTexts["text.badvalue"] );
725            this.containerErrors.show();
726            return false;
727        }
728
729        testOk = isBetween( $( "#iza" ).val(), 0, 90 );
730        if( !testOk )
731        {
732            this.containerErrors.html( tapasTexts["label.iza"] + " : " + tapasTexts["text.badvalue"] );
733            this.containerErrors.show();
734            return false;
735        }
736
737        testOk = isValidNum( $( "#irp" ).val() );
738        if( !testOk )
739        {
740            this.containerErrors.html( tapasTexts["label.resolution"] + " : " + tapasTexts["text.badvalue"] );
741            this.containerErrors.show();
742            return false;
743        }
744
745        testOk = isSup( $( "#irp" ).val(), 1 );
746        if( !testOk )
747        {
748            this.containerErrors.html( tapasTexts["label.resolution"] + " : " + tapasTexts["text.badvalue"] );
749            this.containerErrors.show();
750            return false;
751        }
752
753        testOk = isValidNum( $( "#isr" ).val() );
754        if( !testOk )
755        {
756            this.containerErrors.html( tapasTexts["label.ratio"] + " : " + tapasTexts["text.badvalue"] );
757            this.containerErrors.show();
758            return false;
759        }
760
761        testOk = isSup( $( "#isr" ).val(), 1 );
762        if( !testOk )
763        {
764            this.containerErrors.html( tapasTexts["label.ratio"] + " : " + tapasTexts["text.badvalue"] );
765            this.containerErrors.show();
766            return false;
767        }
768    },
769
770    updateButtons: function()
771    {
772        if( 1 < this.nbRequest )
773            this.delRequestButton.enable();
774        else
775            this.delRequestButton.disable();
776
777        if( 9 <= this.nbRequest )
778            this.addRequestButton.disable();
779        else
780            this.addRequestButton.enable();
781    }
782
783} );
784
785</script>
Note: See TracBrowser for help on using the repository browser.