1 | <script type="text/javascript"> |
---|
2 | |
---|
3 | |
---|
4 | var InterfaceTapas = Class.create( { |
---|
5 | |
---|
6 | initialize: function( jsonFileFormats, jsonYesNos, jsonObservatories, jsonSpectralUnits, jsonInstrumentalFunctions, jsonClimatoReferences ) |
---|
7 | { |
---|
8 | /** *********** CONTAINERS *********** **/ |
---|
9 | this.containerForm = $( "#formulaire" ); |
---|
10 | //this.containerErrors = $( "#errors" ); |
---|
11 | this.containerErrors = $( "#errForm" ); |
---|
12 | this.containerCenter = $( "#containerCenter" ); |
---|
13 | this.containerTabs = $( "#tab" ); |
---|
14 | |
---|
15 | this.jSonFileFormats = jsonFileFormats || null; |
---|
16 | this.jSonYesNos = jsonYesNos || null; |
---|
17 | this.jSonObservatories = jsonObservatories || false; |
---|
18 | this.jSonSpectralUnits = jsonSpectralUnits || null; |
---|
19 | this.jSonInstrumentalFunctions = jsonInstrumentalFunctions || null; |
---|
20 | this.jSonClimatoReferences = jsonClimatoReferences || null; |
---|
21 | this.nbRequest = 1; |
---|
22 | this.tabActive = false; |
---|
23 | this.numRequest = 1; |
---|
24 | |
---|
25 | |
---|
26 | this.containerErrors.show(); |
---|
27 | |
---|
28 | 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 )} ); |
---|
29 | this.addRequestButton = new Button( {value:tapasTexts["label.addButton"], parent:this.containerCenter, id:"button_add", className: "positive", onClick:jQuery.proxy( this.onClickAdd, this )} ); |
---|
30 | this.delRequestButton = new Button( {value:tapasTexts["label.delButton"], parent:this.containerCenter, id:"button_del", className: "negative", onClick:jQuery.proxy( this.onClickDel, this )} ); |
---|
31 | this.delRequestButton.disable(); |
---|
32 | |
---|
33 | this.createForm(); |
---|
34 | this.tabActive = this.createTab(); |
---|
35 | }, |
---|
36 | |
---|
37 | |
---|
38 | // CREATES ******************************************************** |
---|
39 | createTab:function() |
---|
40 | { |
---|
41 | 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 )} ); |
---|
42 | ntab.active(); |
---|
43 | return ntab; |
---|
44 | }, |
---|
45 | |
---|
46 | |
---|
47 | createCalendar: function( containerCalendar, texte, inputDateId, currentDate, isTrToCreate ) |
---|
48 | { |
---|
49 | if( isTrToCreate ) |
---|
50 | { |
---|
51 | // Create input for date text |
---|
52 | var tr = $( document.createElement( "tr" ) ); |
---|
53 | var td1 = $( document.createElement( "td" ) ); |
---|
54 | var td2 = $( document.createElement( "td" ) ); |
---|
55 | var inputDate = $( document.createElement( "input" ) ); |
---|
56 | inputDate.attr( {id:inputDateId, size:"17"} ); |
---|
57 | |
---|
58 | td1.html( texte ); |
---|
59 | td1.attr( { class:"containerLabel" } ); |
---|
60 | tr.append( td1 ); |
---|
61 | |
---|
62 | td2.attr( {colspan:4} ); |
---|
63 | td2.append( inputDate ); |
---|
64 | tr.append( td2 ); |
---|
65 | containerCalendar.append( tr ); |
---|
66 | } |
---|
67 | |
---|
68 | // Calendar |
---|
69 | this.calendarFormat = "%Y-%m-%d %H:%i:%s"; |
---|
70 | this.calendarConverter = new AnyTime.Converter( { format: this.calendarFormat } ); |
---|
71 | |
---|
72 | AnyTime.picker( inputDateId, { format: this.calendarFormat, firstDOW: 1, |
---|
73 | labelTitle: "Select Date", labelYear: "Year", labelMonth: "Month", labelDayOfMonth: "Day", |
---|
74 | labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second" |
---|
75 | } ); |
---|
76 | |
---|
77 | // Ajout de la date courrante ds le calendrier SI currentDate non précisée |
---|
78 | if( !currentDate ) |
---|
79 | currentDate = new Date(); |
---|
80 | $( "#" + inputDateId ).val( this.calendarConverter.format( currentDate ) ); |
---|
81 | $( "#" + inputDateId ).addClass( "calendar" ); |
---|
82 | |
---|
83 | }, |
---|
84 | |
---|
85 | |
---|
86 | // CREATES ******************************************************** |
---|
87 | createTime: function( containerCalendar, texte, inputDateId, currentTime, isTrToCreate ) |
---|
88 | { |
---|
89 | if( isTrToCreate ) |
---|
90 | { |
---|
91 | // Create input for date text |
---|
92 | var tr = $( document.createElement( "tr" ) ); |
---|
93 | var td1 = $( document.createElement( "td" ) ); |
---|
94 | var td2 = $( document.createElement( "td" ) ); |
---|
95 | var inputDate = $( document.createElement( "input" ) ); |
---|
96 | inputDate.attr( {id:inputDateId, size:"10"} ); |
---|
97 | |
---|
98 | td1.html( texte ); |
---|
99 | td1.attr( { class:"containerLabel" } ); |
---|
100 | |
---|
101 | tr.append( td1 ); |
---|
102 | |
---|
103 | |
---|
104 | td2.attr( {colspan:3} ); |
---|
105 | td2.append( inputDate ); |
---|
106 | tr.append( td2 ); |
---|
107 | containerCalendar.append( tr ); |
---|
108 | } |
---|
109 | |
---|
110 | // Time |
---|
111 | this.timeFormat = "%H:%i:%s"; |
---|
112 | this.timeConverter = new AnyTime.Converter( { format: this.timeFormat } ); |
---|
113 | |
---|
114 | AnyTime.picker( inputDateId, { format: this.timeFormat, firstDOW: 1, |
---|
115 | labelTitle: "Select hour", labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second" |
---|
116 | } ); |
---|
117 | |
---|
118 | if( !currentTime ) |
---|
119 | currentTime = "00:00:00"; |
---|
120 | // $( "#" + inputDateId ).val( this.timeConverter.format( currentTime ) ); |
---|
121 | $( "#" + inputDateId ).val( currentTime ); |
---|
122 | $( "#" + inputDateId ).addClass( "time" ); |
---|
123 | }, |
---|
124 | |
---|
125 | |
---|
126 | createTr: function( texte, inputId, container, textesup ) |
---|
127 | { |
---|
128 | var tr = $( document.createElement( "tr" ) ); |
---|
129 | var td1 = $( document.createElement( "td" ) ); |
---|
130 | var td2 = $( document.createElement( "td" ) ); |
---|
131 | var td3 = $( document.createElement( "td" ) ); |
---|
132 | var input = $( document.createElement( "input" ) ); |
---|
133 | |
---|
134 | input.attr( {id: inputId, class:"containerText", size:11} ); |
---|
135 | |
---|
136 | td1.html( texte ); |
---|
137 | td1.attr( {class:"containerLabel"} ); |
---|
138 | |
---|
139 | td3.html( textesup ); |
---|
140 | td3.attr( {class:"containerLabel2", colspan:3} ); |
---|
141 | tr.append( td1 ); |
---|
142 | td2.append( input ); |
---|
143 | |
---|
144 | tr.append( td2 ); |
---|
145 | tr.append( td3 ); |
---|
146 | container.append( tr ); |
---|
147 | |
---|
148 | }, |
---|
149 | |
---|
150 | createSelectYesNo: function( container, name ) |
---|
151 | { |
---|
152 | var paramSelect = new Object(); |
---|
153 | paramSelect.id = "select_" + name; |
---|
154 | paramSelect.parent = container; |
---|
155 | var selectYesNos = new Select( paramSelect ); |
---|
156 | jQuery.each( this.jSonYesNos, jQuery.proxy( function ( i, jsonYesNo ) |
---|
157 | { |
---|
158 | selectYesNos.add( jsonYesNo.value, tapasTexts[jsonYesNo.text] ); |
---|
159 | }, this ) ); |
---|
160 | selectYesNos.selectFirst( false ); |
---|
161 | return selectYesNos; |
---|
162 | }, |
---|
163 | |
---|
164 | |
---|
165 | |
---|
166 | createTr2Input: function( texte1, texte2, inputId1, inputId2, container, textesup ) |
---|
167 | { |
---|
168 | var tr = $( document.createElement( "tr" ) ); |
---|
169 | var td1 = $( document.createElement( "td" ) ); |
---|
170 | var td2 = $( document.createElement( "td" ) ); |
---|
171 | var td3 = $( document.createElement( "td" ) ); |
---|
172 | var td4 = $( document.createElement( "td" ) ); |
---|
173 | var td5 = $( document.createElement( "td" ) ); |
---|
174 | var input1 = $( document.createElement( "input" ) ); |
---|
175 | var input2 = $( document.createElement( "input" ) ); |
---|
176 | |
---|
177 | |
---|
178 | input1.attr( {id: inputId1,class:"containerText",size:11} ); |
---|
179 | input2.attr( {id: inputId2,class:"containerText",size:11} ); |
---|
180 | |
---|
181 | td1.html( texte1 ); |
---|
182 | td3.html( texte2 ); |
---|
183 | td5.html( textesup ); |
---|
184 | td1.attr( {class:"containerLabel"} ); |
---|
185 | td3.attr( {class:"containerLabel3"} ); |
---|
186 | td5.attr( {class:"containerLabel2"} ); |
---|
187 | |
---|
188 | td2.append( input1 ); |
---|
189 | //td2.html( texte2 ); |
---|
190 | td4.append( input2 ); |
---|
191 | |
---|
192 | tr.append( td1 ); |
---|
193 | tr.append( td2 ); |
---|
194 | tr.append( td3 ); |
---|
195 | tr.append( td4 ); |
---|
196 | tr.append( td5 ); |
---|
197 | container.append( tr ); |
---|
198 | }, |
---|
199 | |
---|
200 | |
---|
201 | |
---|
202 | createTrList: function( texte, inputId, container, type ) |
---|
203 | { |
---|
204 | var tr = $( document.createElement( "tr" ) ); |
---|
205 | var td1 = $( document.createElement( "td" ) ); |
---|
206 | var td2 = $( document.createElement( "td" ) ); |
---|
207 | var input = $( document.createElement( "input" ) ); |
---|
208 | |
---|
209 | input.attr( {id: inputId} ); |
---|
210 | |
---|
211 | td1.html( texte ); |
---|
212 | td1.attr( {class:"containerLabel"} ); |
---|
213 | |
---|
214 | tr.append( td1 ); |
---|
215 | if( type == 'format' ) this.displayFileFormats( td2, inputId ); |
---|
216 | else if( type == 'yesno' ) |
---|
217 | { |
---|
218 | if( (/^(ih2oe_[1-9]+)$/.test( inputId ) ) ) this.select_ih2oe = this.createSelectYesNo( td2, inputId ); |
---|
219 | else if( (/^(io2e_[1-9]+)$/.test( inputId ) ) ) this.select_io2e = this.createSelectYesNo( td2, inputId ); |
---|
220 | else if( (/^(io3e_[1-9]+)$/.test( inputId ) ) ) this.select_io3e = this.createSelectYesNo( td2, inputId ); |
---|
221 | else if( (/^(ico2e_[1-9]+)$/.test( inputId ) ) ) this.select_ico2e = this.createSelectYesNo( td2, inputId ); |
---|
222 | else if( (/^(irextinction_[1-9]+)$/.test( inputId ) ) ) this.select_irextinction = this.createSelectYesNo( td2, inputId ); |
---|
223 | } |
---|
224 | else if( type == 'observatories' ) this.displayObservatories( td2, inputId ); |
---|
225 | else if( type == 'spectralUnit' ) |
---|
226 | { |
---|
227 | this.displaySpectralUnits( td2, inputId ); |
---|
228 | //td2.attr({colspan:3}); |
---|
229 | } |
---|
230 | else if( type == 'ilsf' ) this.displayInstrumentalFunctions( td2, inputId ); |
---|
231 | else if( type == 'climatoReference' ) |
---|
232 | { |
---|
233 | this.displayClimatoReferences( td2, inputId ); |
---|
234 | } |
---|
235 | |
---|
236 | td2.attr( {colspan:3} ); |
---|
237 | tr.append( td2 ); |
---|
238 | container.append( tr ); |
---|
239 | }, |
---|
240 | |
---|
241 | |
---|
242 | // REQUESTS ******************************************************** |
---|
243 | requestCreateXML: function() |
---|
244 | { |
---|
245 | var tapasForm = this.createTapasObject(); |
---|
246 | //passage de javascript a json grace au jquery |
---|
247 | var jsonTapasForm = $.toJSON( tapasForm ); |
---|
248 | |
---|
249 | |
---|
250 | if( jsonTapasForm ) |
---|
251 | $.ajax( { |
---|
252 | url: "data?methodName=createUserRequest&jsonTapas=" + jsonTapasForm, |
---|
253 | success:jQuery.proxy( this.handleCreateXML, this ), |
---|
254 | error: jQuery.proxy( this.showErrors, this ) |
---|
255 | } ); |
---|
256 | }, |
---|
257 | |
---|
258 | |
---|
259 | // HANDLES ******************************************************** = retours ajax |
---|
260 | handleCreateXML: function( result ) |
---|
261 | { |
---|
262 | // TODO : gérer le bob ?? |
---|
263 | var bob = jQuery.parseJSON( result ).result; |
---|
264 | alert( bob ); |
---|
265 | }, |
---|
266 | |
---|
267 | |
---|
268 | // EVENTS ******************************************************** |
---|
269 | onClickSubmit: function() |
---|
270 | { |
---|
271 | // if( this.validFields() ) |
---|
272 | // { |
---|
273 | if( confirm( tapasTexts["confirm"] ) ) |
---|
274 | { |
---|
275 | this.containerErrors.hide(); |
---|
276 | this.requestCreateXML(); |
---|
277 | } |
---|
278 | // } |
---|
279 | }, |
---|
280 | |
---|
281 | |
---|
282 | onClickAdd: function() |
---|
283 | { |
---|
284 | //if( this.validFields() ) |
---|
285 | if( true ) |
---|
286 | { |
---|
287 | this.containerErrors.hide(); |
---|
288 | this.nbRequest++; |
---|
289 | |
---|
290 | //tabs |
---|
291 | $( ".tab_class" ).removeClass( "activated" ); |
---|
292 | this.tabActive = this.createTab(); |
---|
293 | this.numRequest = this.tabActive.numTab; |
---|
294 | |
---|
295 | //formulaires |
---|
296 | $( ".divAll" ).hide(); |
---|
297 | this.createForm(); |
---|
298 | |
---|
299 | this.updateButtons(); |
---|
300 | } |
---|
301 | }, |
---|
302 | |
---|
303 | |
---|
304 | onClickDel: function() |
---|
305 | { |
---|
306 | //if( this.validFields() ) |
---|
307 | if( true ) |
---|
308 | { |
---|
309 | var numCurrent = this.numRequest; |
---|
310 | var z = 1; |
---|
311 | |
---|
312 | //suppression onglet et form et controles calendrier caché |
---|
313 | $( "#all_" + numCurrent ).remove(); |
---|
314 | $( "#tab_request" + numCurrent ).remove(); |
---|
315 | AnyTime.noPicker( "iobservation_date_" + numCurrent ); |
---|
316 | AnyTime.noPicker( "ira_" + numCurrent ); |
---|
317 | |
---|
318 | this.tabActive.numTab = "1"; |
---|
319 | this.numRequest = "1"; |
---|
320 | |
---|
321 | for( var i = 1; i <= this.nbRequest; i++ ) |
---|
322 | { |
---|
323 | if( i > numCurrent ) |
---|
324 | { |
---|
325 | z = i - 1; |
---|
326 | document.getElementById( "all_" + i ).id = "all_" + z; |
---|
327 | $( "#tab_request" + i ).html( "Request " + z ); |
---|
328 | $( "#tab_request" + i ).attr( {name:z} ); |
---|
329 | //document.getElementById("tab_request"+i).name=z; |
---|
330 | $( "#tab_request" + i ).attr( {id:"tab_request" + z} ); |
---|
331 | $( "#tabObservation_" + i ).attr( {id:"tabObservation_" + z} ); |
---|
332 | $( "#select_iobservatory_" + i ).attr( {id:"select_iobservatory_" + z} ); |
---|
333 | $( "#select_ispectral_choice_" + i ).attr( {id:"select_ispectral_choice_" + z} ); |
---|
334 | $( "#iminspectral_ranger_" + i ).attr( {id:"iminspectral_ranger_" + z} ); |
---|
335 | $( "#imaxspectral_ranger_" + i ).attr( {id:"imaxspectral_ranger_" + z} ); |
---|
336 | $( "#select_ifunction_" + i ).attr( {id:"select_ifunction_" + z} ); |
---|
337 | $( "#select_icr_" + i ).attr( {id:"select_icr_" + z} ); |
---|
338 | $( "#ide_" + i ).attr( {id:"ide_" + z} ); |
---|
339 | $( "#iza_" + i ).attr( {id:"iza_" + z} ); |
---|
340 | $( "#irp_" + i ).attr( {id:"irp_" + z} ); |
---|
341 | $( "#isr_" + i ).attr( {id:"isr_" + z} ); |
---|
342 | $( "#select_iformat_" + i ).attr( {id:"select_iformat_" + z} ); |
---|
343 | $( "#select_irextinction_" + i ).attr( {id:"select_irextinction_" + z} ); |
---|
344 | $( "#select_ih2oe_" + i ).attr( {id:"select_ih2oe_" + z} ); |
---|
345 | $( "#select_io2e_" + i ).attr( {id:"select_io2e_" + z} ); |
---|
346 | $( "#select_io3e_" + i ).attr( {id:"select_io3e_" + z} ); |
---|
347 | $( "#select_ico2e_" + i ).attr( {id:"select_ico2e_" + z} ); |
---|
348 | |
---|
349 | // Supression du calendrier puis re-création en insérant l'ancienne date |
---|
350 | var oldDate = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() ); |
---|
351 | AnyTime.noPicker( "iobservation_date_" + i ); |
---|
352 | this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, oldDate, false ); |
---|
353 | $( "#iobservation_date_" + i ).attr( {id:"iobservation_date_" + z} ); |
---|
354 | |
---|
355 | // Idem pour les heures !!! |
---|
356 | // TODO : voir si besoin de parser les heures ou non |
---|
357 | // var oldTime = this.timeConverter.parse( $( "#ira_" + i ).val() ); |
---|
358 | var oldTime = $( "#ira_" + i ).val(); |
---|
359 | AnyTime.noPicker( "ira_" + i ); |
---|
360 | this.createTime( $( "#tabObservation_" + z ), tapasTexts["label.ira"], "ira_" + z, oldTime, false ); |
---|
361 | $( "#ira_" + i ).attr( {id:"ira_" + z} ); |
---|
362 | } |
---|
363 | } |
---|
364 | |
---|
365 | this.nbRequest--; |
---|
366 | |
---|
367 | // Mise à jour des boutons |
---|
368 | this.updateButtons(); |
---|
369 | |
---|
370 | //tabs |
---|
371 | $( ".tab_class" ).removeClass( "activated" ); |
---|
372 | $( "#tab_request1" ).addClass( "activated" ); |
---|
373 | |
---|
374 | //formulaires |
---|
375 | $( ".divAll" ).hide(); |
---|
376 | $( "#all_1" ).show(); |
---|
377 | } |
---|
378 | }, |
---|
379 | |
---|
380 | |
---|
381 | onClickTab: function( event ) |
---|
382 | { |
---|
383 | var realTabId = $( "#" + event.currentTarget.id ).attr( "name" ); |
---|
384 | var clickedDiv = event.data; |
---|
385 | |
---|
386 | //tabs |
---|
387 | $( ".tab_class" ).removeClass( "activated" ); |
---|
388 | clickedDiv.divContainer.addClass( "activated" ); |
---|
389 | |
---|
390 | //forms |
---|
391 | $( ".divAll" ).hide(); |
---|
392 | $( "#all_" + realTabId ).show(); |
---|
393 | |
---|
394 | this.numRequest = realTabId; |
---|
395 | this.tabActive.numTab = realTabId; |
---|
396 | |
---|
397 | this.updateButtons(); |
---|
398 | }, |
---|
399 | |
---|
400 | |
---|
401 | // OTHERS ******************************************************** |
---|
402 | displayFileFormats: function( container, id ) |
---|
403 | { |
---|
404 | var paramSelect = new Object(); |
---|
405 | paramSelect.id = "select_" + id; |
---|
406 | paramSelect.parent = container; |
---|
407 | this.selectFormats = new Select( paramSelect ); |
---|
408 | jQuery.each( this.jSonFileFormats, jQuery.proxy( function ( i, jsonFileFormat ) |
---|
409 | { |
---|
410 | this.selectFormats.add( jsonFileFormat.value, jsonFileFormat.text ); |
---|
411 | }, this ) ); |
---|
412 | this.selectFormats.selectFirst( false ); |
---|
413 | }, |
---|
414 | |
---|
415 | |
---|
416 | displayObservatories: function( container, id ) |
---|
417 | { |
---|
418 | var paramSelect = new Object(); |
---|
419 | paramSelect.id = "select_" + id; |
---|
420 | paramSelect.parent = container; |
---|
421 | this.selectObservatories = new Select( paramSelect ); |
---|
422 | //ajouter select vide avec add |
---|
423 | this.selectObservatories.add( "-1", "-- " + tapasTexts["text.select"] + " --" ); |
---|
424 | jQuery.each( this.jSonObservatories, jQuery.proxy( function ( i, jsonObservatory ) |
---|
425 | { |
---|
426 | this.selectObservatories.add( jsonObservatory.id, jsonObservatory.name ); |
---|
427 | }, this ) ); |
---|
428 | this.selectObservatories.selectFirst( true ); |
---|
429 | }, |
---|
430 | |
---|
431 | |
---|
432 | displaySpectralUnits: function( container, id ) |
---|
433 | { |
---|
434 | var paramSelect = new Object(); |
---|
435 | paramSelect.id = "select_" + id; |
---|
436 | paramSelect.parent = container; |
---|
437 | this.selectSpectralUnits = new Select( paramSelect ); |
---|
438 | //ajouter select vide avec add |
---|
439 | this.selectSpectralUnits.add( "-1", "-- " + tapasTexts["text.select"] + " --" ); |
---|
440 | jQuery.each( this.jSonSpectralUnits, jQuery.proxy( function ( i, jsonSpectralUnit ) |
---|
441 | { |
---|
442 | this.selectSpectralUnits.add( jsonSpectralUnit.value, tapasTexts[jsonSpectralUnit.value] ); |
---|
443 | //this.selectSpectralUnits.add( jsonSpectralUnit.value, jsonSpectralUnit.value ); |
---|
444 | }, this ) ); |
---|
445 | this.selectSpectralUnits.selectFirst( true ); |
---|
446 | }, |
---|
447 | |
---|
448 | displayInstrumentalFunctions: function( container, id ) |
---|
449 | { |
---|
450 | var paramSelect = new Object(); |
---|
451 | paramSelect.id = "select_" + id; |
---|
452 | paramSelect.parent = container; |
---|
453 | this.selectInstrumentalFunctions = new Select( paramSelect ); |
---|
454 | //ajouter select vide avec add |
---|
455 | jQuery.each( this.jSonInstrumentalFunctions, jQuery.proxy( function ( i, jsonInstrumentalFunction ) |
---|
456 | { |
---|
457 | this.selectInstrumentalFunctions.add( jsonInstrumentalFunction.value, tapasTexts[jsonInstrumentalFunction.text] ); |
---|
458 | }, this ) ); |
---|
459 | this.selectInstrumentalFunctions.selectFirst( true ); |
---|
460 | }, |
---|
461 | |
---|
462 | |
---|
463 | displayClimatoReferences: function( container, id ) |
---|
464 | { |
---|
465 | var paramSelect = new Object(); |
---|
466 | paramSelect.id = "select_" + id; |
---|
467 | paramSelect.parent = container; |
---|
468 | this.selectClimatoReferences = new Select( paramSelect ); |
---|
469 | //ajouter select vide avec add |
---|
470 | jQuery.each( this.jSonClimatoReferences, jQuery.proxy( function ( i, jsonClimatoReference ) |
---|
471 | { |
---|
472 | this.selectClimatoReferences.add( jsonClimatoReference.value, tapasTexts[jsonClimatoReference.text] ); |
---|
473 | }, this ) ); |
---|
474 | this.selectClimatoReferences.selectFirst( true ); |
---|
475 | }, |
---|
476 | |
---|
477 | |
---|
478 | showErrors: function( result ) |
---|
479 | { |
---|
480 | //this.containerErrors.show(); |
---|
481 | // this.containerErrors.html( tapasTexts[result.responseText] ); |
---|
482 | }, |
---|
483 | |
---|
484 | |
---|
485 | |
---|
486 | createForm: function() |
---|
487 | { |
---|
488 | this.divErreurs = $( document.createElement( "div" ) ); |
---|
489 | this.divErreurs.addClass( "errorsForm" ); |
---|
490 | this.divErreurs.hide(); |
---|
491 | |
---|
492 | var divAll = $( document.createElement( "div" ) ); |
---|
493 | divAll.attr( {id:"all_" + this.nbRequest, class:"divAll"} ); |
---|
494 | |
---|
495 | |
---|
496 | //Creation div |
---|
497 | var divPreference = $( document.createElement( "div" ) ); |
---|
498 | var tabPreference = $( document.createElement( "table" ) ); |
---|
499 | tabPreference.attr( {cellspacing:3} ); |
---|
500 | |
---|
501 | var divObservation = $( document.createElement( "div" ) ); |
---|
502 | var tabObservation = $( document.createElement( "table" ) ); |
---|
503 | //tabObservation.attr({border:1}); |
---|
504 | tabObservation.attr( {id:"tabObservation_" + this.nbRequest, cellspacing:3} ); |
---|
505 | |
---|
506 | |
---|
507 | var divAtmosphere = $( document.createElement( "div" ) ); |
---|
508 | var tabAtmosphere = $( document.createElement( "table" ) ); |
---|
509 | |
---|
510 | |
---|
511 | var fieldSetObservation = $( document.createElement( "fieldset" ) ); |
---|
512 | fieldSetObservation.addClass( "cfs1" ); |
---|
513 | divObservation.append( fieldSetObservation ); |
---|
514 | |
---|
515 | var legendObservation = $( document.createElement( "legend" ) ); |
---|
516 | legendObservation.html( "Observation" ); |
---|
517 | fieldSetObservation.append( legendObservation ); |
---|
518 | legendObservation.addClass( "containerField" ); |
---|
519 | |
---|
520 | var fieldSetPreference = $( document.createElement( "fieldset" ) ); |
---|
521 | fieldSetPreference.addClass( "cfs2" ); |
---|
522 | divPreference.append( fieldSetPreference ); |
---|
523 | |
---|
524 | var legendPreference = $( document.createElement( "legend" ) ); |
---|
525 | legendPreference.html( tapasTexts["label.preferences"] ); |
---|
526 | fieldSetPreference.append( legendPreference ); |
---|
527 | legendPreference.addClass( "containerField" ); |
---|
528 | |
---|
529 | fieldSetObservation.append( tabObservation ); |
---|
530 | divObservation.addClass( "divObservation" ); |
---|
531 | divAll.append( divObservation ); |
---|
532 | |
---|
533 | |
---|
534 | divAtmosphere.append( tabAtmosphere ); |
---|
535 | //divAtmosphere.addClass("divAtmosphere"); |
---|
536 | //this.containerForm.append( divAtmosphere ); |
---|
537 | fieldSetObservation.append( divAtmosphere ); |
---|
538 | |
---|
539 | fieldSetPreference.append( tabPreference ); |
---|
540 | divPreference.addClass( "divPreference" ); |
---|
541 | divAll.append( divPreference ); |
---|
542 | |
---|
543 | this.containerForm.append( divAll ); |
---|
544 | this.containerForm.append( this.divErreurs ); |
---|
545 | //this.tabInput = new Array(3); |
---|
546 | |
---|
547 | this.createTrList( tapasTexts["label.format"], "iformat_" + this.nbRequest, tabPreference, 'format' ); |
---|
548 | this.createTrList( tapasTexts["label.era"], "irextinction_" + this.nbRequest, tabPreference, 'yesno' ); |
---|
549 | this.createTrList( tapasTexts["label.eh2o"], "ih2oe_" + this.nbRequest, tabPreference, 'yesno' ); |
---|
550 | this.createTrList( tapasTexts["label.eo3"], "io3e_" + this.nbRequest, tabPreference, 'yesno' ); |
---|
551 | this.createTrList( tapasTexts["label.eo2"], "io2e_" + this.nbRequest, tabPreference, 'yesno' ); |
---|
552 | this.createTrList( tapasTexts["label.eco2"], "ico2e_" + this.nbRequest, tabPreference, 'yesno' ); |
---|
553 | |
---|
554 | this.createTrList( tapasTexts["label.observatory"], "iobservatory_" + this.nbRequest, tabObservation, 'observatories' ); |
---|
555 | this.createCalendar( tabObservation, tapasTexts["label.datemesure"], "iobservation_date_" + this.nbRequest, false, true ); |
---|
556 | |
---|
557 | //unite |
---|
558 | this.createTrList( tapasTexts["label.spectralUnit"], "ispectral_choice_" + this.nbRequest, tabObservation, 'spectralUnit' ); |
---|
559 | this.createTr2Input( tapasTexts["label.spectralRange"], tapasTexts["label.to"], "iminspectral_ranger_" + this.nbRequest, "imaxspectral_ranger_" + this.nbRequest, tabObservation, "[350,2500] nm" ); |
---|
560 | |
---|
561 | //fonction instrumentale |
---|
562 | this.createTrList( tapasTexts["label.ifunction"], "ifunction_" + this.nbRequest, tabObservation, "ilsf" ); |
---|
563 | //reference climato |
---|
564 | //this.createTrList( tapasTexts["label.climato"], "icr", tabAtmosphere, "climatoReference" ); |
---|
565 | this.createTrList( tapasTexts["label.climato"], "icr_" + this.nbRequest, tabObservation, "climatoReference" ); |
---|
566 | |
---|
567 | |
---|
568 | //this.createTr( tapasTexts["label.ira"], "ira", tabObservation ); |
---|
569 | this.createTime( tabObservation, tapasTexts["label.ira"], "ira_" + this.nbRequest, false, true ); |
---|
570 | this.createTr( tapasTexts["label.ide"], "ide_" + this.nbRequest, tabObservation, "hh:mm:ss.ms [-90,90] °" ); |
---|
571 | this.createTr( tapasTexts["label.iza"], "iza_" + this.nbRequest, tabObservation, "[0,90] °" ); |
---|
572 | |
---|
573 | this.createTr( tapasTexts["label.resolution"], "irp_" + this.nbRequest, tabObservation, "" ); |
---|
574 | this.createTr( tapasTexts["label.ratio"], "isr_" + this.nbRequest, tabObservation, "" ); |
---|
575 | |
---|
576 | |
---|
577 | //jQuery.proxy permet d'envoyer le contexte this courant |
---|
578 | |
---|
579 | }, |
---|
580 | |
---|
581 | |
---|
582 | |
---|
583 | createTapasObject: function() |
---|
584 | { |
---|
585 | |
---|
586 | var requests = new Array(); |
---|
587 | |
---|
588 | for( var i = 1; i <= this.nbRequest; i++ ) |
---|
589 | { |
---|
590 | // PREFERENCE |
---|
591 | var preference = new Object(); |
---|
592 | |
---|
593 | preference.format = new Object(); |
---|
594 | //toutes les valeurs possibles |
---|
595 | preference.format.firstValue = this.selectFormats.getValuesInString(); |
---|
596 | |
---|
597 | //la valeur selectionnee |
---|
598 | preference.format.secondValue = this.selectFormats.getValue(); |
---|
599 | |
---|
600 | preference.rayleighExtinction = new Object(); |
---|
601 | preference.rayleighExtinction.firstValue = this.select_ih2oe.getValuesInString(); |
---|
602 | preference.rayleighExtinction.secondValue = this.select_irextinction.getValue(); |
---|
603 | |
---|
604 | |
---|
605 | preference.h2oExtinction = new Object(); |
---|
606 | preference.h2oExtinction.firstValue = this.select_ih2oe.getValuesInString(); |
---|
607 | preference.h2oExtinction.secondValue = this.select_ih2oe.getValue(); |
---|
608 | |
---|
609 | |
---|
610 | preference.o3Extinction = new Object(); |
---|
611 | preference.o3Extinction.firstValue = this.select_io3e.getValuesInString(); |
---|
612 | preference.o3Extinction.secondValue = this.select_io3e.getValue(); |
---|
613 | |
---|
614 | preference.o2Extinction = new Object(); |
---|
615 | preference.o2Extinction.firstValue = this.select_io2e.getValuesInString(); |
---|
616 | preference.o2Extinction.secondValue = this.select_io2e.getValue(); |
---|
617 | |
---|
618 | preference.co2Extinction = new Object(); |
---|
619 | preference.co2Extinction.firstValue = this.select_ico2e.getValuesInString(); |
---|
620 | preference.co2Extinction.secondValue = this.select_ico2e.getValue(); |
---|
621 | |
---|
622 | |
---|
623 | // OBSERVATION |
---|
624 | var observatory = new Object(); |
---|
625 | |
---|
626 | //observatory.id = this.selectObservatories.getValue(); |
---|
627 | observatory.id = "3"; |
---|
628 | |
---|
629 | // Los |
---|
630 | var los = new Object(); |
---|
631 | |
---|
632 | |
---|
633 | los.raJ2000 = $( "#ira_" + i ).val(); |
---|
634 | los.decJ2000 = $( "#ide_" + i ).val(); |
---|
635 | |
---|
636 | |
---|
637 | los.zenithAngle = $( "#iza_" + i ).val(); |
---|
638 | |
---|
639 | |
---|
640 | // Instrument |
---|
641 | var instrument = new Object(); |
---|
642 | |
---|
643 | instrument.ilsfChoice = new Object(); |
---|
644 | instrument.ilsfChoice.firstValue = this.selectInstrumentalFunctions.getValuesInString(); |
---|
645 | instrument.ilsfChoice.secondValue = this.selectInstrumentalFunctions.getValue(); |
---|
646 | |
---|
647 | instrument.spectralChoice = new Object(); |
---|
648 | |
---|
649 | this.selectSpectralUnits.remove( "-1" ); |
---|
650 | instrument.spectralChoice.firstValue = this.selectSpectralUnits.getValuesInString(); |
---|
651 | instrument.spectralChoice.secondValue = this.selectSpectralUnits.getValue(); |
---|
652 | |
---|
653 | instrument.spectralRange = $( "#iminspectral_ranger_" + i ).val() + ' ' + $( "#imaxspectral_ranger_" + i ).val(); |
---|
654 | |
---|
655 | |
---|
656 | instrument.resolvingPower = new Object(); |
---|
657 | instrument.resolvingPower.firstValue = "0"; |
---|
658 | instrument.resolvingPower.secondValue = $( "#irp_" + i ).val(); |
---|
659 | |
---|
660 | instrument.samplingRatio = new Object(); |
---|
661 | instrument.samplingRatio.firstValue = "0"; |
---|
662 | instrument.samplingRatio.secondValue = $( "#isr_" + i ).val(); |
---|
663 | |
---|
664 | var observation = new Object(); |
---|
665 | observation.date = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() ); |
---|
666 | observation.observatory = observatory; |
---|
667 | |
---|
668 | observation.los = los; |
---|
669 | observation.instrument = instrument; |
---|
670 | |
---|
671 | |
---|
672 | // ATMOSPHERE |
---|
673 | var atmosphere = new Object(); |
---|
674 | |
---|
675 | atmosphere.reference = new Object(); |
---|
676 | atmosphere.reference.firstValue = this.selectClimatoReferences.getValuesInString(); |
---|
677 | atmosphere.reference.secondValue = this.selectClimatoReferences.getValue(); |
---|
678 | |
---|
679 | |
---|
680 | // REQUEST |
---|
681 | var request = new Object(); |
---|
682 | request.id = i; |
---|
683 | request.preference = preference; |
---|
684 | request.observation = observation; |
---|
685 | request.atmosphere = atmosphere; |
---|
686 | |
---|
687 | requests[i] = request; |
---|
688 | } |
---|
689 | |
---|
690 | // TAPAS |
---|
691 | var tapas = new Object(); |
---|
692 | tapas.requests = requests; |
---|
693 | return tapas; |
---|
694 | }, |
---|
695 | |
---|
696 | validFields: function() |
---|
697 | { |
---|
698 | return ( |
---|
699 | isSup( this.selectObservatories.getValue(), 0, tapasTexts["label.observatory"], tapasTexts["text.toselect"], this.containerErrors ) && |
---|
700 | isDiff( this.selectSpectralUnits.getValue(), -1, tapasTexts["label.spectralUnit"], tapasTexts["text.toselect"] ) && |
---|
701 | isValidRange( $( "#iminspectral_ranger" ).val(), $( "#imaxspectral_ranger" ).val(), this.selectSpectralUnits.getValue(), tapasTexts["label.spectralRange"], tapasTexts["text.badvalue"] ) && |
---|
702 | isDeg( $( "#ide" ).val(), tapasTexts["label.ide"], tapasTexts["text.badvalue"] ) && |
---|
703 | isValidNum( $( "#iza" ).val(), tapasTexts["label.iza"], tapasTexts["text.badvalue"] ) && isBetween( $( "#iza" ).val(), 0, 90, tapasTexts["label.iza"], tapasTexts["text.badvalue"] ) && |
---|
704 | isValidNum( $( "#irp" ).val(), tapasTexts["label.resolution"], tapasTexts["text.badvalue"] ) && isSup( $( "#irp" ).val(), 1, tapasTexts["label.resolution"], tapasTexts["text.badvalue"] ) && |
---|
705 | isValidNum( $( "#isr" ).val(), tapasTexts["label.ratio"], tapasTexts["text.badvalue"] ) && isSup( $( "#isr" ).val(), 1, tapasTexts["label.ratio"], tapasTexts["text.badvalue"] ) |
---|
706 | ) |
---|
707 | }, |
---|
708 | |
---|
709 | updateButtons: function() |
---|
710 | { |
---|
711 | if( 1 < this.nbRequest ) |
---|
712 | this.delRequestButton.enable(); |
---|
713 | else |
---|
714 | this.delRequestButton.disable(); |
---|
715 | |
---|
716 | if( 9 <= this.nbRequest ) |
---|
717 | this.addRequestButton.disable(); |
---|
718 | else |
---|
719 | this.addRequestButton.enable(); |
---|
720 | } |
---|
721 | |
---|
722 | } ); |
---|
723 | |
---|
724 | </script> |
---|