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

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

double ouahou
onglets validés
remise observatoires

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