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
Line 
1<script type="text/javascript">
2    var InterfaceTapas = Class.create( {
3
4        initialize: function()
5        {
6            /** *********** CONTAINERS *********** **/
7            this.containerForm = $( "#formulaire" );
8            this.containerErrors = $( "#errors" );
9
10            this.containerErrors.hide();
11            this.createForm();
12        },
13
14        // CREATES ********************************************************
15        createForm: function()
16        {
17            // Create button elements
18            this.input1 = $( document.createElement( "input" ) );
19            var input2 = $( document.createElement( "input" ) );
20
21            this.input1.attr( {id:"1"} );
22            this.containerForm.append( this.input1 );
23
24            input2.attr( {id:"2"} );
25            this.containerForm.append( input2 );
26
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 )} );
28
29        },
30
31        // REQUESTS ********************************************************
32        requestCreateXML: function()
33        {
34            var tapasForm = this.createTapasForm();
35            //passage de javascript a json grace au jquery
36            var jsonTapasForm = $.toJSON( tapasForm );
37
38            if( jsonTapasForm )
39                $.ajax( {
40                    url: "project?methodName=createUserRequest&jsonTapas=" + jsonTapasForm,
41                    success:jQuery.proxy( this.handleCreateXML, this ),
42                    error: jQuery.proxy( this.showErrors, this )
43                } );
44        },
45
46        // HANDLES ******************************************************** = retours ajax
47        handleCreateXML: function( result )
48        {
49            var bob = jQuery.parseJSON( result ).result;
50            alert( bob );
51        },
52
53
54        // EVENTS ********************************************************
55        onClickSubmit: function()
56        {
57            this.containerErrors.hide();
58            this.requestCreateXML();
59        },
60
61        // OTHERS ********************************************************
62        showErrors: function( result )
63        {
64            this.containerErrors.show();
65            this.containerErrors.html( tapasTexts[result.responseText] );
66        },
67
68        createTapasForm: function()
69        {
70            // PREFERENCE
71            var preference = new Object();
72
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
135            var observation = new Object();
136            observation.date = "2012-02-24";
137            observation.observatory = observatory;
138            observation.los = los;
139            observation.instrument = instrument;
140
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;
146
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";
150
151            atmosphere.ecmwfFile = new Array();
152            atmosphere.ecmwfFile[0] = "/home/ferron/tmp/tapas/ecmwf12.txt";
153
154            // REQUEST
155            var request = new Object();
156            request.id = 1;
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;
170        }
171
172    } );
173
174
175</script>
Note: See TracBrowser for help on using the repository browser.