- Timestamp:
- 03/26/12 16:09:21 (12 years ago)
- Location:
- tapas/web
- Files:
-
- 2 added
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
tapas/web/project/formTapas.jsp
r419 r439 9 9 <tiles:put name="insertCss" type="string"> 10 10 <ether:htmlCss cssFile="select"/> 11 <ether:htmlCss cssFile="calendar/anytime"/> 12 <ether:htmlCss cssFile="jquery-ui-1.8.16.custom/jquery-ui-1.8.16.custom"/> 11 13 </tiles:put> 14 12 15 <tiles:put name="insertJsOrJsp" type="string"> 13 16 <ether:htmlJs jsFile="library/jquery.json-2.3"/> 14 17 <ether:htmlJs jsFile="classesForJQuery/Select"/> 18 <ether:htmlJs jsFile="calendar/anytime"/> 15 19 <ether:htmlJsp jspFile="formTapas_script"/> 16 20 </tiles:put> … … 25 29 <tiles:put name="body" type="string"> 26 30 27 <div id="formulaire"> 28 29 </div> 31 <div id="formulaire"></div> 30 32 31 33 <div id="errors"></div> … … 36 38 tapasTexts["<%=WebException.WebCode.ERROR_JSON_TAPAS_IS_NULL%>"] = "<spring:message code="error.ERROR_JSON_TAPAS_IS_NULL"/>"; 37 39 38 var interfaceTapas = new InterfaceTapas( ${jSonFileFormats},${jSonYesNos});40 var interfaceTapas = new InterfaceTapas( ${jSonFileFormats}, ${jSonYesNos} ); 39 41 </script> 40 42 -
tapas/web/project/formTapas_script.jsp
r419 r439 1 1 <script type="text/javascript"> 2 var InterfaceTapas = Class.create( { 3 4 initialize: function(jsonFileFormats,jsonYesNos) 2 var InterfaceTapas = Class.create( { 3 4 initialize: function( jsonFileFormats, jsonYesNos ) 5 { 6 /** *********** CONTAINERS *********** **/ 7 this.containerForm = $( "#formulaire" ); 8 this.containerErrors = $( "#errors" ); 9 10 this.jsonFileFormats = jsonFileFormats || null; 11 this.jsonYesNos = jsonYesNos || null; 12 13 this.containerErrors.hide(); 14 15 this.createForm(); 16 this.createCalendar( this.containerForm ); 17 }, 18 19 20 21 // CREATES ******************************************************** 22 createCalendar: function( containerCalendar ) 23 { 24 // Create input for date text 25 var inputDateId = "observationDate"; 26 var inputDate = $( document.createElement( "input" ) ); 27 inputDate.attr( {id:inputDateId, size:"17"} ); 28 containerCalendar.append( inputDate ); 29 30 // Calendar 31 this.calendarFormat = "%Y-%m-%d %H:%i:%s"; 32 this.calendarConverter = new AnyTime.Converter( { format: this.calendarFormat } ); 33 34 AnyTime.picker( inputDateId, { format: this.calendarFormat, firstDOW: 1, 35 labelTitle: "Select Date", labelYear: "Year", labelMonth: "Month", labelDayOfMonth: "Day", 36 labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second" 37 } ); 38 39 var currentDate = new Date(); 40 $( "#observationDate" ).val( this.calendarConverter.format( currentDate ) ); 41 }, 42 43 createTr: function( texte, inputId, container ) 44 { 45 var tr = $( document.createElement( "tr" ) ); 46 var td1 = $( document.createElement( "td" ) ); 47 var td2 = $( document.createElement( "td" ) ); 48 var input = $( document.createElement( "input" ) ); 49 50 51 input.attr( {id: inputId} ); 52 td1.html( texte ); 53 tr.append( td1 ); 54 td2.append( input ); 55 tr.append( td2 ); 56 container.append( tr ); 57 }, 58 59 60 createTrList: function( texte, inputId, container, type ) 61 { 62 var tr = $( document.createElement( "tr" ) ); 63 var td1 = $( document.createElement( "td" ) ); 64 var td2 = $( document.createElement( "td" ) ); 65 var input = $( document.createElement( "input" ) ); 66 67 68 input.attr( {id: inputId} ); 69 td1.html( texte ); 70 tr.append( td1 ); 71 if( type == 'format' ) this.displayFileFormats( td2 ); 72 else if( type == 'yesno' ) this.displayYesNo( td2 ); 73 74 tr.append( td2 ); 75 container.append( tr ); 76 }, 77 78 79 createForm: function() 80 { 81 82 //Creation div 83 var divPreference = $( document.createElement( "div" ) ); 84 var tabPreference = $( document.createElement( "table" ) ); 85 86 this.createTrList( "File format", "p1", tabPreference, 'format' ); 87 this.createTr( "Rayleigh extinction", "p2", tabPreference ); 88 this.createTrList( "H20 extinction", "p3", tabPreference, 'yesno' ); 89 this.createTrList( "O3 extinction", "p4", tabPreference, 'yesno' ); 90 this.createTrList( "O2 extinction", "p5", tabPreference, 'yesno' ); 91 this.createTrList( "CO2 extinction", "p6", tabPreference, 'yesno' ); 92 93 divPreference.append( tabPreference ); 94 this.containerForm.append( divPreference ); 95 96 //jQuery.proxy permet d'envoyer le contexte this courant 97 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 )} ); 98 99 }, 100 101 102 103 // REQUESTS ******************************************************** 104 requestCreateXML: function() 105 { 106 var tapasForm = this.createTapasForm(); 107 //passage de javascript a json grace au jquery 108 var jsonTapasForm = $.toJSON( tapasForm ); 109 110 if( jsonTapasForm ) 111 $.ajax( { 112 url: "data?methodName=createUserRequest&jsonTapas=" + jsonTapasForm, 113 success:jQuery.proxy( this.handleCreateXML, this ), 114 error: jQuery.proxy( this.showErrors, this ) 115 } ); 116 }, 117 118 // HANDLES ******************************************************** = retours ajax 119 handleCreateXML: function( result ) 120 { 121 var bob = jQuery.parseJSON( result ).result; 122 alert( bob ); 123 }, 124 125 126 // EVENTS ******************************************************** 127 onClickSubmit: function() 128 { 129 this.containerErrors.hide(); 130 this.requestCreateXML(); 131 }, 132 133 // OTHERS ******************************************************** 134 displayFileFormats: function( container ) 135 { 136 var paramSelect = new Object(); 137 paramSelect.id = "select_formats"; 138 paramSelect.parent = container; 139 this.selectFormats = new Select( paramSelect ); 140 jQuery.each( this.jsonFileFormats, jQuery.proxy( function ( i, jsonFileFormat ) 5 141 { 6 /** *********** CONTAINERS *********** **/ 7 this.containerForm = $( "#formulaire" ); 8 this.containerErrors = $( "#errors" ); 9 10 this.jsonFileFormats = jsonFileFormats || null; 11 this.jsonYesNos = jsonYesNos || null; 12 13 this.containerErrors.hide(); 14 15 this.createForm(); 16 }, 17 18 19 20 // CREATES ******************************************************** 21 createTr: function(texte, inputId, container) 142 this.selectFormats.add( jsonFileFormat.value, jsonFileFormat.text ); 143 }, this ) ); 144 this.selectFormats.selectFirst( false ); 145 }, 146 147 148 displayYesNo: function( container, name ) 149 { 150 var paramSelect = new Object(); 151 paramSelect.id = "select_" + name; 152 paramSelect.parent = container; 153 this.selectYesNos = new Select( paramSelect ); 154 jQuery.each( this.jsonYesNos, jQuery.proxy( function ( i, jsonYesNo ) 22 155 { 23 var tr=$( document.createElement("tr") ); 24 var td1=$( document.createElement("td") ); 25 var td2=$( document.createElement("td") ); 26 var input=$( document.createElement("input") ); 27 28 29 input.attr({id: inputId}); 30 td1.html(texte); 31 tr.append(td1); 32 td2.append(input); 33 tr.append(td2); 34 container.append(tr); 35 }, 36 37 38 createTrList: function(texte, inputId, container, type) 39 { 40 var tr=$( document.createElement("tr") ); 41 var td1=$( document.createElement("td") ); 42 var td2=$( document.createElement("td") ); 43 var input=$( document.createElement("input") ); 44 45 46 input.attr({id: inputId}); 47 td1.html(texte); 48 tr.append(td1); 49 if (type == 'format') this.displayFileFormats(td2); 50 else if (type == 'yesno') this.displayYesNo(td2); 51 52 tr.append(td2); 53 container.append(tr); 54 }, 55 56 57 createForm: function() 58 { 59 60 //Creation div 61 var divPreference=$( document.createElement("div") ); 62 var tabPreference=$( document.createElement("table") ); 63 64 this.createTrList("File format", "p1", tabPreference, 'format'); 65 this.createTr("Rayleigh extinction", "p2", tabPreference); 66 this.createTrList("H20 extinction", "p3", tabPreference, 'yesno'); 67 this.createTrList("O3 extinction", "p4", tabPreference, 'yesno'); 68 this.createTrList("O2 extinction", "p5", tabPreference, 'yesno'); 69 this.createTrList("CO2 extinction", "p6", tabPreference, 'yesno'); 70 71 divPreference.append( tabPreference ); 72 this.containerForm.append( divPreference ); 73 74 //jQuery.proxy permet d'envoyer le contexte this courant 75 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 )} ); 76 77 }, 78 79 80 81 // REQUESTS ******************************************************** 82 requestCreateXML: function() 83 { 84 var tapasForm = this.createTapasForm(); 85 //passage de javascript a json grace au jquery 86 var jsonTapasForm = $.toJSON( tapasForm ); 87 88 if( jsonTapasForm ) 89 $.ajax( { 90 url: "data?methodName=createUserRequest&jsonTapas=" + jsonTapasForm, 91 success:jQuery.proxy( this.handleCreateXML, this ), 92 error: jQuery.proxy( this.showErrors, this ) 93 } ); 94 }, 95 96 // HANDLES ******************************************************** = retours ajax 97 handleCreateXML: function( result ) 98 { 99 var bob = jQuery.parseJSON( result ).result; 100 alert( bob ); 101 }, 102 103 104 // EVENTS ******************************************************** 105 onClickSubmit: function() 106 { 107 this.containerErrors.hide(); 108 this.requestCreateXML(); 109 }, 110 111 112 // OTHERS ******************************************************** 113 displayFileFormats: function(container) 114 { 115 var paramSelect = new Object(); 116 paramSelect.id = "select_formats"; 117 paramSelect.parent = container; 118 this.selectFormats = new Select( paramSelect ); 119 jQuery.each( this.jsonFileFormats, jQuery.proxy( function ( i, jsonFileFormat ) 120 { 121 this.selectFormats.add( jsonFileFormat.value, jsonFileFormat.text ); 122 }, this ) ); 123 this.selectFormats.selectFirst( false ); 124 }, 125 126 127 displayYesNo: function(container,name) 128 { 129 var paramSelect = new Object(); 130 paramSelect.id = "select_"+name; 131 paramSelect.parent = container; 132 this.selectYesNos = new Select( paramSelect ); 133 jQuery.each( this.jsonYesNos, jQuery.proxy( function ( i, jsonYesNo ) 134 { 135 this.selectYesNos.add( jsonYesNo.value, jsonYesNo.text ); 136 }, this ) ); 137 this.selectYesNos.selectFirst( false ); 138 }, 139 140 141 showErrors: function( result ) 142 { 143 this.containerErrors.show(); 144 this.containerErrors.html( tapasTexts[result.responseText] ); 145 }, 146 147 createTapasForm: function() 148 { 149 // PREFERENCE 150 var preference = new Object(); 151 152 preference.format = new Object(); 153 preference.format.firstValue = $( "#1" ).val(); 154 preference.format.secondValue = $( "#2" ).val(); 155 156 var pair = new Object(); 157 pair.firstValue = "YES,NO"; 158 pair.secondValue = "YES"; 159 160 preference.rayleighExtinction = pair; 161 preference.h2oExtinction = pair; 162 preference.o3Extinction = pair; 163 preference.o2Extinction = pair; 164 preference.co2Extinction = pair; 165 166 // OBSERVATION 167 // Observatory 168 var observatory = new Object(); 169 observatory.name = "SanFernandoObs.RSanFernando"; 170 171 observatory.longitude = new Object(); 172 observatory.longitude.min = "-180"; 173 observatory.longitude.max = "180"; 174 observatory.longitude.value = -118.491666666667; 175 176 observatory.latitude = new Object(); 177 observatory.latitude.min = "-90"; 178 observatory.latitude.max = "90"; 179 observatory.latitude.value = 34.3083333333333; 180 181 observatory.altitude = new Object(); 182 observatory.altitude.min = "0"; 183 observatory.altitude.max = "10000"; 184 observatory.altitude.value = 371; 185 186 // Los 187 var los = new Object(); 188 los.raJ2000 = "04:32:43"; 189 los.decJ2000 = "-43:12:10.22"; 190 191 los.zenithAngle = new Object(); 192 los.zenithAngle.min = "0"; 193 los.zenithAngle.max = "90"; 194 los.zenithAngle.value = 60; 195 196 // Instrument 197 var instrument = new Object(); 198 199 instrument.spectralChoice = new Object(); 200 instrument.spectralChoice.firstValue = "Vacuum Wavelength (nm),Standard Wavelength (nm),Wavenumber (cm-1)"; 201 instrument.spectralChoice.secondValue = "Standard Wavelength (nm)"; 202 instrument.spectralRange = "1180 1200"; 203 instrument.ilsfChoice = new Object(); 204 instrument.ilsfChoice.firstValue = "-1,0,1"; 205 instrument.ilsfChoice.secondValue = 0; 206 instrument.ilsfPath = "/home/ferron/tmp/tapas/ilsf.txt"; 207 instrument.resolvingPower = new Object(); 208 instrument.resolvingPower.firstValue = "0"; 209 instrument.resolvingPower.secondValue = 1000000; 210 instrument.samplingRatio = new Object(); 211 instrument.samplingRatio.firstValue = "0"; 212 instrument.samplingRatio.secondValue = 3; 213 214 var observation = new Object(); 215 observation.date = "2012-02-24"; 216 observation.observatory = observatory; 217 observation.los = los; 218 observation.instrument = instrument; 219 220 // ATMOSPHERE 221 var atmosphere = new Object(); 222 atmosphere.reference = new Object(); 223 atmosphere.reference.firstValue = "0,1,2,3,4,5,6"; 224 atmosphere.reference.secondValue = 6; 225 226 atmosphere.arlettyFile = new Array(); 227 atmosphere.arlettyFile[0] = "/home/ferron/tmp/tapas/Reims_070402.ARL.txt"; 228 atmosphere.arlettyFile[1] = "/home/ferron/tmp/tapas/Reims_070402.ARL.txt22"; 229 230 atmosphere.ecmwfFile = new Array(); 231 atmosphere.ecmwfFile[0] = "/home/ferron/tmp/tapas/ecmwf12.txt"; 232 233 // REQUEST 234 var request = new Object(); 235 request.id = 1; 236 request.preference = preference; 237 request.observation = observation; 238 request.atmosphere = atmosphere; 239 240 var requests = new Array(); 241 requests[0] = request; 242 243 // TAPAS 244 var tapas = new Object(); 245 tapas.id = "Ether_TAPAS_0000001"; 246 tapas.requests = requests; 247 248 return tapas; 249 } 250 251 } ); 156 this.selectYesNos.add( jsonYesNo.value, jsonYesNo.text ); 157 }, this ) ); 158 this.selectYesNos.selectFirst( false ); 159 }, 160 161 162 showErrors: function( result ) 163 { 164 this.containerErrors.show(); 165 this.containerErrors.html( tapasTexts[result.responseText] ); 166 }, 167 168 createTapasForm: function() 169 { 170 // PREFERENCE 171 var preference = new Object(); 172 173 preference.format = new Object(); 174 preference.format.firstValue = $( "#1" ).val(); 175 preference.format.secondValue = $( "#2" ).val(); 176 177 var pair = new Object(); 178 pair.firstValue = "YES,NO"; 179 pair.secondValue = "YES"; 180 181 preference.rayleighExtinction = pair; 182 preference.h2oExtinction = pair; 183 preference.o3Extinction = pair; 184 preference.o2Extinction = pair; 185 preference.co2Extinction = pair; 186 187 // OBSERVATION 188 // Observatory 189 var observatory = new Object(); 190 observatory.name = "SanFernandoObs.RSanFernando"; 191 192 observatory.longitude = new Object(); 193 observatory.longitude.min = "-180"; 194 observatory.longitude.max = "180"; 195 observatory.longitude.value = -118.491666666667; 196 197 observatory.latitude = new Object(); 198 observatory.latitude.min = "-90"; 199 observatory.latitude.max = "90"; 200 observatory.latitude.value = 34.3083333333333; 201 202 observatory.altitude = new Object(); 203 observatory.altitude.min = "0"; 204 observatory.altitude.max = "10000"; 205 observatory.altitude.value = 371; 206 207 // Los 208 var los = new Object(); 209 los.raJ2000 = "04:32:43"; 210 los.decJ2000 = "-43:12:10.22"; 211 212 los.zenithAngle = new Object(); 213 los.zenithAngle.min = "0"; 214 los.zenithAngle.max = "90"; 215 los.zenithAngle.value = 60; 216 217 // Instrument 218 var instrument = new Object(); 219 220 instrument.spectralChoice = new Object(); 221 instrument.spectralChoice.firstValue = "Vacuum Wavelength (nm),Standard Wavelength (nm),Wavenumber (cm-1)"; 222 instrument.spectralChoice.secondValue = "Standard Wavelength (nm)"; 223 instrument.spectralRange = "1180 1200"; 224 instrument.ilsfChoice = new Object(); 225 instrument.ilsfChoice.firstValue = "-1,0,1"; 226 instrument.ilsfChoice.secondValue = 0; 227 instrument.ilsfPath = "/home/ferron/tmp/tapas/ilsf.txt"; 228 instrument.resolvingPower = new Object(); 229 instrument.resolvingPower.firstValue = "0"; 230 instrument.resolvingPower.secondValue = 1000000; 231 instrument.samplingRatio = new Object(); 232 instrument.samplingRatio.firstValue = "0"; 233 instrument.samplingRatio.secondValue = 3; 234 235 var observation = new Object(); 236 observation.date = this.calendarConverter.parse( $( "#observationDate" ).val() ).getTime(); 237 observation.observatory = observatory; 238 observation.los = los; 239 observation.instrument = instrument; 240 241 // ATMOSPHERE 242 var atmosphere = new Object(); 243 atmosphere.reference = new Object(); 244 atmosphere.reference.firstValue = "0,1,2,3,4,5,6"; 245 atmosphere.reference.secondValue = 6; 246 247 atmosphere.arlettyFile = new Array(); 248 atmosphere.arlettyFile[0] = "/home/ferron/tmp/tapas/Reims_070402.ARL.txt"; 249 atmosphere.arlettyFile[1] = "/home/ferron/tmp/tapas/Reims_070402.ARL.txt22"; 250 251 atmosphere.ecmwfFile = new Array(); 252 atmosphere.ecmwfFile[0] = "/home/ferron/tmp/tapas/ecmwf12.txt"; 253 254 // REQUEST 255 var request = new Object(); 256 request.id = 1; 257 request.preference = preference; 258 request.observation = observation; 259 request.atmosphere = atmosphere; 260 261 var requests = new Array(); 262 requests[0] = request; 263 264 // TAPAS 265 var tapas = new Object(); 266 tapas.id = "Ether_TAPAS_0000001"; 267 tapas.requests = requests; 268 269 return tapas; 270 } 271 272 } ); 252 273 253 274 -
tapas/web/resources/css/tapas.css
r409 r439 269 269 margin-top: 4px; 270 270 } 271 272 /** ************************************ **/ 273 /** ************ CALENDAR ************** **/ 274 /** ************************************ **/ 275 #observationDate { 276 background-image: url("../../resources/icons/calendrier-icone-16x16.png"); 277 background-position: right center; 278 background-repeat: no-repeat; 279 }
Note: See TracChangeset
for help on using the changeset viewer.