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

Last change on this file since 779 was 779, checked in by rboipsl, 10 years ago

Dernière version rboipsl

File size: 55.8 KB
RevLine 
[779]1<script src="js/library/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script>
[382]2<script type="text/javascript">
[489]3
4
[439]5var InterfaceTapas = Class.create( {
[496]6    initialize: function( jsonFileFormats, jsonYesNos, jsonObservatories, jsonSpectralUnits, jsonInstrumentalFunctions, jsonClimatoReferences )
[439]7    {
8        /** *********** CONTAINERS *********** **/
9        this.containerForm = $( "#formulaire" );
[504]10        //this.containerErrors = $( "#errForm" );
11        //this.divE= $( "#divErreurs");
[481]12        this.containerCenter = $( "#containerCenter" );
[490]13        this.containerTabs = $( "#tab" );
[382]14
[497]15        /** *********** VARIABLES *********** **/
[444]16        this.jSonFileFormats = jsonFileFormats || null;
[501]17        this.selectFileFormatsList = new Object();
[502]18
[444]19        this.jSonYesNos = jsonYesNos || null;
[502]20        this.select_ih2oeList = new Object();
21        this.select_io2eList = new Object();
22        this.select_io3eList = new Object();
23        this.select_ico2eList = new Object();
[779]24        this.select_ich4eList = new Object();
25        this.select_in2oeList = new Object();
[502]26        this.select_irextinctionList = new Object();
[767]27        this.select_ibervCList = new Object();
[501]28
[496]29        this.jSonObservatories = jsonObservatories || false;
[501]30        this.selectObservatoriesList = new Object();
[444]31        this.jSonSpectralUnits = jsonSpectralUnits || null;
[501]32        this.selectSpectralUnitsList = new Object();
[444]33        this.jSonInstrumentalFunctions = jsonInstrumentalFunctions || null;
[501]34        this.selectInstrumentalFunctionsList = new Object();
[444]35        this.jSonClimatoReferences = jsonClimatoReferences || null;
[501]36        this.selectClimatoReferencesList = new Object();
[490]37        this.nbRequest = 1;
38        this.tabActive = false;
[494]39        this.numRequest = 1;
[419]40
[767]41        this.language = tapasTexts["language"] ;
42        this.browser="Firefox";
43
44        if (navigator.userAgent.indexOf('Firefox') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox') + 8)) >= 3.6){
45            this.browser="Firefox";
46        }
47        else if (navigator.userAgent.indexOf('Chrome') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Chrome') + 7).split(' ')[0]) >= 15){
48            this.browser="Chrome";
49        }
50        else if(navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Version') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Version') + 8).split(' ')[0]) >= 5){
51            this.browser="Safari";
52        }
53
[501]54        // Buttons
[490]55        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 )} );
[504]56        this.addRequestButton = new Button( {title:tapasTexts["label.title.add"],value:tapasTexts["label.addButton"], parent:this.containerCenter, id:"button_add", className: "positive", onClick:jQuery.proxy( this.onClickAdd, this )} );
57        this.delRequestButton = new Button( {title:tapasTexts["label.title.del"],value:tapasTexts["label.delButton"], parent:this.containerCenter, id:"button_del", className: "negative", onClick:jQuery.proxy( this.onClickDel, this )} );
[490]58        this.delRequestButton.disable();
59
[439]60        this.createForm();
[490]61        this.tabActive = this.createTab();
[504]62        this.divE = $( document.createElement( "div" ) );
63        this.divE.attr( {id:"divErrors", class:"errorsForm"} );
64        /*var fieldSetE = $( document.createElement( "fieldset" ) );
65         fieldSetE.addClass( "cfs3" );
66         this.divE.append( fieldSetE );*/
[497]67
[504]68        this.containerForm.append( this.divE );
69        //this.containerErrors.hide();
70        this.divE.hide();
71
[511]72        /** *********** LOADING *********** **/
73        var param = new Object();
74        param.id = "loadingForRequest";
75        param.parent = this.containerForm;
76        param.className = "loading-classic";
77        this.loadingRequest = new Loading( param );
[515]78        //this.loadingRequest.display();
[439]79    },
[382]80
[419]81
[439]82    // CREATES ********************************************************
[490]83    createTab:function()
[439]84    {
[493]85        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]86        ntab.active();
87        return ntab;
88    },
89
90
[495]91    createCalendar: function( containerCalendar, texte, inputDateId, currentDate, isTrToCreate )
[490]92    {
[495]93        if( isTrToCreate )
94        {
95            // Create input for date text
96            var tr = $( document.createElement( "tr" ) );
97            var td1 = $( document.createElement( "td" ) );
98            var td2 = $( document.createElement( "td" ) );
99            var inputDate = $( document.createElement( "input" ) );
100            inputDate.attr( {id:inputDateId, size:"17"} );
[419]101
[495]102            td1.html( texte );
103            td1.attr( { class:"containerLabel" } );
104            tr.append( td1 );
[481]105
[495]106            td2.attr( {colspan:4} );
107            td2.append( inputDate );
108            tr.append( td2 );
109            containerCalendar.append( tr );
110        }
[481]111
[439]112        // Calendar
113        this.calendarFormat = "%Y-%m-%d %H:%i:%s";
114        this.calendarConverter = new AnyTime.Converter( { format: this.calendarFormat } );
[419]115
[439]116        AnyTime.picker( inputDateId, { format: this.calendarFormat, firstDOW: 1,
117            labelTitle: "Select Date", labelYear: "Year", labelMonth: "Month", labelDayOfMonth: "Day",
118            labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second"
119        } );
[419]120
[495]121        // Ajout de la date courrante ds le calendrier SI currentDate non précisée
122        if( !currentDate )
123            currentDate = new Date();
[504]124
[529]125
[490]126        $( "#" + inputDateId ).val( this.calendarConverter.format( currentDate ) );
127        $( "#" + inputDateId ).addClass( "calendar" );
128
[439]129    },
[419]130
[489]131
132    // CREATES ********************************************************
[529]133    createTime: function( containerCalendar, texte, inputDateId, currentTime, isTrToCreate, text2 )
[439]134    {
[495]135        if( isTrToCreate )
136        {
[529]137
[495]138            // Create input for date text
139            var tr = $( document.createElement( "tr" ) );
140            var td1 = $( document.createElement( "td" ) );
141            var td2 = $( document.createElement( "td" ) );
[529]142            var td3 = $( document.createElement( "td" ) );
[495]143            var inputDate = $( document.createElement( "input" ) );
144            inputDate.attr( {id:inputDateId, size:"10"} );
[489]145
[495]146            td1.html( texte );
147            td1.attr( { class:"containerLabel" } );
148            tr.append( td1 );
[489]149
[529]150            td2.attr( {colspan:1} );
[495]151            td2.append( inputDate );
152            tr.append( td2 );
[529]153
154            td3.html( text2 );
155            td3.attr( { class:"containerLabel2" } );
156            tr.append( td3 );
157
[495]158            containerCalendar.append( tr );
159        }
[489]160
[490]161        // Time
162        this.timeFormat = "%H:%i:%s";
163        this.timeConverter = new AnyTime.Converter( { format: this.timeFormat } );
[489]164
[490]165        AnyTime.picker( inputDateId, { format: this.timeFormat, firstDOW: 1,
[489]166            labelTitle: "Select hour", labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second"
167        } );
168
[495]169        if( !currentTime )
170            currentTime = "00:00:00";
[497]171        // TODO : voir si besoin de convertir format des heures
[495]172//        $( "#" + inputDateId ).val( this.timeConverter.format( currentTime ) );
173        $( "#" + inputDateId ).val( currentTime );
[490]174        $( "#" + inputDateId ).addClass( "time" );
[489]175    },
176
[490]177
[767]178    createTr: function( texte, inputId, container, textesup, event, champ, ctnb, info )
[489]179    {
[767]180
[489]181        var tr = $( document.createElement( "tr" ) );
182        var td1 = $( document.createElement( "td" ) );
183        var td2 = $( document.createElement( "td" ) );
184        var td3 = $( document.createElement( "td" ) );
[439]185        var input = $( document.createElement( "input" ) );
[419]186
[529]187        input.attr( {id: inputId, class:"containerText"+ctnb, size:11} );
[419]188
[529]189
190        if (event.length > 0) input.bind( event, [this, champ], this.angleChoice );
191
[779]192
[481]193        td1.attr( {class:"containerLabel"} );
[489]194
195        td3.html( textesup );
196        td3.attr( {class:"containerLabel2", colspan:3} );
[439]197        tr.append( td1 );
198        td2.append( input );
[444]199
[439]200        tr.append( td2 );
[489]201        tr.append( td3 );
[439]202        container.append( tr );
[444]203
[767]204        var re1 = new RegExp("isr_");
205        var re2 = new RegExp("irp_");
206
207        if (info && (inputId.match(re1) || inputId.match(re2))) {
208
209            var img = $( document.createElement( "img" ) );
210            var a = $( document.createElement( "a" ) );
211            var div = $( document.createElement( "div" ) );
212            img.attr("src","resources/images/info.png");
213            img.attr("width","19");
214            a.attr("style","cursor:pointer");
215
216            img.bind("click",[inputId,450,100,this],this.onClickInfos);
217            a.append(img);
218            div.append(a);
219
[779]220
221            td1.append( a );
222            td1.append( texte );
[767]223            tr.append( div );
224
225        }
226        else if (info) {
227            var img = $( document.createElement( "img" ) );
228            var a = $( document.createElement( "a" ) );
229            img.attr("src","resources/images/info.png");
230            img.attr("width","19");
231            a.attr("style","cursor:pointer");
232            img.bind("click",[inputId,450,100,this],this.onClickInfos);
233            a.append(img);
[779]234            td1.append(a);
235            td1.append( texte );
[767]236
237        }
[439]238    },
[419]239
[529]240
241    createTrTxt: function( texte, container )
242    {
243            var tr = $( document.createElement( "tr" ) );
244            var td1 = $( document.createElement( "td" ) );
245
246            td1.html( texte );
247            td1.attr( {class:"containerLabelT", colspan:4} );
248
249            tr.append( td1 );
250            container.append( tr );
251
[767]252
[529]253    },
254
255
256
[489]257    createTr2Input: function( texte1, texte2, inputId1, inputId2, container, textesup )
[444]258    {
259        var tr = $( document.createElement( "tr" ) );
260        var td1 = $( document.createElement( "td" ) );
261        var td2 = $( document.createElement( "td" ) );
262        var td3 = $( document.createElement( "td" ) );
263        var td4 = $( document.createElement( "td" ) );
[489]264        var td5 = $( document.createElement( "td" ) );
[767]265        var td6 = $( document.createElement( "td" ) );
[444]266        var input1 = $( document.createElement( "input" ) );
267        var input2 = $( document.createElement( "input" ) );
268
269
[489]270        input1.attr( {id: inputId1,class:"containerText",size:11} );
271        input2.attr( {id: inputId2,class:"containerText",size:11} );
[444]272
[779]273
[444]274        td3.html( texte2 );
[489]275        td5.html( textesup );
[767]276        var img = $( document.createElement( "img" ) );
277        var a = $( document.createElement( "a" ) );
278        img.attr("src","resources/images/info.png");
279        img.attr("width","19");
280        a.attr("style","cursor:pointer");
281        img.bind("click",["spectral_range",450,100,this],this.onClickInfos);
282        a.append(img);
[779]283        td1.append(a);
284         td1.append( texte1 );
[767]285
286        //img.onclick(this.onClickInfos("spectral_range",1200,440));
287
[490]288        td1.attr( {class:"containerLabel"} );
289        td3.attr( {class:"containerLabel3"} );
290        td5.attr( {class:"containerLabel2"} );
[489]291
[445]292        td2.append( input1 );
[481]293        //td2.html( texte2 );
[489]294        td4.append( input2 );
[444]295
[445]296        tr.append( td1 );
297        tr.append( td2 );
298        tr.append( td3 );
299        tr.append( td4 );
[489]300        tr.append( td5 );
[767]301        tr.append( td6 );
[445]302        container.append( tr );
[444]303    },
304
305
[490]306
[767]307    createTrList: function( texte, inputId, index, container, type, info )
[439]308    {
309        var tr = $( document.createElement( "tr" ) );
310        var td1 = $( document.createElement( "td" ) );
311        var td2 = $( document.createElement( "td" ) );
[779]312        var td3 = $( document.createElement( "td" ) );
[439]313        var input = $( document.createElement( "input" ) );
[779]314        var champ="";
[419]315
[767]316        var div = $( document.createElement( "div" ) );
317
[779]318
[439]319        input.attr( {id: inputId} );
[444]320
[779]321        // alert(inputId);
[767]322        if( 'format' == type ) {
323            this.displaySelect( td2, inputId, index, this.jSonFileFormats, this.selectFileFormatsList, false, null );
324            info = true;
325            champ = "iformat_";
[779]326
[767]327        }
[501]328        else
329        if( 'yesno' == type )
[466]330        {
[502]331            if( (/^(ih2oe_[1-9]+)$/.test( inputId )  ) )
332                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_ih2oeList, false, "yesNos" );
333            else if( (/^(io2e_[1-9]+)$/.test( inputId )  ) )
334                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_io2eList, false, "yesNos" );
335            else if( (/^(io3e_[1-9]+)$/.test( inputId )  ) )
336                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_io3eList, false, "yesNos" );
337            else if( (/^(ico2e_[1-9]+)$/.test( inputId )  ) )
338                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_ico2eList, false, "yesNos" );
[779]339            else if( (/^(ich4e_[1-9]+)$/.test( inputId )  ) )
340                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_ich4eList, false, "yesNos" );
341            else if( (/^(in2oe_[1-9]+)$/.test( inputId )  ) )
342                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_in2oeList, false, "yesNos" );
[767]343            else if( (/^(irextinction_[1-9]+)$/.test( inputId )  ) ) {
344
[502]345                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_irextinctionList, false, "yesNos" );
[767]346                info = true;
347                champ=inputId;
348            }
349            else if( (/^(ibervC_[1-9]+)$/.test( inputId )  ) ) {
350                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_ibervCList, false, "yesNos" );
351                info = true;
352                champ=inputId;
353            }
[466]354        }
[767]355        else if( 'observatories' == type ) {
356
[779]357            this.displaySelect1( td2, inputId, index, this.jSonObservatories, this.selectObservatoriesList, true, "observatories" );
358            //this.displaySelect( td2, inputId, index, this.jSonObservatories, this.selectObservatoriesList, true, "observatories" );
[767]359
360            champ="iobservatory_";
361        }
362        else if( 'spectralUnit' == type ) {
[501]363            this.displaySelect( td2, inputId, index, this.jSonSpectralUnits, this.selectSpectralUnitsList, true, "spectralUnits" );
[767]364            info = true;
365
366            champ = "ispectral_choice_";
367        }
368        else if( 'ilsf' == type ) {
[501]369            this.displaySelect( td2, inputId, index, this.jSonInstrumentalFunctions, this.selectInstrumentalFunctionsList, false, "instrumentalFunctions" );
[767]370            info = true;
371            champ = "ifunction_";
372        }
373        else if( 'climatoReference' == type ) {
[501]374            this.displaySelect( td2, inputId, index, this.jSonClimatoReferences, this.selectClimatoReferencesList, false, "climatoReferences" );
[767]375            info = true;
376            champ = "icr_";
377        }
378
[779]379        td1.attr( {class:"containerLabel"} );
380        tr.append( td1 );
[767]381
382
383        if (info) {
384            var img = $( document.createElement( "img" ) );
385            var a = $( document.createElement( "a" ) );
386            img.attr("src","resources/images/info.png");
387            img.attr("width","19");
388            a.attr("style","cursor:pointer");
389
390            img.bind("click",[champ,450,100,this],this.onClickInfos);
391            a.append(img);
392            div.append(a);
393
[779]394
395            td2.attr( {colspan:5} );
396            td1.append( a );
397            td1.append( texte );
398
[767]399            tr.append( td2 );
[779]400
[767]401        }
402        else {
[779]403            td1.append( texte );
[767]404            td2.attr( {colspan:3} );
405            tr.append( td2 );
406        }
[439]407        container.append( tr );
408    },
[382]409
[419]410
[439]411    // REQUESTS ********************************************************
412    requestCreateXML: function()
413    {
[440]414        var tapasForm = this.createTapasObject();
[439]415        //passage de javascript a json grace au jquery
416        var jsonTapasForm = $.toJSON( tapasForm );
[396]417
[470]418
[439]419        if( jsonTapasForm )
420            $.ajax( {
421                url: "data?methodName=createUserRequest&jsonTapas=" + jsonTapasForm,
422                success:jQuery.proxy( this.handleCreateXML, this ),
423                error: jQuery.proxy( this.showErrors, this )
424            } );
[504]425
[439]426    },
[419]427
[490]428
[439]429    // HANDLES ******************************************************** = retours ajax
430    handleCreateXML: function( result )
431    {
[511]432        this.loadingRequest.hide();
[515]433        //this.loadingRequest.display();
[511]434
[504]435        var res = jQuery.parseJSON( result ).result;
[767]436
[439]437    },
[419]438
439
[439]440    // EVENTS ********************************************************
[767]441    onClickInfos: function(param)
442    {
443
444        var parametre=param.data[0];
445        var width=param.data[1];
446        var height=param.data[2];
447        var context=param.data[3];
448
449        if ("spectral_range" == parametre) {
450            width=600;
451            height=150;
452            var titre = "D&eacute;finition de l'intervalle spectral pour le calcul.";
453            var pageInfo = "resources/doc/infosSpectralRange_fr.txt";
454
455            if( "fr" != context.language ) {
456                titre = "Definition of spectral interval for the computation.";
457                pageInfo = "resources/doc/infosSpectralRange_en.txt";
458                width=600;
459                height=100;
460            }
461
462        }
463
464        if ("ispectral_choice_" == parametre) {
465            var titre = "Unit&eacute; spectrale";
466            var pageInfo = "resources/doc/infosSpectralUnit_fr.txt";
467            width=600;
468            height=450;
469            if( "fr" != context.language ) {
470                titre = "Spectral unit";
471                pageInfo = "resources/doc/infosSpectralUnit_en.txt";
472                width=500;
473                height=500;
474            }
475        }
476
477        var re = new RegExp("irp_");
478        if (parametre.match(re)) {
479            var titre = "R&eacute;solution";
480            var pageInfo = "resources/doc/infosResolution_fr.txt";
481            width=600;
482            height=200;
483            if( "fr" != context.language ) {
484                titre = "Resolution power";
485                pageInfo = "resources/doc/infosResolution_en.txt";
486                width=500;
487                height=200;
488            }
489        }
490
491        var re = new RegExp("isr_");
492        if (parametre.match(re)) {
493            var titre = "Taux d'&eacute;chantillonnage";
494            var pageInfo = "resources/doc/infosSamplingRatio_fr.txt";
495            width=600;
496            height=100;
497            if( "fr" != context.language ) {
498                titre = "Sampling Ratio";
499                pageInfo = "resources/doc/infosSamplingRatio_en.txt";
500                width=500;
501                height=100;
502            }
503        }
504
505       var re = new RegExp("ibervC_");
506        if (parametre.match(re)) {
507            var titre = "Correction BERV";
508            var pageInfo = "resources/doc/infosBERV_fr.txt";
509            width=950;
510            height=700;
511            if( "fr" != context.language ) {
512                titre = "BERV correction";
513                pageInfo = "resources/doc/infosBERV_en.txt";
514                width=950;
515                height=700;
516            }
517        }
518
519        var re = new RegExp("ira_");
520        if (parametre.match(re)) {
521            var titre = "LOS Ascension Droite";
522            var pageInfo = "resources/doc/infosLOSRA_fr.txt";
523            width=600;
524            height=100;
525            if( "fr" != context.language ) {
526                titre = "LOS Right Ascension";
527                pageInfo = "resources/doc/infosLOSRA_en.txt";
528                width=500;
529                height=100;
530            }
531        }
532
533        var re = new RegExp("ide_");
534        if (parametre.match(re)) {
535            var titre = "LOS D&eacute;clinaison";
536            var pageInfo = "resources/doc/infosLOSD_fr.txt";
537            width=600;
538            height=100;
539            if( "fr" != context.language ) {
540                titre = "LOS Declination";
541                pageInfo = "resources/doc/infosLOSD_en.txt";
542                width=600;
543                height=100;
544            }
545        }
546
547        var re = new RegExp("iza_");
548        if (parametre.match(re)) {
549            var titre = "Angle z&eacute;nithal";
550            var pageInfo = "resources/doc/infosZenithalAngle_fr.txt";
551            width=600;
552            height=100;
553            if( "fr" != context.language ) {
554                titre = "Zenithal angle";
555                pageInfo = "resources/doc/infosZenithalAngle_en.txt";
556                width=600;
557                height=100;
558            }
559        }
560
561        var re = new RegExp("isr_");
562        if (parametre.match(re)) {
563            var titre = "Taux d'&eacute;chantillonnage";
564            var pageInfo = "resources/doc/infosSamplingRatio_fr.txt";
565            width=600;
566            height=100;
567            if( "fr" != context.language ) {
568                titre = "Sampling Ratio";
569                pageInfo = "resources/doc/infosSamplingRatio_en.txt";
570                width=500;
571                height=100;
572            }
573        }
574
575        var re = new RegExp("irextinction_");
576        if (parametre.match(re)) {
577            var titre = "S&eacute;lection des composants atmsoph&eacute;riques";
578            var pageInfo = "resources/doc/infosSpecies_fr.txt";
579            width=600;
580            height=350;
581            if( "fr" != context.language ) {
582                titre = "Selection of atmospheric constituents";
583                pageInfo = "resources/doc/infosSpecies_en.txt";
584                width=600;
585                height=300;
586            }
587        }
588
589        if ("icr_" == parametre) {
590            var titre = "Mod&egrave;le atmosph&eacute;rique";
591            var pageInfo = "resources/doc/infosAtmosphericModel_fr.txt";
592            width=600;
593            height=500;
594            if( "fr" != context.language ) {
595                titre = "Atmospheric model";
596                pageInfo = "resources/doc/infosAtmosphericModel_en.txt";
597                width=500;
598                height=450;
599            }
600        }
601
602        if ("iobservatory_" == parametre) {
603            var titre = "Observatoire";
604            var pageInfo = "resources/doc/infosObservatory_fr.txt";
605            width=600;
606            height=200;
607            if( "fr" != context.language ) {
608                titre = "Observatory";
609                pageInfo = "resources/doc/infosObservatory_en.txt";
610                width=500;
611                height=200;
612            }
613        }
614
615        if ("iformat_" == parametre) {
616            var titre = "Format fichier";
617            var pageInfo = "resources/doc/infosInstrumentalFunction_fr.txt";
618            width=600;
619            height=200;
620            if( "fr" != context.language ) {
621                titre = "File format";
622                pageInfo = "resources/doc/infosInstrumentalFunction_en.txt";
623                width=500;
624                height=200;
625            }
626        }
627
628        if ("ifunction_" == parametre) {
629            var titre = "Fonction instrumentale";
630            var pageInfo = "resources/doc/infosInstrumentalFunction_fr.txt";
631            width=600;
632            height=250;
633            if( "fr" != context.language ) {
634                titre = "Instrumental function";
635                pageInfo = "resources/doc/infosInstrumentalFunction_en.txt";
636                width=500;
637                height=200;
638            }
639        }
640
641
642        var $dialog = $( '<div></div>' )
643                .load( pageInfo )
644                    .dialog( {
645                            autoOpen: false,
646                            title:titre,
647                            height:height,
648                            width:width
649                } );
650
651        $dialog.dialog( 'open' );
652
653    },
654
[439]655    onClickSubmit: function()
656    {
[504]657        if( this.validFields() )
658        {
659            this.divE.hide();
660            if( confirm( tapasTexts["confirm"] ) )
[511]661            {
662                this.loadingRequest.display();
[504]663                this.requestCreateXML();
[511]664            }
[504]665        }
[490]666    },
[489]667
[490]668
669    onClickAdd: function()
670    {
[504]671        this.divE.hide();
[497]672        this.nbRequest++;
[490]673
[497]674        //tabs
675        $( ".tab_class" ).removeClass( "activated" );
676        this.tabActive = this.createTab();
677        this.numRequest = this.tabActive.numTab;
[490]678
[497]679        //formulaires
680        $( ".divAll" ).hide();
681        this.createForm();
[490]682
[497]683        this.updateButtons();
[490]684    },
685
686
687    onClickDel: function()
688    {
[504]689        if( confirm( tapasTexts["label.confirm.del"] ) )
[490]690        {
[494]691            var numCurrent = this.numRequest;
[529]692
[494]693            var z = 1;
[490]694
[494]695            //suppression onglet et form et controles calendrier caché
[493]696            $( "#all_" + numCurrent ).remove();
697            $( "#tab_request" + numCurrent ).remove();
[495]698            AnyTime.noPicker( "iobservation_date_" + numCurrent );
699            AnyTime.noPicker( "ira_" + numCurrent );
[490]700
[493]701            this.tabActive.numTab = "1";
[494]702            this.numRequest = "1";
[490]703
[503]704            this.selectClimatoReferencesList[numCurrent] = null;
705
[495]706            for( var i = 1; i <= this.nbRequest; i++ )
[493]707            {
[495]708                if( i > numCurrent )
[493]709                {
[495]710                    z = i - 1;
[493]711                    document.getElementById( "all_" + i ).id = "all_" + z;
712                    $( "#tab_request" + i ).html( "Request " + z );
[529]713                    //$( "#tab_request" + i ).html( "toto");
[493]714                    $( "#tab_request" + i ).attr( {name:z} );
[779]715                    $( "#tab_request" + i ).attr( {id:"tab_request" + z} );       //this.angleChoice
[496]716                    $( "#tabObservation_" + i ).attr( {id:"tabObservation_" + z} );
[503]717//                    $( "#select_iobservatory_" + i ).attr( {id:"select_iobservatory_" + z} );
718                    this.selectObservatoriesList[z] = this.selectObservatoriesList[i];
719                    this.selectObservatoriesList[i] = null;
720//                    $( "#select_ispectral_choice_" + i ).attr( {id:"select_ispectral_choice_" + z} );
721                    this.selectSpectralUnitsList[z] = this.selectSpectralUnitsList[i];
722                    this.selectSpectralUnitsList[i] = null;
[496]723                    $( "#iminspectral_ranger_" + i ).attr( {id:"iminspectral_ranger_" + z} );
724                    $( "#imaxspectral_ranger_" + i ).attr( {id:"imaxspectral_ranger_" + z} );
[503]725//                    $( "#select_ifunction_" + i ).attr( {id:"select_ifunction_" + z} );
726                    this.selectInstrumentalFunctionsList[z] = this.selectInstrumentalFunctionsList[i];
727                    this.selectInstrumentalFunctionsList[i] = null;
728//                    $( "#select_icr_" + i ).attr( {id:"select_icr_" + z} );
729                    this.selectClimatoReferencesList[z] = this.selectClimatoReferencesList[i];
730                    this.selectClimatoReferencesList[i] = null;
[529]731                    // le $ n'intervient qu en html. $() remplace le document.element
[496]732                    $( "#ide_" + i ).attr( {id:"ide_" + z} );
733                    $( "#iza_" + i ).attr( {id:"iza_" + z} );
734                    $( "#irp_" + i ).attr( {id:"irp_" + z} );
735                    $( "#isr_" + i ).attr( {id:"isr_" + z} );
[529]736                    $( "#ira_" + i ).attr( {id:"ira_" + z} );
[503]737//                    $( "#select_iformat_" + i ).attr( {id:"select_iformat_" + z} );
738                    this.selectFileFormatsList[z] = this.selectFileFormatsList[i];
739                    this.selectFileFormatsList[i] = null;
740//                    $( "#select_irextinction_" + i ).attr( {id:"select_irextinction_" + z} );
741                    this.select_irextinctionList[z] = this.select_irextinctionList[i];
742                    this.select_irextinctionList[i] = null;
743//                    $( "#select_ih2oe_" + i ).attr( {id:"select_ih2oe_" + z} );
744                    this.select_ih2oeList[z] = this.select_ih2oeList[i];
745                    this.select_ih2oeList[i] = null;
746//                    $( "#select_io2e_" + i ).attr( {id:"select_io2e_" + z} );
747                    this.select_io2eList[z] = this.select_io2eList[i];
748                    this.select_io2eList[i] = null;
749//                    $( "#select_io3e_" + i ).attr( {id:"select_io3e_" + z} );
750                    this.select_io3eList[z] = this.select_io3eList[i];
751                    this.select_io3eList[i] = null;
752//                    $( "#select_ico2e_" + i ).attr( {id:"select_ico2e_" + z} );
753                    this.select_ico2eList[z] = this.select_ico2eList[i];
754                    this.select_ico2eList[i] = null;
[494]755
[779]756                    this.select_ich4eList[z] = this.select_ich4eList[i];
757                    this.select_ich4eList[i] = null;
758
759                    this.select_in2oeList[z] = this.select_in2oeList[i];
760                    this.select_in2oeList[i] = null;
761
[767]762                    this.select_ibervCList[z] = this.select_ibervCList[i];
763                    this.select_ibervCList[i] = null;
764
[495]765                    // Supression du calendrier puis re-création en insérant l'ancienne date
766                    var oldDate = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() );
[529]767                    //var oldDate = $( "#iobservation_date_" + i ).val();
768
[495]769                    AnyTime.noPicker( "iobservation_date_" + i );
[529]770                    //this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, oldDate, false );
771
772                    $( "#iobservation_date_" + i ).attr( {id:"iobservation_date_" + z} );
[495]773                    this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, oldDate, false );
[529]774                    //this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, false, false );
[495]775
776                    // Idem pour les heures !!!
777                    // TODO : voir si besoin de parser les heures ou non
778//                    var oldTime = this.timeConverter.parse( $( "#ira_" + i ).val() );
[529]779                    /*var oldTime = $( "#ira_" + i ).val();
[495]780                    AnyTime.noPicker( "ira_" + i );
[529]781                    this.createTime( $( "#tabObservation_" + z ), tapasTexts["label.ira"], "ira_" + z, oldTime, false,"j2000" );
782                    $( "#ira_" + i ).attr( {id:"ira_" + z} );*/
[493]783                }
[491]784            }
785
[494]786            this.nbRequest--;
787
[496]788            // Mise à jour des boutons
789            this.updateButtons();
790
[494]791            //tabs
792            $( ".tab_class" ).removeClass( "activated" );
793            $( "#tab_request1" ).addClass( "activated" );
794
795            //formulaires
796            $( ".divAll" ).hide();
797            $( "#all_1" ).show();
[480]798        }
[439]799    },
800
[440]801
[493]802    onClickTab: function( event )
[490]803    {
[493]804        var realTabId = $( "#" + event.currentTarget.id ).attr( "name" );
805        var clickedDiv = event.data;
806
[490]807        //tabs
[493]808        $( ".tab_class" ).removeClass( "activated" );
809        clickedDiv.divContainer.addClass( "activated" );
[491]810
811        //forms
812        $( ".divAll" ).hide();
[493]813        $( "#all_" + realTabId ).show();
[491]814
[495]815        this.numRequest = realTabId;
816        this.tabActive.numTab = realTabId;
[494]817
[496]818        this.updateButtons();
[491]819    },
820
[490]821
[439]822    // OTHERS ********************************************************
[501]823    // General method to display select
824    displaySelect: function( container, id, index, jsonList, selectList, nullValueIsNeeded, contentManage )
[439]825    {
826        var paramSelect = new Object();
[490]827        paramSelect.id = "select_" + id;
[439]828        paramSelect.parent = container;
[501]829        var select = new Select( paramSelect );
830        if( nullValueIsNeeded )
831            select.add( "-1", "-- " + tapasTexts["text.select"] + " --" );
832        jQuery.each( jsonList, jQuery.proxy( function ( i, jsonElement )
[419]833        {
[501]834            switch( contentManage )
835            {
836                case "observatories":
837                    select.add( jsonElement.id, jsonElement.name );
838                    break;
839                case "spectralUnits":
840                    select.add( jsonElement.value, tapasTexts[jsonElement.value] );
841                    break;
842                case "instrumentalFunctions" :
[502]843                case "climatoReferences" :
844                case "yesNos" :
[501]845                    select.add( jsonElement.value, tapasTexts[jsonElement.text] );
846                    break;
847                default:
848                    select.add( jsonElement.value, jsonElement.text );
849                    break;
850            }
[439]851        }, this ) );
[501]852        select.selectFirst( false );
853        selectList[index] = select;
[439]854    },
[419]855
[779]856    createAutoCompleteMenuForRegions: function()
857    {
858
859        $( "#select_iobservatory_"+this.nbRequest ).autocomplete( {
860            source: this.listObs,
861            appendTo: "#regionContent"+this.nbRequest,
862            minLength: 0,
863            autoFocus: true,
864            autoSelect: true,
865            select: jQuery.proxy( function( event, ui )
866            {
867                this.regionLabel = ui.item.value;
868            }, this )
869        } ).focus( function( event )
870        {
871            $( this ).autocomplete( "search", "" );
872        } );
873
874        //$( "#regionTags" ).focus();
875    },
876
877
878// OTHERS ********************************************************
879    // General method to display select
880    displaySelect1: function( container, id, index, jsonList, selectList, nullValueIsNeeded, contentManage )
881    {
882        //alert("ok");
883        var iselect = $( document.createElement( "select" ) );
884        var option = document.createElement("option");
885
886        var paramSelect = new Object();
887        paramSelect.id = "select_" + id;
888        paramSelect.parent = container;
889
890        var observatoryArray=new Array();
891        this.listObs=new Array();
892
893
894        //var bob =$('<div id="region" class="containerField"><div class="containerTitle"><div class="containerTitleText">Region</div><div class="containerTitleClose"><img src="img/close.png"></div></div><div class="containerRegion"><input id="regionTags" size="23"/></div><div id="regionContent"></div></div> ');
895        var bob =$('<div class="containerField"><input id="select_'+id+'" size="42"/></div><div id="regionContent'+this.nbRequest+'" class="regionContent"></div> ');
896
897        //alert('<div class=containerField><input id=select_'+id+' size=23/></div><div id=regionContent></div> ');
898
899        //var select = new Select( paramSelect );
900        //iselect.options.add("1","1");
901        //if( nullValueIsNeeded )                          Select1
902
903        var option = new Option();
904        option.text = "-- " + tapasTexts["text.select"] + " --";
905        option.value = "-1";
906        iselect.append( option );
907
908        jQuery.each( jsonList, jQuery.proxy( function ( i, jsonElement )
909        {
910                //ajouter fonction
911
912                /*var option = new Option();
913                option.text = jsonElement.name;
914                option.value = jsonElement.id;*/
915                //observatoryArray.push(jsonElement.name);
916                this.listObs.push(jsonElement.name);
917                //console.log(option.value+"-"+option.text);
918                //iselect.append(option);
919
920
921        }, this ) );
922        //iselect.selectFirst( false );
923        /*selectList[index] = select;*/
924        //container.append(iselect);
925        container.append(bob);
926        selectList[index]="select_"+id;
927
928    },
929
930
[439]931    showErrors: function( result )
932    {
[490]933        //this.containerErrors.show();
934        // this.containerErrors.html( tapasTexts[result.responseText] );
[439]935    },
[400]936
[444]937    createForm: function()
938    {
[490]939
[767]940
941
[490]942        var divAll = $( document.createElement( "div" ) );
943        divAll.attr( {id:"all_" + this.nbRequest, class:"divAll"} );
944
945
946        //Creation div
[444]947        var divPreference = $( document.createElement( "div" ) );
948        var tabPreference = $( document.createElement( "table" ) );
[490]949        tabPreference.attr( {cellspacing:3} );
[444]950
951        var divObservation = $( document.createElement( "div" ) );
952        var tabObservation = $( document.createElement( "table" ) );
[489]953        //tabObservation.attr({border:1});
[495]954        tabObservation.attr( {id:"tabObservation_" + this.nbRequest, cellspacing:3} );
[444]955
[489]956
[444]957        var divAtmosphere = $( document.createElement( "div" ) );
958        var tabAtmosphere = $( document.createElement( "table" ) );
959
960
[481]961        var fieldSetObservation = $( document.createElement( "fieldset" ) );
[490]962        fieldSetObservation.addClass( "cfs1" );
963        divObservation.append( fieldSetObservation );
[481]964
965        var legendObservation = $( document.createElement( "legend" ) );
[490]966        legendObservation.html( "Observation" );
967        fieldSetObservation.append( legendObservation );
968        legendObservation.addClass( "containerField" );
[481]969
970        var fieldSetPreference = $( document.createElement( "fieldset" ) );
[490]971        fieldSetPreference.addClass( "cfs2" );
972        divPreference.append( fieldSetPreference );
[481]973
974        var legendPreference = $( document.createElement( "legend" ) );
[490]975        legendPreference.html( tapasTexts["label.preferences"] );
976        fieldSetPreference.append( legendPreference );
977        legendPreference.addClass( "containerField" );
[481]978
[490]979        fieldSetObservation.append( tabObservation );
980        divObservation.addClass( "divObservation" );
981        divAll.append( divObservation );
[481]982
[490]983
[489]984        divAtmosphere.append( tabAtmosphere );
985        //divAtmosphere.addClass("divAtmosphere");
986        //this.containerForm.append( divAtmosphere );
987        fieldSetObservation.append( divAtmosphere );
988
989        fieldSetPreference.append( tabPreference );
[490]990        divPreference.addClass( "divPreference" );
991        divAll.append( divPreference );
992
993        this.containerForm.append( divAll );
[504]994        this.containerForm.append( this.divE );
[444]995        //this.tabInput = new Array(3);
996
[501]997        this.createTrList( tapasTexts["label.format"], "iformat_" + this.nbRequest, this.nbRequest, tabPreference, 'format' );
998        this.createTrList( tapasTexts["label.era"], "irextinction_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
999        this.createTrList( tapasTexts["label.eh2o"], "ih2oe_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1000        this.createTrList( tapasTexts["label.eo3"], "io3e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1001        this.createTrList( tapasTexts["label.eo2"], "io2e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1002        this.createTrList( tapasTexts["label.eco2"], "ico2e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
[779]1003        this.createTrList( tapasTexts["label.ech4"], "ich4e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1004        this.createTrList( tapasTexts["label.en2o"], "in2oe_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
[767]1005        this.createTrList( tapasTexts["label.berv"], "ibervC_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
[444]1006
[767]1007        this.createTrList( tapasTexts["label.observatory"], "iobservatory_" + this.nbRequest, this.nbRequest, tabObservation, 'observatories',true );
[495]1008        this.createCalendar( tabObservation, tapasTexts["label.datemesure"], "iobservation_date_" + this.nbRequest, false, true );
[444]1009
1010        //unite
[501]1011        this.createTrList( tapasTexts["label.spectralUnit"], "ispectral_choice_" + this.nbRequest, this.nbRequest, tabObservation, 'spectralUnit' );
[490]1012        this.createTr2Input( tapasTexts["label.spectralRange"], tapasTexts["label.to"], "iminspectral_ranger_" + this.nbRequest, "imaxspectral_ranger_" + this.nbRequest, tabObservation, "[350,2500] nm" );
[444]1013
1014        //fonction instrumentale
[501]1015        this.createTrList( tapasTexts["label.ifunction"], "ifunction_" + this.nbRequest, this.nbRequest, tabObservation, "ilsf" );
[444]1016        //reference climato
[489]1017        //this.createTrList( tapasTexts["label.climato"], "icr", tabAtmosphere, "climatoReference" );
[501]1018        this.createTrList( tapasTexts["label.climato"], "icr_" + this.nbRequest, this.nbRequest, tabObservation, "climatoReference" );
[444]1019
1020
[767]1021        this.createTr( tapasTexts["label.resolution"], "irp_" + this.nbRequest, tabObservation, "", "", "","",true );
1022        this.createTr( tapasTexts["label.ratio"], "isr_" + this.nbRequest, tabObservation, "", "","","",true );
[481]1023
[444]1024
[767]1025        this.createTr( tapasTexts["label.ira"], "ira_" + this.nbRequest,tabObservation,"hh:mm:ss (J2000)","keypress","ra","2",true );
[529]1026        //this.createTime( tabObservation, tapasTexts["label.ira"], "ira_" + this.nbRequest, false, true,"hh:mm:ss (J2000)" );
[767]1027        this.createTr( tapasTexts["label.ide"], "ide_" + this.nbRequest, tabObservation, "deg:':''","keypress","de","2",true );
[529]1028        this.createTrTxt( tapasTexts["label.or"], tabObservation );
[767]1029        this.createTr( tapasTexts["label.iza"], "iza_" + this.nbRequest, tabObservation, "[0,90] &deg;","keypress","za","2",true );
[490]1030
[779]1031        this.createAutoCompleteMenuForRegions();
[529]1032
1033        this.initRequestFields();
[444]1034        //jQuery.proxy permet d'envoyer le contexte this courant
1035
1036    },
1037
1038
[440]1039    createTapasObject: function()
[439]1040    {
[400]1041
[490]1042        var requests = new Array();
[466]1043
[490]1044        for( var i = 1; i <= this.nbRequest; i++ )
1045        {
1046            // PREFERENCE
1047            var preference = new Object();
[400]1048
[490]1049            preference.format = new Object();
1050            //toutes les valeurs possibles
[501]1051            preference.format.firstValue = this.selectFileFormatsList[i].getValuesInString();
[490]1052            //la valeur selectionnee
[501]1053            preference.format.secondValue = this.selectFileFormatsList[i].getValue();
[466]1054
[490]1055            preference.rayleighExtinction = new Object();
[502]1056            preference.rayleighExtinction.firstValue = this.select_irextinctionList[i].getValuesInString();
1057            preference.rayleighExtinction.secondValue = this.select_irextinctionList[i].getValue();
[442]1058
[490]1059            preference.h2oExtinction = new Object();
[502]1060            preference.h2oExtinction.firstValue = this.select_ih2oeList[i].getValuesInString();
1061            preference.h2oExtinction.secondValue = this.select_ih2oeList[i].getValue();
[444]1062
[490]1063            preference.o3Extinction = new Object();
[502]1064            preference.o3Extinction.firstValue = this.select_io3eList[i].getValuesInString();
1065            preference.o3Extinction.secondValue = this.select_io3eList[i].getValue();
[444]1066
[490]1067            preference.o2Extinction = new Object();
[502]1068            preference.o2Extinction.firstValue = this.select_io2eList[i].getValuesInString();
1069            preference.o2Extinction.secondValue = this.select_io2eList[i].getValue();
[444]1070
[490]1071            preference.co2Extinction = new Object();
[502]1072            preference.co2Extinction.firstValue = this.select_ico2eList[i].getValuesInString();
1073            preference.co2Extinction.secondValue = this.select_ico2eList[i].getValue();
[400]1074
[779]1075            preference.ch4Extinction = new Object();
1076            preference.ch4Extinction.firstValue = this.select_ich4eList[i].getValuesInString();
1077            preference.ch4Extinction.secondValue = this.select_ich4eList[i].getValue();
1078
1079            preference.n2oExtinction = new Object();
1080            preference.n2oExtinction.firstValue = this.select_in2oeList[i].getValuesInString();
1081            preference.n2oExtinction.secondValue = this.select_in2oeList[i].getValue();
1082
[767]1083            preference.bervCorrection = new Object();
1084            preference.bervCorrection.firstValue = this.select_ibervCList[i].getValuesInString();
1085            preference.bervCorrection.secondValue = this.select_ibervCList[i].getValue();
[466]1086
[767]1087
[490]1088            // OBSERVATION
1089            var observatory = new Object();
[779]1090            //observatory.id = "European Southern Obs R La Serena Cerro La Silla";//this.selectObservatoriesList[i].getValue();
1091            //observatory.id = this.selectObservatoriesList[i].getValue();
1092            //observatory.id = 2;
1093            observatory.name = $("#select_iobservatory_"+i).val();
[400]1094
[490]1095            // Los
1096            var los = new Object();
[466]1097
[529]1098            //if ($( "#iza_" + i ).val().toString() != null)
1099                los.zenithAngle = $( "#iza_" + i ).val();
1100            //else {
1101                los.raJ2000 = $( "#ira_" + i ).val();
1102                los.decJ2000 = $( "#ide_" + i ).val();
1103            //}
1104
1105
1106            //los.raJ2000 = "22:22:22";//$( "#ira_" + i ).val();
1107            //los.decJ2000 = "22:22:22";//$( "#ide_" + i ).val();
1108            //los.zenithAngle = "12";//$( "#iza_" + i ).val("12");
1109
1110
[490]1111            // Instrument
1112            var instrument = new Object();
1113            instrument.ilsfChoice = new Object();
[508]1114            instrument.ilsfChoice.firstValue = "-1,0,1";//this.selectInstrumentalFunctionsList[i].getValuesInString();
[515]1115            instrument.ilsfChoice.secondValue = this.selectInstrumentalFunctionsList[i].getValue();
[444]1116
[502]1117            this.selectSpectralUnitsList[i].remove( "-1" );
[490]1118            instrument.spectralChoice = new Object();
[502]1119            instrument.spectralChoice.firstValue = this.selectSpectralUnitsList[i].getValuesInString();
1120            instrument.spectralChoice.secondValue = this.selectSpectralUnitsList[i].getValue();
[399]1121
[490]1122            instrument.spectralRange = $( "#iminspectral_ranger_" + i ).val() + ' ' + $( "#imaxspectral_ranger_" + i ).val();
[470]1123
[490]1124            instrument.resolvingPower = new Object();
1125            instrument.resolvingPower.firstValue = "0";
1126            instrument.resolvingPower.secondValue = $( "#irp_" + i ).val();
[399]1127
[490]1128            instrument.samplingRatio = new Object();
1129            instrument.samplingRatio.firstValue = "0";
1130            instrument.samplingRatio.secondValue = $( "#isr_" + i ).val();
[444]1131
[490]1132            var observation = new Object();
[524]1133            observation.date = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() ).getTime();
[529]1134
1135
[490]1136            observation.observatory = observatory;
[466]1137
[490]1138            observation.los = los;
1139            observation.instrument = instrument;
[400]1140
[490]1141            // ATMOSPHERE
1142            var atmosphere = new Object();
[400]1143
[490]1144            atmosphere.reference = new Object();
[502]1145            atmosphere.reference.firstValue = this.selectClimatoReferencesList[i].getValuesInString();
1146            atmosphere.reference.secondValue = this.selectClimatoReferencesList[i].getValue();
[382]1147
[490]1148
1149            // REQUEST
1150            var request = new Object();
1151            request.id = i;
1152            request.preference = preference;
1153            request.observation = observation;
1154            request.atmosphere = atmosphere;
1155
[502]1156            requests[i - 1] = request;
[490]1157        }
1158
[439]1159        // TAPAS
1160        var tapas = new Object();
1161        tapas.requests = requests;
1162        return tapas;
[490]1163    },
1164
1165    validFields: function()
1166    {
[504]1167        for( var i = 1; i <= this.nbRequest; i++ )
[497]1168        {
1169
[504]1170            var chaine = tapasTexts["text.erreur.saisie"] + " " + i + "<br>";
[529]1171            var testOk1=false;
1172            var testOk2=false;
1173            var testOk3=false;
[779]1174            //var testOk = isSup( this.selectObservatoriesList[i].getValue(), 0 );
1175            var testOk = isEmpty($( "#select_iobservatory_" + i ).val()) || this.listObs.indexOf($( "#select_iobservatory_" + i ).val())<0;
1176            //alert(testOk);
1177            if( testOk )
[504]1178            {
1179                this.divE.html( chaine + tapasTexts["label.observatory"] + " : " + tapasTexts["text.toselect"] );
1180                this.divE.show();
1181                return false;
1182            }
[497]1183
[504]1184            testOk = isDiff( this.selectSpectralUnitsList[i].getValue(), -1 );
1185            if( !testOk )
1186            {
1187                this.divE.html( chaine + tapasTexts["label.spectralUnit"] + " : " + tapasTexts["text.toselect"] );
1188                this.divE.show();
1189                return false;
1190            }
[497]1191
[504]1192            testOk = isValidRange( $( "#iminspectral_ranger_" + i ).val(), $( "#imaxspectral_ranger_" + i ).val(), this.selectSpectralUnitsList[i].getValue() );
1193            if( !testOk )
1194            {
1195                this.divE.html( chaine + tapasTexts["label.spectralRange"] + " : " + tapasTexts["text.badvalue"] );
1196                this.divE.show();
1197                return false;
1198            }
[497]1199
[529]1200            /*testOk = isDeg( $( "#ide_" + i ).val() );
[504]1201            if( !testOk )
1202            {
1203                this.divE.html( chaine + tapasTexts["label.ide"] + " : " + tapasTexts["text.badvalue"] );
1204                this.divE.show();
1205                return false;
[529]1206            } */
[497]1207
[529]1208
1209            testOk = isBetween( $( "#iza_" + i ).val(), 0, 90 );
1210            testOk1 = isValidNum( $( "#iza_" + i ).val());
1211            testOk2 = isDeg( $( "#ide_" + i ).val());
1212            testOk3 = isHourDeg( $( "#ira_" + i ).val());
1213            if( !((testOk && testOk1) || (testOk2 && testOk3)) )
[504]1214            {
[529]1215                if ( !(testOk && testOk1) )
1216                    this.divE.html( chaine + "LOS : " + tapasTexts["text.badvalue"] );
1217                else
1218                    this.divE.html( chaine + tapasTexts["label.iza"] + " : " + tapasTexts["text.badvalue"] );
[504]1219                this.divE.show();
1220                return false;
1221            }
[497]1222
[529]1223            /*testOk = isBetween( $( "#iza_" + i ).val(), 0, 90 );
[504]1224            if( !testOk )
1225            {
1226                this.divE.html( chaine + tapasTexts["label.iza"] + " : " + tapasTexts["text.badvalue"] );
1227                this.divE.show();
1228                return false;
[529]1229            } */
[497]1230
[504]1231            testOk = isValidNum( $( "#irp_" + i ).val() );
1232            if( !testOk )
1233            {
1234                this.divE.html( chaine + tapasTexts["label.resolution"] + " : " + tapasTexts["text.badvalue"] );
1235                this.divE.show();
1236                return false;
1237            }
[497]1238
[504]1239            testOk = isSup( $( "#irp_" + i ).val(), 1 );
1240            if( !testOk )
1241            {
1242                this.divE.html( chaine + tapasTexts["label.resolution"] + " : " + tapasTexts["text.badvalue"] );
1243                this.divE.show();
1244                return false;
1245            }
1246
1247            testOk = isValidNum( $( "#isr_" + i ).val() );
1248            if( !testOk )
1249            {
1250                this.divE.html( chaine + tapasTexts["label.ratio"] + " : " + tapasTexts["text.badvalue"] );
1251                this.divE.show();
1252                return false;
1253            }
1254
1255            testOk = isSup( $( "#isr_" + i ).val(), 1 );
1256            if( !testOk )
1257            {
1258                this.divE.html( chaine + tapasTexts["label.ratio"] + " : " + tapasTexts["text.badvalue"] );
1259                this.divE.show();
1260                return false;
1261            }
[497]1262        }
1263
[504]1264        return true;
[496]1265    },
[384]1266
[496]1267    updateButtons: function()
1268    {
1269        if( 1 < this.nbRequest )
1270            this.delRequestButton.enable();
1271        else
1272            this.delRequestButton.disable();
[490]1273
[515]1274        if( 9 <= this.nbRequest )
[496]1275            this.addRequestButton.disable();
1276        else
1277            this.addRequestButton.enable();
[529]1278    },
1279
1280
1281    angleChoice: function(params)
1282    {
1283        var context = params.data[0];
1284        var champ = params.data[1];
1285        //alert(context.nbRequest);
1286        var indice = context.nbRequest;
1287        if (champ == "za") {
1288            //$( "#iza_"+indice ).val($( "#iza_"+indice ).val().replace(/^\s+|\s+$/g,""));
1289            //alert($( "#iza_"+indice ).val($( "#iza_"+indice ).val().replace(/^\s+|\s+$/g,"")).length);
1290            //if ($( "#iza_"+indice ).val($( "#iza_"+indice ).val().replace(/^\s+|\s+$/g,"")).length >0 ) {
1291                $( "#ira_"+indice ).val("");
1292                $( "#ide_"+indice ).val("");
1293            //}
1294        }
1295        else {
1296            $( "#iza_"+indice ).val("");
1297        }
1298
1299
1300    },
1301
1302
1303
1304/*this.createTrList( tapasTexts["label.format"], "iformat_" + this.nbRequest, this.nbRequest, tabPreference, 'format' );
1305      this.createTrList( tapasTexts["label.era"], "irextinction_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1306      this.createTrList( tapasTexts["label.eh2o"], "ih2oe_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1307      this.createTrList( tapasTexts["label.eo3"], "io3e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1308      this.createTrList( tapasTexts["label.eo2"], "io2e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1309      this.createTrList( tapasTexts["label.eco2"], "ico2e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1310
1311      this.createTrList( tapasTexts["label.observatory"], "iobservatory_" + this.nbRequest, this.nbRequest, tabObservation, 'observatories' );
1312      this.createCalendar( tabObservation, tapasTexts["label.datemesure"], "iobservation_date_" + this.nbRequest, false, true );
1313
1314      //unite
1315      this.createTrList( tapasTexts["label.spectralUnit"], "ispectral_choice_" + this.nbRequest, this.nbRequest, tabObservation, 'spectralUnit' );
1316      this.createTr2Input( tapasTexts["label.spectralRange"], tapasTexts["label.to"], "iminspectral_ranger_" + this.nbRequest, "imaxspectral_ranger_" + this.nbRequest, tabObservation, "[350,2500] nm" );
1317
1318      //fonction instrumentale
1319      this.createTrList( tapasTexts["label.ifunction"], "ifunction_" + this.nbRequest, this.nbRequest, tabObservation, "ilsf" );
1320      //reference climato
1321      //this.createTrList( tapasTexts["label.climato"], "icr", tabAtmosphere, "climatoReference" );
1322      this.createTrList( tapasTexts["label.climato"], "icr_" + this.nbRequest, this.nbRequest, tabObservation, "climatoReference" );
1323
1324
1325      this.createTr( tapasTexts["label.ira"], "ira_" + this.nbRequest,tabObservation,"hh:mm:ss (J2000)","keypress","ra","2" );
1326      //this.createTime( tabObservation, tapasTexts["label.ira"], "ira_" + this.nbRequest, false, true,"hh:mm:ss (J2000)" );
1327      this.createTr( tapasTexts["label.ide"], "ide_" + this.nbRequest, tabObservation, "deg:':''","keypress","de","2" );
[767]1328
[529]1329      this.createTrTxt( "or", tabObservation );
1330      this.createTr( tapasTexts["label.iza"], "iza_" + this.nbRequest, tabObservation, "[0,90] &deg;","keypress","za","2" );
1331
1332      this.createTr( tapasTexts["label.resolution"], "irp_" + this.nbRequest, tabObservation, "", "", "","" );
1333      this.createTr( tapasTexts["label.ratio"], "isr_" + this.nbRequest, tabObservation, "", "","","" );
1334      */
1335
1336
1337    initRequestFields: function()
1338    {
1339        if (this.nbRequest > 1 && this.nbRequest <=9) {
1340            var indice = this.nbRequest;
1341            var indice0 = indice - 1;
1342
1343            this.selectObservatoriesList[indice].select(this.selectObservatoriesList[indice-1].getValue(),false);
1344            $( "#iobservation_date_" + indice ).val( $( "#iobservation_date_" + indice0).val() );
1345            this.selectSpectralUnitsList[indice].select(this.selectSpectralUnitsList[indice-1].getValue(),false);
1346
1347
1348            this.selectInstrumentalFunctionsList[indice].select(this.selectInstrumentalFunctionsList[indice-1].getValue(),false);
1349            this.selectClimatoReferencesList[indice].select(this.selectClimatoReferencesList[indice-1].getValue(),false);
1350
1351            this.selectFileFormatsList[indice].select(this.selectFileFormatsList[indice-1].getValue(),false);
1352            this.select_irextinctionList[indice].select(this.select_irextinctionList[indice-1].getValue(),false);
1353            this.select_ih2oeList[indice].select(this.select_ih2oeList[indice-1].getValue(),false);
1354            this.select_io3eList[indice].select(this.select_io3eList[indice-1].getValue(),false);
1355            this.select_io2eList[indice].select(this.select_io2eList[indice-1].getValue(),false);
1356            this.select_ico2eList[indice].select(this.select_ico2eList[indice-1].getValue(),false);
[779]1357            this.select_ich4eList[indice].select(this.select_ich4eList[indice-1].getValue(),false);
1358            this.select_in2oeList[indice].select(this.select_in2oeList[indice-1].getValue(),false);
[767]1359            this.select_ibervCList[indice].select(this.select_ibervCList[indice-1].getValue(),false);
[529]1360
1361            $( "#iminspectral_ranger_" + indice ).val($( "#iminspectral_ranger_" + indice0 ).val() );
1362            $( "#imaxspectral_ranger_" + indice ).val($( "#imaxspectral_ranger_" + indice0 ).val() );
1363
1364            $( "#irp_" + indice ).val($( "#irp_" + indice0 ).val() );
1365            $( "#isr_" + indice ).val($( "#isr_" + indice0 ).val() );
1366            $( "#ira_" + indice ).val($( "#ira_" + indice0 ).val() );
1367            $( "#ide_" + indice ).val($( "#ide_" + indice0 ).val() );
1368            $( "#iza_" + indice ).val($( "#iza_" + indice0 ).val() );
1369
1370
1371
1372      //      $( "#iobservatory_date_" + indice ).val( $( "#iobservatory_date_" + indice0 ).val() );
1373    //        $( "#iobservatory_date_" + indice ).val( this.calendarConverter.format( currentDate ) );
1374
1375            //$( "#iobservatory_date_" + indice ).val( this.calendarConverter.format( this.calendarConverter.parse( $( "#iobservation_date_" + indice0 ).val() ).getTime() ) );
1376            //      this.selectSpectralUnitsList[z] = this.selectSpectralUnitsList[i];
1377            /*this.selectSpectralUnitsList[i] = null;
1378            $( "#iminspectral_ranger_" + i ).attr( {id:"iminspectral_ranger_" + z} );
1379            $( "#imaxspectral_ranger_" + i ).attr( {id:"imaxspectral_ranger_" + z} );*/
1380
1381            //$( "#irp_"+indice ).val($( "#irp_"+(indice-1)).val() );
1382
1383        }
[496]1384    }
[489]1385
[439]1386} );
1387
[384]1388</script>
Note: See TracBrowser for help on using the repository browser.