1 | <script type="text/javascript"> |
---|
2 | var InterfaceInit = Class.create( { |
---|
3 | |
---|
4 | initialize: function() |
---|
5 | { |
---|
6 | /** *********** CONTAINERS *********** **/ |
---|
7 | this.containerForm = $( "#formulaire" ); |
---|
8 | |
---|
9 | this.createForm(); |
---|
10 | |
---|
11 | }, |
---|
12 | |
---|
13 | // CREATES ******************************************************** |
---|
14 | createForm: function() |
---|
15 | { |
---|
16 | // Create button elements |
---|
17 | this.input1 = $( document.createElement( "input" ) ); |
---|
18 | var input2 = $( document.createElement( "input" ) ); |
---|
19 | |
---|
20 | this.input1.attr( {id:"1"} ); |
---|
21 | this.containerForm.append( this.input1 ); |
---|
22 | |
---|
23 | input2.attr( {id:"2"} ); |
---|
24 | this.containerForm.append( input2 ); |
---|
25 | |
---|
26 | var submitButton = new Button( {value:initTexts["label.submitButton"], parent:this.containerForm, id:"button_submit", className: "red_button", classNameText:"red_button_text", onClick:jQuery.proxy( this.onClickSubmit, this )} ); |
---|
27 | |
---|
28 | }, |
---|
29 | |
---|
30 | // REQUESTS ******************************************************** |
---|
31 | requestCreateXML: function() |
---|
32 | { |
---|
33 | var bob = new Object(); |
---|
34 | bob.input1 = "eee"; |
---|
35 | bob.input2 = "rr"; |
---|
36 | var jsonBob = $.toJSON( bob ); |
---|
37 | |
---|
38 | var jsonFormXml = this.serializeFormXMLToJson(); |
---|
39 | if( jsonFormXml ) |
---|
40 | $.ajax( { |
---|
41 | url: "project?methodName=createUserRequest&jsonFormXml=" + jsonBob + "&jsonTapas=" + jsonFormXml, |
---|
42 | success:jQuery.proxy( this.handleCreateXML, 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.requestCreateXML(); |
---|
58 | }, |
---|
59 | |
---|
60 | // OTHERS ******************************************************** |
---|
61 | serializeFormXMLToJson: function() |
---|
62 | { |
---|
63 | var formXML = new Array(); |
---|
64 | var requestXML = new Object(); |
---|
65 | |
---|
66 | var preference = new Object(); |
---|
67 | preference.format = $( "#1" ).val(); |
---|
68 | preference.rayleigh_extinction = $( "#2" ).val(); |
---|
69 | preference.h2o_extinction = "h2o_extinction"; |
---|
70 | preference.o3_extinction = "o3_extinction"; |
---|
71 | preference.o2_extinction = "o2_extinction"; |
---|
72 | preference.co2_extinction = "co2_extinction"; |
---|
73 | |
---|
74 | var observation = new Object(); |
---|
75 | observation.date = "2012-02-24"; |
---|
76 | |
---|
77 | requestXML.preference = preference; |
---|
78 | requestXML.observation = observation; |
---|
79 | requestXML.atmosphere = "atmosphereZZZZ"; |
---|
80 | |
---|
81 | formXML[0] = requestXML; |
---|
82 | |
---|
83 | return $.toJSON( formXML ); |
---|
84 | } |
---|
85 | |
---|
86 | } ); |
---|
87 | |
---|
88 | |
---|
89 | </script> |
---|