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

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

creation 1 form xml

File size: 6.2 KB
RevLine 
[382]1<script type="text/javascript">
[400]2    var InterfaceTapas = Class.create( {
[382]3
[389]4        initialize: function()
5        {
6            /** *********** CONTAINERS *********** **/
7            this.containerForm = $( "#formulaire" );
[402]8            this.containerErrors = $( "#errors" );
[382]9
[402]10            this.containerErrors.hide();
[389]11            this.createForm();
12        },
[382]13
[389]14        // CREATES ********************************************************
15        createForm: function()
16        {
17            // Create button elements
18            this.input1 = $( document.createElement( "input" ) );
19            var input2 = $( document.createElement( "input" ) );
[382]20
[389]21            this.input1.attr( {id:"1"} );
22            this.containerForm.append( this.input1 );
[382]23
[389]24            input2.attr( {id:"2"} );
25            this.containerForm.append( input2 );
[382]26
[402]27            var submitButton = new Button( {value:tapasTexts["label.submitButton"], parent:this.containerForm, id:"button_submit", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickSubmit, this )} );
[382]28
[389]29        },
[382]30
[389]31        // REQUESTS ********************************************************
32        requestCreateXML: function()
33        {
[400]34            var tapasForm = this.createTapasForm();
[411]35            //passage de javascript a json grace au jquery
[400]36            var jsonTapasForm = $.toJSON( tapasForm );
[399]37
[400]38            if( jsonTapasForm )
[396]39                $.ajax( {
[400]40                    url: "project?methodName=createUserRequest&jsonTapas=" + jsonTapasForm,
[402]41                    success:jQuery.proxy( this.handleCreateXML, this ),
42                    error: jQuery.proxy( this.showErrors, this )
[396]43                } );
[389]44        },
[382]45
[389]46        // HANDLES ******************************************************** = retours ajax
47        handleCreateXML: function( result )
48        {
49            var bob = jQuery.parseJSON( result ).result;
[402]50            alert( bob );
[389]51        },
[382]52
53
[389]54        // EVENTS ********************************************************
55        onClickSubmit: function()
56        {
[402]57            this.containerErrors.hide();
[389]58            this.requestCreateXML();
[396]59        },
60
61        // OTHERS ********************************************************
[402]62        showErrors: function( result )
63        {
64            this.containerErrors.show();
65            this.containerErrors.html( tapasTexts[result.responseText] );
66        },
67
[400]68        createTapasForm: function()
[396]69        {
[400]70            // PREFERENCE
[399]71            var preference = new Object();
72
[400]73            preference.format = new Object();
74            preference.format.firstValue = $( "#1" ).val();
75            preference.format.secondValue = $( "#2" ).val();
76
77            var pair = new Object();
78            pair.firstValue = "YES,NO";
79            pair.secondValue = "YES";
80
81            preference.rayleighExtinction = pair;
82            preference.h2oExtinction = pair;
83            preference.o3Extinction = pair;
84            preference.o2Extinction = pair;
85            preference.co2Extinction = pair;
86
87            // OBSERVATION
88            // Observatory
89            var observatory = new Object();
90            observatory.name = "SanFernandoObs.RSanFernando";
91
92            observatory.longitude = new Object();
93            observatory.longitude.min = "-180";
94            observatory.longitude.max = "180";
95            observatory.longitude.value = -118.491666666667;
96
97            observatory.latitude = new Object();
98            observatory.latitude.min = "-90";
99            observatory.latitude.max = "90";
100            observatory.latitude.value = 34.3083333333333;
101
102            observatory.altitude = new Object();
103            observatory.altitude.min = "0";
104            observatory.altitude.max = "10000";
105            observatory.altitude.value = 371;
106
107            // Los
108            var los = new Object();
109            los.raJ2000 = "04:32:43";
110            los.decJ2000 = "-43:12:10.22";
111
112            los.zenithAngle = new Object();
113            los.zenithAngle.min = "0";
114            los.zenithAngle.max = "90";
115            los.zenithAngle.value = 60;
116
117            // Instrument
118            var instrument = new Object();
119
120            instrument.spectralChoice = new Object();
121            instrument.spectralChoice.firstValue = "Vacuum Wavelength (nm),Standard Wavelength (nm),Wavenumber (cm-1)";
122            instrument.spectralChoice.secondValue = "Standard Wavelength (nm)";
123            instrument.spectralRange = "1180 1200";
124            instrument.ilsfChoice = new Object();
125            instrument.ilsfChoice.firstValue = "-1,0,1";
126            instrument.ilsfChoice.secondValue = 0;
127            instrument.ilsfPath = "/home/ferron/tmp/tapas/ilsf.txt";
128            instrument.resolvingPower = new Object();
129            instrument.resolvingPower.firstValue = "0";
130            instrument.resolvingPower.secondValue = 1000000;
131            instrument.samplingRatio = new Object();
132            instrument.samplingRatio.firstValue = "0";
133            instrument.samplingRatio.secondValue = 3;
134
[399]135            var observation = new Object();
136            observation.date = "2012-02-24";
[400]137            observation.observatory = observatory;
138            observation.los = los;
139            observation.instrument = instrument;
[399]140
[400]141            // ATMOSPHERE
142            var atmosphere = new Object();
143            atmosphere.reference = new Object();
144            atmosphere.reference.firstValue = "0,1,2,3,4,5,6";
145            atmosphere.reference.secondValue = 6;
[399]146
[400]147            atmosphere.arlettyFile = new Array();
148            atmosphere.arlettyFile[0] = "/home/ferron/tmp/tapas/Reims_070402.ARL.txt";
149            atmosphere.arlettyFile[1] = "/home/ferron/tmp/tapas/Reims_070402.ARL.txt22";
[399]150
[400]151            atmosphere.ecmwfFile = new Array();
152            atmosphere.ecmwfFile[0] = "/home/ferron/tmp/tapas/ecmwf12.txt";
153
154            // REQUEST
155            var request = new Object();
[401]156            request.id = 1;
[400]157            request.preference = preference;
158            request.observation = observation;
159            request.atmosphere = atmosphere;
160
161            var requests = new Array();
162            requests[0] = request;
163
164            // TAPAS
165            var tapas = new Object();
166            tapas.id = "Ether_TAPAS_0000001";
167            tapas.requests = requests;
168
169            return tapas;
[389]170        }
[382]171
172    } );
[384]173
174
175</script>
Note: See TracBrowser for help on using the repository browser.