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
Line 
1<script src="js/library/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script>
2<script type="text/javascript">
3
4
5var InterfaceTapas = Class.create( {
6    initialize: function( jsonFileFormats, jsonYesNos, jsonObservatories, jsonSpectralUnits, jsonInstrumentalFunctions, jsonClimatoReferences )
7    {
8        /** *********** CONTAINERS *********** **/
9        this.containerForm = $( "#formulaire" );
10        //this.containerErrors = $( "#errForm" );
11        //this.divE= $( "#divErreurs");
12        this.containerCenter = $( "#containerCenter" );
13        this.containerTabs = $( "#tab" );
14
15        /** *********** VARIABLES *********** **/
16        this.jSonFileFormats = jsonFileFormats || null;
17        this.selectFileFormatsList = new Object();
18
19        this.jSonYesNos = jsonYesNos || null;
20        this.select_ih2oeList = new Object();
21        this.select_io2eList = new Object();
22        this.select_io3eList = new Object();
23        this.select_ico2eList = new Object();
24        this.select_ich4eList = new Object();
25        this.select_in2oeList = new Object();
26        this.select_irextinctionList = new Object();
27        this.select_ibervCList = new Object();
28
29        this.jSonObservatories = jsonObservatories || false;
30        this.selectObservatoriesList = new Object();
31        this.jSonSpectralUnits = jsonSpectralUnits || null;
32        this.selectSpectralUnitsList = new Object();
33        this.jSonInstrumentalFunctions = jsonInstrumentalFunctions || null;
34        this.selectInstrumentalFunctionsList = new Object();
35        this.jSonClimatoReferences = jsonClimatoReferences || null;
36        this.selectClimatoReferencesList = new Object();
37        this.nbRequest = 1;
38        this.tabActive = false;
39        this.numRequest = 1;
40
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
54        // Buttons
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 )} );
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 )} );
58        this.delRequestButton.disable();
59
60        this.createForm();
61        this.tabActive = this.createTab();
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 );*/
67
68        this.containerForm.append( this.divE );
69        //this.containerErrors.hide();
70        this.divE.hide();
71
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 );
78        //this.loadingRequest.display();
79    },
80
81
82    // CREATES ********************************************************
83    createTab:function()
84    {
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 )} );
86        ntab.active();
87        return ntab;
88    },
89
90
91    createCalendar: function( containerCalendar, texte, inputDateId, currentDate, isTrToCreate )
92    {
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"} );
101
102            td1.html( texte );
103            td1.attr( { class:"containerLabel" } );
104            tr.append( td1 );
105
106            td2.attr( {colspan:4} );
107            td2.append( inputDate );
108            tr.append( td2 );
109            containerCalendar.append( tr );
110        }
111
112        // Calendar
113        this.calendarFormat = "%Y-%m-%d %H:%i:%s";
114        this.calendarConverter = new AnyTime.Converter( { format: this.calendarFormat } );
115
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        } );
120
121        // Ajout de la date courrante ds le calendrier SI currentDate non précisée
122        if( !currentDate )
123            currentDate = new Date();
124
125
126        $( "#" + inputDateId ).val( this.calendarConverter.format( currentDate ) );
127        $( "#" + inputDateId ).addClass( "calendar" );
128
129    },
130
131
132    // CREATES ********************************************************
133    createTime: function( containerCalendar, texte, inputDateId, currentTime, isTrToCreate, text2 )
134    {
135        if( isTrToCreate )
136        {
137
138            // Create input for date text
139            var tr = $( document.createElement( "tr" ) );
140            var td1 = $( document.createElement( "td" ) );
141            var td2 = $( document.createElement( "td" ) );
142            var td3 = $( document.createElement( "td" ) );
143            var inputDate = $( document.createElement( "input" ) );
144            inputDate.attr( {id:inputDateId, size:"10"} );
145
146            td1.html( texte );
147            td1.attr( { class:"containerLabel" } );
148            tr.append( td1 );
149
150            td2.attr( {colspan:1} );
151            td2.append( inputDate );
152            tr.append( td2 );
153
154            td3.html( text2 );
155            td3.attr( { class:"containerLabel2" } );
156            tr.append( td3 );
157
158            containerCalendar.append( tr );
159        }
160
161        // Time
162        this.timeFormat = "%H:%i:%s";
163        this.timeConverter = new AnyTime.Converter( { format: this.timeFormat } );
164
165        AnyTime.picker( inputDateId, { format: this.timeFormat, firstDOW: 1,
166            labelTitle: "Select hour", labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second"
167        } );
168
169        if( !currentTime )
170            currentTime = "00:00:00";
171        // TODO : voir si besoin de convertir format des heures
172//        $( "#" + inputDateId ).val( this.timeConverter.format( currentTime ) );
173        $( "#" + inputDateId ).val( currentTime );
174        $( "#" + inputDateId ).addClass( "time" );
175    },
176
177
178    createTr: function( texte, inputId, container, textesup, event, champ, ctnb, info )
179    {
180
181        var tr = $( document.createElement( "tr" ) );
182        var td1 = $( document.createElement( "td" ) );
183        var td2 = $( document.createElement( "td" ) );
184        var td3 = $( document.createElement( "td" ) );
185        var input = $( document.createElement( "input" ) );
186
187        input.attr( {id: inputId, class:"containerText"+ctnb, size:11} );
188
189
190        if (event.length > 0) input.bind( event, [this, champ], this.angleChoice );
191
192
193        td1.attr( {class:"containerLabel"} );
194
195        td3.html( textesup );
196        td3.attr( {class:"containerLabel2", colspan:3} );
197        tr.append( td1 );
198        td2.append( input );
199
200        tr.append( td2 );
201        tr.append( td3 );
202        container.append( tr );
203
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
220
221            td1.append( a );
222            td1.append( texte );
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);
234            td1.append(a);
235            td1.append( texte );
236
237        }
238    },
239
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
252
253    },
254
255
256
257    createTr2Input: function( texte1, texte2, inputId1, inputId2, container, textesup )
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" ) );
264        var td5 = $( document.createElement( "td" ) );
265        var td6 = $( document.createElement( "td" ) );
266        var input1 = $( document.createElement( "input" ) );
267        var input2 = $( document.createElement( "input" ) );
268
269
270        input1.attr( {id: inputId1,class:"containerText",size:11} );
271        input2.attr( {id: inputId2,class:"containerText",size:11} );
272
273
274        td3.html( texte2 );
275        td5.html( textesup );
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);
283        td1.append(a);
284         td1.append( texte1 );
285
286        //img.onclick(this.onClickInfos("spectral_range",1200,440));
287
288        td1.attr( {class:"containerLabel"} );
289        td3.attr( {class:"containerLabel3"} );
290        td5.attr( {class:"containerLabel2"} );
291
292        td2.append( input1 );
293        //td2.html( texte2 );
294        td4.append( input2 );
295
296        tr.append( td1 );
297        tr.append( td2 );
298        tr.append( td3 );
299        tr.append( td4 );
300        tr.append( td5 );
301        tr.append( td6 );
302        container.append( tr );
303    },
304
305
306
307    createTrList: function( texte, inputId, index, container, type, info )
308    {
309        var tr = $( document.createElement( "tr" ) );
310        var td1 = $( document.createElement( "td" ) );
311        var td2 = $( document.createElement( "td" ) );
312        var td3 = $( document.createElement( "td" ) );
313        var input = $( document.createElement( "input" ) );
314        var champ="";
315
316        var div = $( document.createElement( "div" ) );
317
318
319        input.attr( {id: inputId} );
320
321        // alert(inputId);
322        if( 'format' == type ) {
323            this.displaySelect( td2, inputId, index, this.jSonFileFormats, this.selectFileFormatsList, false, null );
324            info = true;
325            champ = "iformat_";
326
327        }
328        else
329        if( 'yesno' == type )
330        {
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" );
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" );
343            else if( (/^(irextinction_[1-9]+)$/.test( inputId )  ) ) {
344
345                this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_irextinctionList, false, "yesNos" );
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            }
354        }
355        else if( 'observatories' == type ) {
356
357            this.displaySelect1( td2, inputId, index, this.jSonObservatories, this.selectObservatoriesList, true, "observatories" );
358            //this.displaySelect( td2, inputId, index, this.jSonObservatories, this.selectObservatoriesList, true, "observatories" );
359
360            champ="iobservatory_";
361        }
362        else if( 'spectralUnit' == type ) {
363            this.displaySelect( td2, inputId, index, this.jSonSpectralUnits, this.selectSpectralUnitsList, true, "spectralUnits" );
364            info = true;
365
366            champ = "ispectral_choice_";
367        }
368        else if( 'ilsf' == type ) {
369            this.displaySelect( td2, inputId, index, this.jSonInstrumentalFunctions, this.selectInstrumentalFunctionsList, false, "instrumentalFunctions" );
370            info = true;
371            champ = "ifunction_";
372        }
373        else if( 'climatoReference' == type ) {
374            this.displaySelect( td2, inputId, index, this.jSonClimatoReferences, this.selectClimatoReferencesList, false, "climatoReferences" );
375            info = true;
376            champ = "icr_";
377        }
378
379        td1.attr( {class:"containerLabel"} );
380        tr.append( td1 );
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
394
395            td2.attr( {colspan:5} );
396            td1.append( a );
397            td1.append( texte );
398
399            tr.append( td2 );
400
401        }
402        else {
403            td1.append( texte );
404            td2.attr( {colspan:3} );
405            tr.append( td2 );
406        }
407        container.append( tr );
408    },
409
410
411    // REQUESTS ********************************************************
412    requestCreateXML: function()
413    {
414        var tapasForm = this.createTapasObject();
415        //passage de javascript a json grace au jquery
416        var jsonTapasForm = $.toJSON( tapasForm );
417
418
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            } );
425
426    },
427
428
429    // HANDLES ******************************************************** = retours ajax
430    handleCreateXML: function( result )
431    {
432        this.loadingRequest.hide();
433        //this.loadingRequest.display();
434
435        var res = jQuery.parseJSON( result ).result;
436
437    },
438
439
440    // EVENTS ********************************************************
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
655    onClickSubmit: function()
656    {
657        if( this.validFields() )
658        {
659            this.divE.hide();
660            if( confirm( tapasTexts["confirm"] ) )
661            {
662                this.loadingRequest.display();
663                this.requestCreateXML();
664            }
665        }
666    },
667
668
669    onClickAdd: function()
670    {
671        this.divE.hide();
672        this.nbRequest++;
673
674        //tabs
675        $( ".tab_class" ).removeClass( "activated" );
676        this.tabActive = this.createTab();
677        this.numRequest = this.tabActive.numTab;
678
679        //formulaires
680        $( ".divAll" ).hide();
681        this.createForm();
682
683        this.updateButtons();
684    },
685
686
687    onClickDel: function()
688    {
689        if( confirm( tapasTexts["label.confirm.del"] ) )
690        {
691            var numCurrent = this.numRequest;
692
693            var z = 1;
694
695            //suppression onglet et form et controles calendrier caché
696            $( "#all_" + numCurrent ).remove();
697            $( "#tab_request" + numCurrent ).remove();
698            AnyTime.noPicker( "iobservation_date_" + numCurrent );
699            AnyTime.noPicker( "ira_" + numCurrent );
700
701            this.tabActive.numTab = "1";
702            this.numRequest = "1";
703
704            this.selectClimatoReferencesList[numCurrent] = null;
705
706            for( var i = 1; i <= this.nbRequest; i++ )
707            {
708                if( i > numCurrent )
709                {
710                    z = i - 1;
711                    document.getElementById( "all_" + i ).id = "all_" + z;
712                    $( "#tab_request" + i ).html( "Request " + z );
713                    //$( "#tab_request" + i ).html( "toto");
714                    $( "#tab_request" + i ).attr( {name:z} );
715                    $( "#tab_request" + i ).attr( {id:"tab_request" + z} );       //this.angleChoice
716                    $( "#tabObservation_" + i ).attr( {id:"tabObservation_" + z} );
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;
723                    $( "#iminspectral_ranger_" + i ).attr( {id:"iminspectral_ranger_" + z} );
724                    $( "#imaxspectral_ranger_" + i ).attr( {id:"imaxspectral_ranger_" + z} );
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;
731                    // le $ n'intervient qu en html. $() remplace le document.element
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} );
736                    $( "#ira_" + i ).attr( {id:"ira_" + z} );
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;
755
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
762                    this.select_ibervCList[z] = this.select_ibervCList[i];
763                    this.select_ibervCList[i] = null;
764
765                    // Supression du calendrier puis re-création en insérant l'ancienne date
766                    var oldDate = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() );
767                    //var oldDate = $( "#iobservation_date_" + i ).val();
768
769                    AnyTime.noPicker( "iobservation_date_" + i );
770                    //this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, oldDate, false );
771
772                    $( "#iobservation_date_" + i ).attr( {id:"iobservation_date_" + z} );
773                    this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, oldDate, false );
774                    //this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, false, false );
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() );
779                    /*var oldTime = $( "#ira_" + i ).val();
780                    AnyTime.noPicker( "ira_" + i );
781                    this.createTime( $( "#tabObservation_" + z ), tapasTexts["label.ira"], "ira_" + z, oldTime, false,"j2000" );
782                    $( "#ira_" + i ).attr( {id:"ira_" + z} );*/
783                }
784            }
785
786            this.nbRequest--;
787
788            // Mise à jour des boutons
789            this.updateButtons();
790
791            //tabs
792            $( ".tab_class" ).removeClass( "activated" );
793            $( "#tab_request1" ).addClass( "activated" );
794
795            //formulaires
796            $( ".divAll" ).hide();
797            $( "#all_1" ).show();
798        }
799    },
800
801
802    onClickTab: function( event )
803    {
804        var realTabId = $( "#" + event.currentTarget.id ).attr( "name" );
805        var clickedDiv = event.data;
806
807        //tabs
808        $( ".tab_class" ).removeClass( "activated" );
809        clickedDiv.divContainer.addClass( "activated" );
810
811        //forms
812        $( ".divAll" ).hide();
813        $( "#all_" + realTabId ).show();
814
815        this.numRequest = realTabId;
816        this.tabActive.numTab = realTabId;
817
818        this.updateButtons();
819    },
820
821
822    // OTHERS ********************************************************
823    // General method to display select
824    displaySelect: function( container, id, index, jsonList, selectList, nullValueIsNeeded, contentManage )
825    {
826        var paramSelect = new Object();
827        paramSelect.id = "select_" + id;
828        paramSelect.parent = container;
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 )
833        {
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" :
843                case "climatoReferences" :
844                case "yesNos" :
845                    select.add( jsonElement.value, tapasTexts[jsonElement.text] );
846                    break;
847                default:
848                    select.add( jsonElement.value, jsonElement.text );
849                    break;
850            }
851        }, this ) );
852        select.selectFirst( false );
853        selectList[index] = select;
854    },
855
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
931    showErrors: function( result )
932    {
933        //this.containerErrors.show();
934        // this.containerErrors.html( tapasTexts[result.responseText] );
935    },
936
937    createForm: function()
938    {
939
940
941
942        var divAll = $( document.createElement( "div" ) );
943        divAll.attr( {id:"all_" + this.nbRequest, class:"divAll"} );
944
945
946        //Creation div
947        var divPreference = $( document.createElement( "div" ) );
948        var tabPreference = $( document.createElement( "table" ) );
949        tabPreference.attr( {cellspacing:3} );
950
951        var divObservation = $( document.createElement( "div" ) );
952        var tabObservation = $( document.createElement( "table" ) );
953        //tabObservation.attr({border:1});
954        tabObservation.attr( {id:"tabObservation_" + this.nbRequest, cellspacing:3} );
955
956
957        var divAtmosphere = $( document.createElement( "div" ) );
958        var tabAtmosphere = $( document.createElement( "table" ) );
959
960
961        var fieldSetObservation = $( document.createElement( "fieldset" ) );
962        fieldSetObservation.addClass( "cfs1" );
963        divObservation.append( fieldSetObservation );
964
965        var legendObservation = $( document.createElement( "legend" ) );
966        legendObservation.html( "Observation" );
967        fieldSetObservation.append( legendObservation );
968        legendObservation.addClass( "containerField" );
969
970        var fieldSetPreference = $( document.createElement( "fieldset" ) );
971        fieldSetPreference.addClass( "cfs2" );
972        divPreference.append( fieldSetPreference );
973
974        var legendPreference = $( document.createElement( "legend" ) );
975        legendPreference.html( tapasTexts["label.preferences"] );
976        fieldSetPreference.append( legendPreference );
977        legendPreference.addClass( "containerField" );
978
979        fieldSetObservation.append( tabObservation );
980        divObservation.addClass( "divObservation" );
981        divAll.append( divObservation );
982
983
984        divAtmosphere.append( tabAtmosphere );
985        //divAtmosphere.addClass("divAtmosphere");
986        //this.containerForm.append( divAtmosphere );
987        fieldSetObservation.append( divAtmosphere );
988
989        fieldSetPreference.append( tabPreference );
990        divPreference.addClass( "divPreference" );
991        divAll.append( divPreference );
992
993        this.containerForm.append( divAll );
994        this.containerForm.append( this.divE );
995        //this.tabInput = new Array(3);
996
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' );
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' );
1005        this.createTrList( tapasTexts["label.berv"], "ibervC_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' );
1006
1007        this.createTrList( tapasTexts["label.observatory"], "iobservatory_" + this.nbRequest, this.nbRequest, tabObservation, 'observatories',true );
1008        this.createCalendar( tabObservation, tapasTexts["label.datemesure"], "iobservation_date_" + this.nbRequest, false, true );
1009
1010        //unite
1011        this.createTrList( tapasTexts["label.spectralUnit"], "ispectral_choice_" + this.nbRequest, this.nbRequest, tabObservation, 'spectralUnit' );
1012        this.createTr2Input( tapasTexts["label.spectralRange"], tapasTexts["label.to"], "iminspectral_ranger_" + this.nbRequest, "imaxspectral_ranger_" + this.nbRequest, tabObservation, "[350,2500] nm" );
1013
1014        //fonction instrumentale
1015        this.createTrList( tapasTexts["label.ifunction"], "ifunction_" + this.nbRequest, this.nbRequest, tabObservation, "ilsf" );
1016        //reference climato
1017        //this.createTrList( tapasTexts["label.climato"], "icr", tabAtmosphere, "climatoReference" );
1018        this.createTrList( tapasTexts["label.climato"], "icr_" + this.nbRequest, this.nbRequest, tabObservation, "climatoReference" );
1019
1020
1021        this.createTr( tapasTexts["label.resolution"], "irp_" + this.nbRequest, tabObservation, "", "", "","",true );
1022        this.createTr( tapasTexts["label.ratio"], "isr_" + this.nbRequest, tabObservation, "", "","","",true );
1023
1024
1025        this.createTr( tapasTexts["label.ira"], "ira_" + this.nbRequest,tabObservation,"hh:mm:ss (J2000)","keypress","ra","2",true );
1026        //this.createTime( tabObservation, tapasTexts["label.ira"], "ira_" + this.nbRequest, false, true,"hh:mm:ss (J2000)" );
1027        this.createTr( tapasTexts["label.ide"], "ide_" + this.nbRequest, tabObservation, "deg:':''","keypress","de","2",true );
1028        this.createTrTxt( tapasTexts["label.or"], tabObservation );
1029        this.createTr( tapasTexts["label.iza"], "iza_" + this.nbRequest, tabObservation, "[0,90] &deg;","keypress","za","2",true );
1030
1031        this.createAutoCompleteMenuForRegions();
1032
1033        this.initRequestFields();
1034        //jQuery.proxy permet d'envoyer le contexte this courant
1035
1036    },
1037
1038
1039    createTapasObject: function()
1040    {
1041
1042        var requests = new Array();
1043
1044        for( var i = 1; i <= this.nbRequest; i++ )
1045        {
1046            // PREFERENCE
1047            var preference = new Object();
1048
1049            preference.format = new Object();
1050            //toutes les valeurs possibles
1051            preference.format.firstValue = this.selectFileFormatsList[i].getValuesInString();
1052            //la valeur selectionnee
1053            preference.format.secondValue = this.selectFileFormatsList[i].getValue();
1054
1055            preference.rayleighExtinction = new Object();
1056            preference.rayleighExtinction.firstValue = this.select_irextinctionList[i].getValuesInString();
1057            preference.rayleighExtinction.secondValue = this.select_irextinctionList[i].getValue();
1058
1059            preference.h2oExtinction = new Object();
1060            preference.h2oExtinction.firstValue = this.select_ih2oeList[i].getValuesInString();
1061            preference.h2oExtinction.secondValue = this.select_ih2oeList[i].getValue();
1062
1063            preference.o3Extinction = new Object();
1064            preference.o3Extinction.firstValue = this.select_io3eList[i].getValuesInString();
1065            preference.o3Extinction.secondValue = this.select_io3eList[i].getValue();
1066
1067            preference.o2Extinction = new Object();
1068            preference.o2Extinction.firstValue = this.select_io2eList[i].getValuesInString();
1069            preference.o2Extinction.secondValue = this.select_io2eList[i].getValue();
1070
1071            preference.co2Extinction = new Object();
1072            preference.co2Extinction.firstValue = this.select_ico2eList[i].getValuesInString();
1073            preference.co2Extinction.secondValue = this.select_ico2eList[i].getValue();
1074
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
1083            preference.bervCorrection = new Object();
1084            preference.bervCorrection.firstValue = this.select_ibervCList[i].getValuesInString();
1085            preference.bervCorrection.secondValue = this.select_ibervCList[i].getValue();
1086
1087
1088            // OBSERVATION
1089            var observatory = new Object();
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();
1094
1095            // Los
1096            var los = new Object();
1097
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
1111            // Instrument
1112            var instrument = new Object();
1113            instrument.ilsfChoice = new Object();
1114            instrument.ilsfChoice.firstValue = "-1,0,1";//this.selectInstrumentalFunctionsList[i].getValuesInString();
1115            instrument.ilsfChoice.secondValue = this.selectInstrumentalFunctionsList[i].getValue();
1116
1117            this.selectSpectralUnitsList[i].remove( "-1" );
1118            instrument.spectralChoice = new Object();
1119            instrument.spectralChoice.firstValue = this.selectSpectralUnitsList[i].getValuesInString();
1120            instrument.spectralChoice.secondValue = this.selectSpectralUnitsList[i].getValue();
1121
1122            instrument.spectralRange = $( "#iminspectral_ranger_" + i ).val() + ' ' + $( "#imaxspectral_ranger_" + i ).val();
1123
1124            instrument.resolvingPower = new Object();
1125            instrument.resolvingPower.firstValue = "0";
1126            instrument.resolvingPower.secondValue = $( "#irp_" + i ).val();
1127
1128            instrument.samplingRatio = new Object();
1129            instrument.samplingRatio.firstValue = "0";
1130            instrument.samplingRatio.secondValue = $( "#isr_" + i ).val();
1131
1132            var observation = new Object();
1133            observation.date = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() ).getTime();
1134
1135
1136            observation.observatory = observatory;
1137
1138            observation.los = los;
1139            observation.instrument = instrument;
1140
1141            // ATMOSPHERE
1142            var atmosphere = new Object();
1143
1144            atmosphere.reference = new Object();
1145            atmosphere.reference.firstValue = this.selectClimatoReferencesList[i].getValuesInString();
1146            atmosphere.reference.secondValue = this.selectClimatoReferencesList[i].getValue();
1147
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
1156            requests[i - 1] = request;
1157        }
1158
1159        // TAPAS
1160        var tapas = new Object();
1161        tapas.requests = requests;
1162        return tapas;
1163    },
1164
1165    validFields: function()
1166    {
1167        for( var i = 1; i <= this.nbRequest; i++ )
1168        {
1169
1170            var chaine = tapasTexts["text.erreur.saisie"] + " " + i + "<br>";
1171            var testOk1=false;
1172            var testOk2=false;
1173            var testOk3=false;
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 )
1178            {
1179                this.divE.html( chaine + tapasTexts["label.observatory"] + " : " + tapasTexts["text.toselect"] );
1180                this.divE.show();
1181                return false;
1182            }
1183
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            }
1191
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            }
1199
1200            /*testOk = isDeg( $( "#ide_" + i ).val() );
1201            if( !testOk )
1202            {
1203                this.divE.html( chaine + tapasTexts["label.ide"] + " : " + tapasTexts["text.badvalue"] );
1204                this.divE.show();
1205                return false;
1206            } */
1207
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)) )
1214            {
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"] );
1219                this.divE.show();
1220                return false;
1221            }
1222
1223            /*testOk = isBetween( $( "#iza_" + i ).val(), 0, 90 );
1224            if( !testOk )
1225            {
1226                this.divE.html( chaine + tapasTexts["label.iza"] + " : " + tapasTexts["text.badvalue"] );
1227                this.divE.show();
1228                return false;
1229            } */
1230
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            }
1238
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            }
1262        }
1263
1264        return true;
1265    },
1266
1267    updateButtons: function()
1268    {
1269        if( 1 < this.nbRequest )
1270            this.delRequestButton.enable();
1271        else
1272            this.delRequestButton.disable();
1273
1274        if( 9 <= this.nbRequest )
1275            this.addRequestButton.disable();
1276        else
1277            this.addRequestButton.enable();
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" );
1328
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);
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);
1359            this.select_ibervCList[indice].select(this.select_ibervCList[indice-1].getValue(),false);
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        }
1384    }
1385
1386} );
1387
1388</script>
Note: See TracBrowser for help on using the repository browser.