1 | |
---|
2 | <script type="text/javascript"> |
---|
3 | |
---|
4 | |
---|
5 | var InterfaceTapas = Class.create( { |
---|
6 | initialize: function( jsonFileFormats, jsonYesNos, jsonObservatories, jsonSpectralUnits, jsonInstrumentalFunctions, jsonClimatoReferences ) |
---|
7 | { |
---|
8 | /** *********** CONTAINERS *********** **/ |
---|
9 | this.containerForm = $( "#formulaire" ); |
---|
10 | //this.containerErrors = $( "#errForm" ); |
---|
11 | //this.divE= $( "#divErreurs"); |
---|
12 | this.containerCenter = $( "#containerCenter" ); |
---|
13 | this.containerTabs = $( "#tab" ); |
---|
14 | |
---|
15 | /** *********** VARIABLES *********** **/ |
---|
16 | this.jSonFileFormats = jsonFileFormats || null; |
---|
17 | this.selectFileFormatsList = new Object(); |
---|
18 | |
---|
19 | this.jSonYesNos = jsonYesNos || null; |
---|
20 | this.select_ih2oeList = new Object(); |
---|
21 | this.select_io2eList = new Object(); |
---|
22 | this.select_io3eList = new Object(); |
---|
23 | this.select_ico2eList = new Object(); |
---|
24 | this.select_irextinctionList = new Object(); |
---|
25 | this.select_ibervCList = new Object(); |
---|
26 | |
---|
27 | this.jSonObservatories = jsonObservatories || false; |
---|
28 | this.selectObservatoriesList = new Object(); |
---|
29 | this.jSonSpectralUnits = jsonSpectralUnits || null; |
---|
30 | this.selectSpectralUnitsList = new Object(); |
---|
31 | this.jSonInstrumentalFunctions = jsonInstrumentalFunctions || null; |
---|
32 | this.selectInstrumentalFunctionsList = new Object(); |
---|
33 | this.jSonClimatoReferences = jsonClimatoReferences || null; |
---|
34 | this.selectClimatoReferencesList = new Object(); |
---|
35 | this.nbRequest = 1; |
---|
36 | this.tabActive = false; |
---|
37 | this.numRequest = 1; |
---|
38 | |
---|
39 | this.language = tapasTexts["language"] ; |
---|
40 | this.browser="Firefox"; |
---|
41 | |
---|
42 | if (navigator.userAgent.indexOf('Firefox') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox') + 8)) >= 3.6){ |
---|
43 | this.browser="Firefox"; |
---|
44 | } |
---|
45 | else if (navigator.userAgent.indexOf('Chrome') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Chrome') + 7).split(' ')[0]) >= 15){ |
---|
46 | this.browser="Chrome"; |
---|
47 | } |
---|
48 | else if(navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Version') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Version') + 8).split(' ')[0]) >= 5){ |
---|
49 | this.browser="Safari"; |
---|
50 | } |
---|
51 | |
---|
52 | // Buttons |
---|
53 | 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 )} ); |
---|
54 | this.addRequestButton = new Button( {title:tapasTexts["label.title.add"],value:tapasTexts["label.addButton"], parent:this.containerCenter, id:"button_add", className: "positive", onClick:jQuery.proxy( this.onClickAdd, this )} ); |
---|
55 | this.delRequestButton = new Button( {title:tapasTexts["label.title.del"],value:tapasTexts["label.delButton"], parent:this.containerCenter, id:"button_del", className: "negative", onClick:jQuery.proxy( this.onClickDel, this )} ); |
---|
56 | this.delRequestButton.disable(); |
---|
57 | |
---|
58 | this.createForm(); |
---|
59 | this.tabActive = this.createTab(); |
---|
60 | this.divE = $( document.createElement( "div" ) ); |
---|
61 | this.divE.attr( {id:"divErrors", class:"errorsForm"} ); |
---|
62 | /*var fieldSetE = $( document.createElement( "fieldset" ) ); |
---|
63 | fieldSetE.addClass( "cfs3" ); |
---|
64 | this.divE.append( fieldSetE );*/ |
---|
65 | |
---|
66 | this.containerForm.append( this.divE ); |
---|
67 | //this.containerErrors.hide(); |
---|
68 | this.divE.hide(); |
---|
69 | |
---|
70 | /** *********** LOADING *********** **/ |
---|
71 | var param = new Object(); |
---|
72 | param.id = "loadingForRequest"; |
---|
73 | param.parent = this.containerForm; |
---|
74 | param.className = "loading-classic"; |
---|
75 | this.loadingRequest = new Loading( param ); |
---|
76 | //this.loadingRequest.display(); |
---|
77 | }, |
---|
78 | |
---|
79 | |
---|
80 | // CREATES ******************************************************** |
---|
81 | createTab:function() |
---|
82 | { |
---|
83 | 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 )} ); |
---|
84 | ntab.active(); |
---|
85 | return ntab; |
---|
86 | }, |
---|
87 | |
---|
88 | |
---|
89 | createCalendar: function( containerCalendar, texte, inputDateId, currentDate, isTrToCreate ) |
---|
90 | { |
---|
91 | if( isTrToCreate ) |
---|
92 | { |
---|
93 | // Create input for date text |
---|
94 | var tr = $( document.createElement( "tr" ) ); |
---|
95 | var td1 = $( document.createElement( "td" ) ); |
---|
96 | var td2 = $( document.createElement( "td" ) ); |
---|
97 | var inputDate = $( document.createElement( "input" ) ); |
---|
98 | inputDate.attr( {id:inputDateId, size:"17"} ); |
---|
99 | |
---|
100 | td1.html( texte ); |
---|
101 | td1.attr( { class:"containerLabel" } ); |
---|
102 | tr.append( td1 ); |
---|
103 | |
---|
104 | td2.attr( {colspan:4} ); |
---|
105 | td2.append( inputDate ); |
---|
106 | tr.append( td2 ); |
---|
107 | containerCalendar.append( tr ); |
---|
108 | } |
---|
109 | |
---|
110 | // Calendar |
---|
111 | this.calendarFormat = "%Y-%m-%d %H:%i:%s"; |
---|
112 | this.calendarConverter = new AnyTime.Converter( { format: this.calendarFormat } ); |
---|
113 | |
---|
114 | AnyTime.picker( inputDateId, { format: this.calendarFormat, firstDOW: 1, |
---|
115 | labelTitle: "Select Date", labelYear: "Year", labelMonth: "Month", labelDayOfMonth: "Day", |
---|
116 | labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second" |
---|
117 | } ); |
---|
118 | |
---|
119 | // Ajout de la date courrante ds le calendrier SI currentDate non précisée |
---|
120 | if( !currentDate ) |
---|
121 | currentDate = new Date(); |
---|
122 | |
---|
123 | |
---|
124 | $( "#" + inputDateId ).val( this.calendarConverter.format( currentDate ) ); |
---|
125 | $( "#" + inputDateId ).addClass( "calendar" ); |
---|
126 | |
---|
127 | }, |
---|
128 | |
---|
129 | |
---|
130 | // CREATES ******************************************************** |
---|
131 | createTime: function( containerCalendar, texte, inputDateId, currentTime, isTrToCreate, text2 ) |
---|
132 | { |
---|
133 | if( isTrToCreate ) |
---|
134 | { |
---|
135 | |
---|
136 | // Create input for date text |
---|
137 | var tr = $( document.createElement( "tr" ) ); |
---|
138 | var td1 = $( document.createElement( "td" ) ); |
---|
139 | var td2 = $( document.createElement( "td" ) ); |
---|
140 | var td3 = $( document.createElement( "td" ) ); |
---|
141 | var inputDate = $( document.createElement( "input" ) ); |
---|
142 | inputDate.attr( {id:inputDateId, size:"10"} ); |
---|
143 | |
---|
144 | td1.html( texte ); |
---|
145 | td1.attr( { class:"containerLabel" } ); |
---|
146 | tr.append( td1 ); |
---|
147 | |
---|
148 | td2.attr( {colspan:1} ); |
---|
149 | td2.append( inputDate ); |
---|
150 | tr.append( td2 ); |
---|
151 | |
---|
152 | td3.html( text2 ); |
---|
153 | td3.attr( { class:"containerLabel2" } ); |
---|
154 | tr.append( td3 ); |
---|
155 | |
---|
156 | containerCalendar.append( tr ); |
---|
157 | } |
---|
158 | |
---|
159 | // Time |
---|
160 | this.timeFormat = "%H:%i:%s"; |
---|
161 | this.timeConverter = new AnyTime.Converter( { format: this.timeFormat } ); |
---|
162 | |
---|
163 | AnyTime.picker( inputDateId, { format: this.timeFormat, firstDOW: 1, |
---|
164 | labelTitle: "Select hour", labelHour: "Hour", labelMinute: "Minute", labelSecond: "Second" |
---|
165 | } ); |
---|
166 | |
---|
167 | if( !currentTime ) |
---|
168 | currentTime = "00:00:00"; |
---|
169 | // TODO : voir si besoin de convertir format des heures |
---|
170 | // $( "#" + inputDateId ).val( this.timeConverter.format( currentTime ) ); |
---|
171 | $( "#" + inputDateId ).val( currentTime ); |
---|
172 | $( "#" + inputDateId ).addClass( "time" ); |
---|
173 | }, |
---|
174 | |
---|
175 | |
---|
176 | createTr: function( texte, inputId, container, textesup, event, champ, ctnb, info ) |
---|
177 | { |
---|
178 | |
---|
179 | var tr = $( document.createElement( "tr" ) ); |
---|
180 | var td1 = $( document.createElement( "td" ) ); |
---|
181 | var td2 = $( document.createElement( "td" ) ); |
---|
182 | var td3 = $( document.createElement( "td" ) ); |
---|
183 | var input = $( document.createElement( "input" ) ); |
---|
184 | |
---|
185 | input.attr( {id: inputId, class:"containerText"+ctnb, size:11} ); |
---|
186 | |
---|
187 | |
---|
188 | if (event.length > 0) input.bind( event, [this, champ], this.angleChoice ); |
---|
189 | |
---|
190 | td1.html( texte ); |
---|
191 | td1.attr( {class:"containerLabel"} ); |
---|
192 | |
---|
193 | td3.html( textesup ); |
---|
194 | td3.attr( {class:"containerLabel2", colspan:3} ); |
---|
195 | tr.append( td1 ); |
---|
196 | td2.append( input ); |
---|
197 | |
---|
198 | tr.append( td2 ); |
---|
199 | tr.append( td3 ); |
---|
200 | container.append( tr ); |
---|
201 | |
---|
202 | var re1 = new RegExp("isr_"); |
---|
203 | var re2 = new RegExp("irp_"); |
---|
204 | |
---|
205 | if (info && (inputId.match(re1) || inputId.match(re2))) { |
---|
206 | var mt="-4px"; |
---|
207 | var ml=""; |
---|
208 | |
---|
209 | if (this.browser == "Firefox") { |
---|
210 | if (this.language == "en") ml="-252px"; |
---|
211 | else ml="-244px"; |
---|
212 | } |
---|
213 | else if (this.browser == "Chrome") { |
---|
214 | if (this.language == "en") ml="-227px"; |
---|
215 | else ml="-223px"; |
---|
216 | } |
---|
217 | |
---|
218 | var img = $( document.createElement( "img" ) ); |
---|
219 | var a = $( document.createElement( "a" ) ); |
---|
220 | var div = $( document.createElement( "div" ) ); |
---|
221 | img.attr("src","resources/images/info.png"); |
---|
222 | img.attr("width","19"); |
---|
223 | a.attr("style","cursor:pointer"); |
---|
224 | |
---|
225 | img.bind("click",[inputId,450,100,this],this.onClickInfos); |
---|
226 | a.append(img); |
---|
227 | div.append(a); |
---|
228 | div.attr( "style","margin-left:"+ml+";margin-top:"+mt); |
---|
229 | |
---|
230 | tr.append( div ); |
---|
231 | |
---|
232 | /*td2.attr( {colspan:3} ); |
---|
233 | tr.append( td2 ); |
---|
234 | tr.append( div );*/ |
---|
235 | } |
---|
236 | else if (info) { |
---|
237 | var img = $( document.createElement( "img" ) ); |
---|
238 | var a = $( document.createElement( "a" ) ); |
---|
239 | img.attr("src","resources/images/info.png"); |
---|
240 | img.attr("width","19"); |
---|
241 | a.attr("style","cursor:pointer"); |
---|
242 | img.bind("click",[inputId,450,100,this],this.onClickInfos); |
---|
243 | a.append(img); |
---|
244 | td3.append(a); |
---|
245 | |
---|
246 | } |
---|
247 | }, |
---|
248 | |
---|
249 | |
---|
250 | createTrTxt: function( texte, container ) |
---|
251 | { |
---|
252 | var tr = $( document.createElement( "tr" ) ); |
---|
253 | var td1 = $( document.createElement( "td" ) ); |
---|
254 | |
---|
255 | td1.html( texte ); |
---|
256 | td1.attr( {class:"containerLabelT", colspan:4} ); |
---|
257 | |
---|
258 | tr.append( td1 ); |
---|
259 | container.append( tr ); |
---|
260 | |
---|
261 | |
---|
262 | }, |
---|
263 | |
---|
264 | |
---|
265 | |
---|
266 | createTr2Input: function( texte1, texte2, inputId1, inputId2, container, textesup ) |
---|
267 | { |
---|
268 | var tr = $( document.createElement( "tr" ) ); |
---|
269 | var td1 = $( document.createElement( "td" ) ); |
---|
270 | var td2 = $( document.createElement( "td" ) ); |
---|
271 | var td3 = $( document.createElement( "td" ) ); |
---|
272 | var td4 = $( document.createElement( "td" ) ); |
---|
273 | var td5 = $( document.createElement( "td" ) ); |
---|
274 | var td6 = $( document.createElement( "td" ) ); |
---|
275 | var input1 = $( document.createElement( "input" ) ); |
---|
276 | var input2 = $( document.createElement( "input" ) ); |
---|
277 | |
---|
278 | |
---|
279 | input1.attr( {id: inputId1,class:"containerText",size:11} ); |
---|
280 | input2.attr( {id: inputId2,class:"containerText",size:11} ); |
---|
281 | |
---|
282 | td1.html( texte1 ); |
---|
283 | td3.html( texte2 ); |
---|
284 | td5.html( textesup ); |
---|
285 | var img = $( document.createElement( "img" ) ); |
---|
286 | var a = $( document.createElement( "a" ) ); |
---|
287 | img.attr("src","resources/images/info.png"); |
---|
288 | img.attr("width","19"); |
---|
289 | a.attr("style","cursor:pointer"); |
---|
290 | img.bind("click",["spectral_range",450,100,this],this.onClickInfos); |
---|
291 | a.append(img); |
---|
292 | td5.append(a); |
---|
293 | |
---|
294 | //img.onclick(this.onClickInfos("spectral_range",1200,440)); |
---|
295 | |
---|
296 | td1.attr( {class:"containerLabel"} ); |
---|
297 | td3.attr( {class:"containerLabel3"} ); |
---|
298 | td5.attr( {class:"containerLabel2"} ); |
---|
299 | |
---|
300 | td2.append( input1 ); |
---|
301 | //td2.html( texte2 ); |
---|
302 | td4.append( input2 ); |
---|
303 | |
---|
304 | tr.append( td1 ); |
---|
305 | tr.append( td2 ); |
---|
306 | tr.append( td3 ); |
---|
307 | tr.append( td4 ); |
---|
308 | tr.append( td5 ); |
---|
309 | tr.append( td6 ); |
---|
310 | container.append( tr ); |
---|
311 | }, |
---|
312 | |
---|
313 | |
---|
314 | |
---|
315 | createTrList: function( texte, inputId, index, container, type, info ) |
---|
316 | { |
---|
317 | var tr = $( document.createElement( "tr" ) ); |
---|
318 | var td1 = $( document.createElement( "td" ) ); |
---|
319 | var td2 = $( document.createElement( "td" ) ); |
---|
320 | var input = $( document.createElement( "input" ) ); |
---|
321 | var champ="", ml="", mt="-4px"; |
---|
322 | |
---|
323 | var div = $( document.createElement( "div" ) ); |
---|
324 | |
---|
325 | input.attr( {id: inputId} ); |
---|
326 | |
---|
327 | td1.html( texte ); |
---|
328 | td1.attr( {class:"containerLabel"} ); |
---|
329 | tr.append( td1 ); |
---|
330 | |
---|
331 | |
---|
332 | // alert(inputId); |
---|
333 | if( 'format' == type ) { |
---|
334 | this.displaySelect( td2, inputId, index, this.jSonFileFormats, this.selectFileFormatsList, false, null ); |
---|
335 | info = true; |
---|
336 | champ = "iformat_"; |
---|
337 | ml="-2px"; |
---|
338 | mt="-4px"; |
---|
339 | } |
---|
340 | |
---|
341 | else |
---|
342 | if( 'yesno' == type ) |
---|
343 | { |
---|
344 | if( (/^(ih2oe_[1-9]+)$/.test( inputId ) ) ) |
---|
345 | this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_ih2oeList, false, "yesNos" ); |
---|
346 | else if( (/^(io2e_[1-9]+)$/.test( inputId ) ) ) |
---|
347 | this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_io2eList, false, "yesNos" ); |
---|
348 | else if( (/^(io3e_[1-9]+)$/.test( inputId ) ) ) |
---|
349 | this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_io3eList, false, "yesNos" ); |
---|
350 | else if( (/^(ico2e_[1-9]+)$/.test( inputId ) ) ) |
---|
351 | this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_ico2eList, false, "yesNos" ); |
---|
352 | else if( (/^(irextinction_[1-9]+)$/.test( inputId ) ) ) { |
---|
353 | |
---|
354 | this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_irextinctionList, false, "yesNos" ); |
---|
355 | info = true; |
---|
356 | champ=inputId; |
---|
357 | if (this.language == "en") ml="-11px"; |
---|
358 | else ml="-13px"; |
---|
359 | |
---|
360 | } |
---|
361 | else if( (/^(ibervC_[1-9]+)$/.test( inputId ) ) ) { |
---|
362 | this.displaySelect( td2, inputId, index, this.jSonYesNos, this.select_ibervCList, false, "yesNos" ); |
---|
363 | info = true; |
---|
364 | champ=inputId; |
---|
365 | if (this.language == "en") ml="-11px"; |
---|
366 | else ml="-13px"; |
---|
367 | } |
---|
368 | } |
---|
369 | else if( 'observatories' == type ) { |
---|
370 | this.displaySelect( td2, inputId, index, this.jSonObservatories, this.selectObservatoriesList, true, "observatories" ); |
---|
371 | |
---|
372 | if (this.browser == "Firefox") { |
---|
373 | if (this.language == "en") ml="-162px"; |
---|
374 | else ml="-116px"; |
---|
375 | } |
---|
376 | else if (this.browser == "Chrome") { |
---|
377 | if (this.language == "en") ml="-123px"; |
---|
378 | else ml="-84px"; |
---|
379 | } |
---|
380 | |
---|
381 | champ="iobservatory_"; |
---|
382 | } |
---|
383 | else if( 'spectralUnit' == type ) { |
---|
384 | this.displaySelect( td2, inputId, index, this.jSonSpectralUnits, this.selectSpectralUnitsList, true, "spectralUnits" ); |
---|
385 | info = true; |
---|
386 | |
---|
387 | champ = "ispectral_choice_"; |
---|
388 | |
---|
389 | if (this.browser == "Firefox") { |
---|
390 | if (this.language == "en") ml="-162px"; |
---|
391 | else ml="-116px"; |
---|
392 | } |
---|
393 | else if (this.browser == "Chrome") { |
---|
394 | if (this.language == "en") ml="-123px"; |
---|
395 | else ml="-84px"; |
---|
396 | } |
---|
397 | |
---|
398 | } |
---|
399 | else if( 'ilsf' == type ) { |
---|
400 | this.displaySelect( td2, inputId, index, this.jSonInstrumentalFunctions, this.selectInstrumentalFunctionsList, false, "instrumentalFunctions" ); |
---|
401 | info = true; |
---|
402 | champ = "ifunction_"; |
---|
403 | if (this.language == "en") ml="-192px"; |
---|
404 | else ml="-172px"; |
---|
405 | |
---|
406 | if (this.browser == "Firefox") { |
---|
407 | if (this.language == "en") ml="-192px"; |
---|
408 | else ml="-172px"; |
---|
409 | } |
---|
410 | else if (this.browser == "Chrome") { |
---|
411 | if (this.language == "en") ml="-149px"; |
---|
412 | else ml="-134px"; |
---|
413 | } |
---|
414 | |
---|
415 | } |
---|
416 | else if( 'climatoReference' == type ) { |
---|
417 | this.displaySelect( td2, inputId, index, this.jSonClimatoReferences, this.selectClimatoReferencesList, false, "climatoReferences" ); |
---|
418 | info = true; |
---|
419 | champ = "icr_"; |
---|
420 | |
---|
421 | if (this.browser == "Firefox") { |
---|
422 | if (this.language == "en") ml="-170px"; |
---|
423 | else ml="-162px"; |
---|
424 | } |
---|
425 | else if (this.browser == "Chrome") { |
---|
426 | if (this.language == "en") ml="-127px"; |
---|
427 | else ml="-124px"; |
---|
428 | } |
---|
429 | |
---|
430 | } |
---|
431 | |
---|
432 | |
---|
433 | |
---|
434 | if (info) { |
---|
435 | var img = $( document.createElement( "img" ) ); |
---|
436 | var a = $( document.createElement( "a" ) ); |
---|
437 | img.attr("src","resources/images/info.png"); |
---|
438 | img.attr("width","19"); |
---|
439 | a.attr("style","cursor:pointer"); |
---|
440 | |
---|
441 | img.bind("click",[champ,450,100,this],this.onClickInfos); |
---|
442 | a.append(img); |
---|
443 | div.append(a); |
---|
444 | div.attr( "style","margin-left:"+ml+";margin-top:"+mt); |
---|
445 | |
---|
446 | td2.attr( {colspan:3} ); |
---|
447 | tr.append( td2 ); |
---|
448 | tr.append( div ); |
---|
449 | } |
---|
450 | else { |
---|
451 | td2.attr( {colspan:3} ); |
---|
452 | tr.append( td2 ); |
---|
453 | } |
---|
454 | container.append( tr ); |
---|
455 | }, |
---|
456 | |
---|
457 | |
---|
458 | // REQUESTS ******************************************************** |
---|
459 | requestCreateXML: function() |
---|
460 | { |
---|
461 | var tapasForm = this.createTapasObject(); |
---|
462 | //passage de javascript a json grace au jquery |
---|
463 | var jsonTapasForm = $.toJSON( tapasForm ); |
---|
464 | |
---|
465 | |
---|
466 | if( jsonTapasForm ) |
---|
467 | $.ajax( { |
---|
468 | url: "data?methodName=createUserRequest&jsonTapas=" + jsonTapasForm, |
---|
469 | success:jQuery.proxy( this.handleCreateXML, this ), |
---|
470 | error: jQuery.proxy( this.showErrors, this ) |
---|
471 | } ); |
---|
472 | |
---|
473 | }, |
---|
474 | |
---|
475 | |
---|
476 | // HANDLES ******************************************************** = retours ajax |
---|
477 | handleCreateXML: function( result ) |
---|
478 | { |
---|
479 | this.loadingRequest.hide(); |
---|
480 | //this.loadingRequest.display(); |
---|
481 | |
---|
482 | var res = jQuery.parseJSON( result ).result; |
---|
483 | |
---|
484 | }, |
---|
485 | |
---|
486 | |
---|
487 | // EVENTS ******************************************************** |
---|
488 | onClickInfos: function(param) |
---|
489 | { |
---|
490 | |
---|
491 | var parametre=param.data[0]; |
---|
492 | var width=param.data[1]; |
---|
493 | var height=param.data[2]; |
---|
494 | var context=param.data[3]; |
---|
495 | |
---|
496 | if ("spectral_range" == parametre) { |
---|
497 | width=600; |
---|
498 | height=150; |
---|
499 | var titre = "Définition de l'intervalle spectral pour le calcul."; |
---|
500 | var pageInfo = "resources/doc/infosSpectralRange_fr.txt"; |
---|
501 | |
---|
502 | if( "fr" != context.language ) { |
---|
503 | titre = "Definition of spectral interval for the computation."; |
---|
504 | pageInfo = "resources/doc/infosSpectralRange_en.txt"; |
---|
505 | width=600; |
---|
506 | height=100; |
---|
507 | } |
---|
508 | |
---|
509 | } |
---|
510 | |
---|
511 | if ("ispectral_choice_" == parametre) { |
---|
512 | var titre = "Unité spectrale"; |
---|
513 | var pageInfo = "resources/doc/infosSpectralUnit_fr.txt"; |
---|
514 | width=600; |
---|
515 | height=450; |
---|
516 | if( "fr" != context.language ) { |
---|
517 | titre = "Spectral unit"; |
---|
518 | pageInfo = "resources/doc/infosSpectralUnit_en.txt"; |
---|
519 | width=500; |
---|
520 | height=500; |
---|
521 | } |
---|
522 | } |
---|
523 | |
---|
524 | var re = new RegExp("irp_"); |
---|
525 | if (parametre.match(re)) { |
---|
526 | var titre = "Résolution"; |
---|
527 | var pageInfo = "resources/doc/infosResolution_fr.txt"; |
---|
528 | width=600; |
---|
529 | height=200; |
---|
530 | if( "fr" != context.language ) { |
---|
531 | titre = "Resolution power"; |
---|
532 | pageInfo = "resources/doc/infosResolution_en.txt"; |
---|
533 | width=500; |
---|
534 | height=200; |
---|
535 | } |
---|
536 | } |
---|
537 | |
---|
538 | var re = new RegExp("isr_"); |
---|
539 | if (parametre.match(re)) { |
---|
540 | var titre = "Taux d'échantillonnage"; |
---|
541 | var pageInfo = "resources/doc/infosSamplingRatio_fr.txt"; |
---|
542 | width=600; |
---|
543 | height=100; |
---|
544 | if( "fr" != context.language ) { |
---|
545 | titre = "Sampling Ratio"; |
---|
546 | pageInfo = "resources/doc/infosSamplingRatio_en.txt"; |
---|
547 | width=500; |
---|
548 | height=100; |
---|
549 | } |
---|
550 | } |
---|
551 | |
---|
552 | var re = new RegExp("ibervC_"); |
---|
553 | if (parametre.match(re)) { |
---|
554 | var titre = "Correction BERV"; |
---|
555 | var pageInfo = "resources/doc/infosBERV_fr.txt"; |
---|
556 | width=950; |
---|
557 | height=700; |
---|
558 | if( "fr" != context.language ) { |
---|
559 | titre = "BERV correction"; |
---|
560 | pageInfo = "resources/doc/infosBERV_en.txt"; |
---|
561 | width=950; |
---|
562 | height=700; |
---|
563 | } |
---|
564 | } |
---|
565 | |
---|
566 | var re = new RegExp("ira_"); |
---|
567 | if (parametre.match(re)) { |
---|
568 | var titre = "LOS Ascension Droite"; |
---|
569 | var pageInfo = "resources/doc/infosLOSRA_fr.txt"; |
---|
570 | width=600; |
---|
571 | height=100; |
---|
572 | if( "fr" != context.language ) { |
---|
573 | titre = "LOS Right Ascension"; |
---|
574 | pageInfo = "resources/doc/infosLOSRA_en.txt"; |
---|
575 | width=500; |
---|
576 | height=100; |
---|
577 | } |
---|
578 | } |
---|
579 | |
---|
580 | var re = new RegExp("ide_"); |
---|
581 | if (parametre.match(re)) { |
---|
582 | var titre = "LOS Déclinaison"; |
---|
583 | var pageInfo = "resources/doc/infosLOSD_fr.txt"; |
---|
584 | width=600; |
---|
585 | height=100; |
---|
586 | if( "fr" != context.language ) { |
---|
587 | titre = "LOS Declination"; |
---|
588 | pageInfo = "resources/doc/infosLOSD_en.txt"; |
---|
589 | width=600; |
---|
590 | height=100; |
---|
591 | } |
---|
592 | } |
---|
593 | |
---|
594 | var re = new RegExp("iza_"); |
---|
595 | if (parametre.match(re)) { |
---|
596 | var titre = "Angle zénithal"; |
---|
597 | var pageInfo = "resources/doc/infosZenithalAngle_fr.txt"; |
---|
598 | width=600; |
---|
599 | height=100; |
---|
600 | if( "fr" != context.language ) { |
---|
601 | titre = "Zenithal angle"; |
---|
602 | pageInfo = "resources/doc/infosZenithalAngle_en.txt"; |
---|
603 | width=600; |
---|
604 | height=100; |
---|
605 | } |
---|
606 | } |
---|
607 | |
---|
608 | var re = new RegExp("isr_"); |
---|
609 | if (parametre.match(re)) { |
---|
610 | var titre = "Taux d'échantillonnage"; |
---|
611 | var pageInfo = "resources/doc/infosSamplingRatio_fr.txt"; |
---|
612 | width=600; |
---|
613 | height=100; |
---|
614 | if( "fr" != context.language ) { |
---|
615 | titre = "Sampling Ratio"; |
---|
616 | pageInfo = "resources/doc/infosSamplingRatio_en.txt"; |
---|
617 | width=500; |
---|
618 | height=100; |
---|
619 | } |
---|
620 | } |
---|
621 | |
---|
622 | var re = new RegExp("irextinction_"); |
---|
623 | if (parametre.match(re)) { |
---|
624 | var titre = "Sélection des composants atmsophériques"; |
---|
625 | var pageInfo = "resources/doc/infosSpecies_fr.txt"; |
---|
626 | width=600; |
---|
627 | height=350; |
---|
628 | if( "fr" != context.language ) { |
---|
629 | titre = "Selection of atmospheric constituents"; |
---|
630 | pageInfo = "resources/doc/infosSpecies_en.txt"; |
---|
631 | width=600; |
---|
632 | height=300; |
---|
633 | } |
---|
634 | } |
---|
635 | |
---|
636 | if ("icr_" == parametre) { |
---|
637 | var titre = "Modèle atmosphérique"; |
---|
638 | var pageInfo = "resources/doc/infosAtmosphericModel_fr.txt"; |
---|
639 | width=600; |
---|
640 | height=500; |
---|
641 | if( "fr" != context.language ) { |
---|
642 | titre = "Atmospheric model"; |
---|
643 | pageInfo = "resources/doc/infosAtmosphericModel_en.txt"; |
---|
644 | width=500; |
---|
645 | height=450; |
---|
646 | } |
---|
647 | } |
---|
648 | |
---|
649 | if ("iobservatory_" == parametre) { |
---|
650 | var titre = "Observatoire"; |
---|
651 | var pageInfo = "resources/doc/infosObservatory_fr.txt"; |
---|
652 | width=600; |
---|
653 | height=200; |
---|
654 | if( "fr" != context.language ) { |
---|
655 | titre = "Observatory"; |
---|
656 | pageInfo = "resources/doc/infosObservatory_en.txt"; |
---|
657 | width=500; |
---|
658 | height=200; |
---|
659 | } |
---|
660 | } |
---|
661 | |
---|
662 | if ("iformat_" == parametre) { |
---|
663 | var titre = "Format fichier"; |
---|
664 | var pageInfo = "resources/doc/infosInstrumentalFunction_fr.txt"; |
---|
665 | width=600; |
---|
666 | height=200; |
---|
667 | if( "fr" != context.language ) { |
---|
668 | titre = "File format"; |
---|
669 | pageInfo = "resources/doc/infosInstrumentalFunction_en.txt"; |
---|
670 | width=500; |
---|
671 | height=200; |
---|
672 | } |
---|
673 | } |
---|
674 | |
---|
675 | if ("ifunction_" == parametre) { |
---|
676 | var titre = "Fonction instrumentale"; |
---|
677 | var pageInfo = "resources/doc/infosInstrumentalFunction_fr.txt"; |
---|
678 | width=600; |
---|
679 | height=250; |
---|
680 | if( "fr" != context.language ) { |
---|
681 | titre = "Instrumental function"; |
---|
682 | pageInfo = "resources/doc/infosInstrumentalFunction_en.txt"; |
---|
683 | width=500; |
---|
684 | height=200; |
---|
685 | } |
---|
686 | } |
---|
687 | |
---|
688 | |
---|
689 | var $dialog = $( '<div></div>' ) |
---|
690 | .load( pageInfo ) |
---|
691 | .dialog( { |
---|
692 | autoOpen: false, |
---|
693 | title:titre, |
---|
694 | height:height, |
---|
695 | width:width |
---|
696 | } ); |
---|
697 | |
---|
698 | $dialog.dialog( 'open' ); |
---|
699 | |
---|
700 | }, |
---|
701 | |
---|
702 | onClickSubmit: function() |
---|
703 | { |
---|
704 | if( this.validFields() ) |
---|
705 | { |
---|
706 | this.divE.hide(); |
---|
707 | if( confirm( tapasTexts["confirm"] ) ) |
---|
708 | { |
---|
709 | this.loadingRequest.display(); |
---|
710 | this.requestCreateXML(); |
---|
711 | } |
---|
712 | } |
---|
713 | }, |
---|
714 | |
---|
715 | |
---|
716 | onClickAdd: function() |
---|
717 | { |
---|
718 | this.divE.hide(); |
---|
719 | this.nbRequest++; |
---|
720 | |
---|
721 | //tabs |
---|
722 | $( ".tab_class" ).removeClass( "activated" ); |
---|
723 | this.tabActive = this.createTab(); |
---|
724 | this.numRequest = this.tabActive.numTab; |
---|
725 | |
---|
726 | //formulaires |
---|
727 | $( ".divAll" ).hide(); |
---|
728 | this.createForm(); |
---|
729 | |
---|
730 | this.updateButtons(); |
---|
731 | }, |
---|
732 | |
---|
733 | |
---|
734 | onClickDel: function() |
---|
735 | { |
---|
736 | if( confirm( tapasTexts["label.confirm.del"] ) ) |
---|
737 | { |
---|
738 | var numCurrent = this.numRequest; |
---|
739 | |
---|
740 | var z = 1; |
---|
741 | |
---|
742 | //suppression onglet et form et controles calendrier caché |
---|
743 | $( "#all_" + numCurrent ).remove(); |
---|
744 | $( "#tab_request" + numCurrent ).remove(); |
---|
745 | AnyTime.noPicker( "iobservation_date_" + numCurrent ); |
---|
746 | AnyTime.noPicker( "ira_" + numCurrent ); |
---|
747 | |
---|
748 | this.tabActive.numTab = "1"; |
---|
749 | this.numRequest = "1"; |
---|
750 | |
---|
751 | this.selectClimatoReferencesList[numCurrent] = null; |
---|
752 | |
---|
753 | for( var i = 1; i <= this.nbRequest; i++ ) |
---|
754 | { |
---|
755 | if( i > numCurrent ) |
---|
756 | { |
---|
757 | z = i - 1; |
---|
758 | document.getElementById( "all_" + i ).id = "all_" + z; |
---|
759 | $( "#tab_request" + i ).html( "Request " + z ); |
---|
760 | //$( "#tab_request" + i ).html( "toto"); |
---|
761 | $( "#tab_request" + i ).attr( {name:z} ); |
---|
762 | $( "#tab_request" + i ).attr( {id:"tab_request" + z} ); this.angleChoice |
---|
763 | $( "#tabObservation_" + i ).attr( {id:"tabObservation_" + z} ); |
---|
764 | // $( "#select_iobservatory_" + i ).attr( {id:"select_iobservatory_" + z} ); |
---|
765 | this.selectObservatoriesList[z] = this.selectObservatoriesList[i]; |
---|
766 | this.selectObservatoriesList[i] = null; |
---|
767 | // $( "#select_ispectral_choice_" + i ).attr( {id:"select_ispectral_choice_" + z} ); |
---|
768 | this.selectSpectralUnitsList[z] = this.selectSpectralUnitsList[i]; |
---|
769 | this.selectSpectralUnitsList[i] = null; |
---|
770 | $( "#iminspectral_ranger_" + i ).attr( {id:"iminspectral_ranger_" + z} ); |
---|
771 | $( "#imaxspectral_ranger_" + i ).attr( {id:"imaxspectral_ranger_" + z} ); |
---|
772 | // $( "#select_ifunction_" + i ).attr( {id:"select_ifunction_" + z} ); |
---|
773 | this.selectInstrumentalFunctionsList[z] = this.selectInstrumentalFunctionsList[i]; |
---|
774 | this.selectInstrumentalFunctionsList[i] = null; |
---|
775 | // $( "#select_icr_" + i ).attr( {id:"select_icr_" + z} ); |
---|
776 | this.selectClimatoReferencesList[z] = this.selectClimatoReferencesList[i]; |
---|
777 | this.selectClimatoReferencesList[i] = null; |
---|
778 | // le $ n'intervient qu en html. $() remplace le document.element |
---|
779 | $( "#ide_" + i ).attr( {id:"ide_" + z} ); |
---|
780 | $( "#iza_" + i ).attr( {id:"iza_" + z} ); |
---|
781 | $( "#irp_" + i ).attr( {id:"irp_" + z} ); |
---|
782 | $( "#isr_" + i ).attr( {id:"isr_" + z} ); |
---|
783 | $( "#ira_" + i ).attr( {id:"ira_" + z} ); |
---|
784 | // $( "#select_iformat_" + i ).attr( {id:"select_iformat_" + z} ); |
---|
785 | this.selectFileFormatsList[z] = this.selectFileFormatsList[i]; |
---|
786 | this.selectFileFormatsList[i] = null; |
---|
787 | // $( "#select_irextinction_" + i ).attr( {id:"select_irextinction_" + z} ); |
---|
788 | this.select_irextinctionList[z] = this.select_irextinctionList[i]; |
---|
789 | this.select_irextinctionList[i] = null; |
---|
790 | // $( "#select_ih2oe_" + i ).attr( {id:"select_ih2oe_" + z} ); |
---|
791 | this.select_ih2oeList[z] = this.select_ih2oeList[i]; |
---|
792 | this.select_ih2oeList[i] = null; |
---|
793 | // $( "#select_io2e_" + i ).attr( {id:"select_io2e_" + z} ); |
---|
794 | this.select_io2eList[z] = this.select_io2eList[i]; |
---|
795 | this.select_io2eList[i] = null; |
---|
796 | // $( "#select_io3e_" + i ).attr( {id:"select_io3e_" + z} ); |
---|
797 | this.select_io3eList[z] = this.select_io3eList[i]; |
---|
798 | this.select_io3eList[i] = null; |
---|
799 | // $( "#select_ico2e_" + i ).attr( {id:"select_ico2e_" + z} ); |
---|
800 | this.select_ico2eList[z] = this.select_ico2eList[i]; |
---|
801 | this.select_ico2eList[i] = null; |
---|
802 | |
---|
803 | this.select_ibervCList[z] = this.select_ibervCList[i]; |
---|
804 | this.select_ibervCList[i] = null; |
---|
805 | |
---|
806 | // Supression du calendrier puis re-création en insérant l'ancienne date |
---|
807 | var oldDate = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() ); |
---|
808 | //var oldDate = $( "#iobservation_date_" + i ).val(); |
---|
809 | |
---|
810 | AnyTime.noPicker( "iobservation_date_" + i ); |
---|
811 | //this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, oldDate, false ); |
---|
812 | |
---|
813 | $( "#iobservation_date_" + i ).attr( {id:"iobservation_date_" + z} ); |
---|
814 | this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, oldDate, false ); |
---|
815 | //this.createCalendar( $( "#tabObservation_" + z ), tapasTexts["label.datemesure"], "iobservation_date_" + z, false, false ); |
---|
816 | |
---|
817 | // Idem pour les heures !!! |
---|
818 | // TODO : voir si besoin de parser les heures ou non |
---|
819 | // var oldTime = this.timeConverter.parse( $( "#ira_" + i ).val() ); |
---|
820 | /*var oldTime = $( "#ira_" + i ).val(); |
---|
821 | AnyTime.noPicker( "ira_" + i ); |
---|
822 | this.createTime( $( "#tabObservation_" + z ), tapasTexts["label.ira"], "ira_" + z, oldTime, false,"j2000" ); |
---|
823 | $( "#ira_" + i ).attr( {id:"ira_" + z} );*/ |
---|
824 | } |
---|
825 | } |
---|
826 | |
---|
827 | this.nbRequest--; |
---|
828 | |
---|
829 | // Mise à jour des boutons |
---|
830 | this.updateButtons(); |
---|
831 | |
---|
832 | //tabs |
---|
833 | $( ".tab_class" ).removeClass( "activated" ); |
---|
834 | $( "#tab_request1" ).addClass( "activated" ); |
---|
835 | |
---|
836 | //formulaires |
---|
837 | $( ".divAll" ).hide(); |
---|
838 | $( "#all_1" ).show(); |
---|
839 | } |
---|
840 | }, |
---|
841 | |
---|
842 | |
---|
843 | onClickTab: function( event ) |
---|
844 | { |
---|
845 | var realTabId = $( "#" + event.currentTarget.id ).attr( "name" ); |
---|
846 | var clickedDiv = event.data; |
---|
847 | |
---|
848 | //tabs |
---|
849 | $( ".tab_class" ).removeClass( "activated" ); |
---|
850 | clickedDiv.divContainer.addClass( "activated" ); |
---|
851 | |
---|
852 | //forms |
---|
853 | $( ".divAll" ).hide(); |
---|
854 | $( "#all_" + realTabId ).show(); |
---|
855 | |
---|
856 | this.numRequest = realTabId; |
---|
857 | this.tabActive.numTab = realTabId; |
---|
858 | |
---|
859 | this.updateButtons(); |
---|
860 | }, |
---|
861 | |
---|
862 | |
---|
863 | // OTHERS ******************************************************** |
---|
864 | // General method to display select |
---|
865 | displaySelect: function( container, id, index, jsonList, selectList, nullValueIsNeeded, contentManage ) |
---|
866 | { |
---|
867 | var paramSelect = new Object(); |
---|
868 | paramSelect.id = "select_" + id; |
---|
869 | paramSelect.parent = container; |
---|
870 | var select = new Select( paramSelect ); |
---|
871 | if( nullValueIsNeeded ) |
---|
872 | select.add( "-1", "-- " + tapasTexts["text.select"] + " --" ); |
---|
873 | jQuery.each( jsonList, jQuery.proxy( function ( i, jsonElement ) |
---|
874 | { |
---|
875 | switch( contentManage ) |
---|
876 | { |
---|
877 | case "observatories": |
---|
878 | select.add( jsonElement.id, jsonElement.name ); |
---|
879 | break; |
---|
880 | case "spectralUnits": |
---|
881 | select.add( jsonElement.value, tapasTexts[jsonElement.value] ); |
---|
882 | break; |
---|
883 | case "instrumentalFunctions" : |
---|
884 | case "climatoReferences" : |
---|
885 | case "yesNos" : |
---|
886 | select.add( jsonElement.value, tapasTexts[jsonElement.text] ); |
---|
887 | break; |
---|
888 | default: |
---|
889 | select.add( jsonElement.value, jsonElement.text ); |
---|
890 | break; |
---|
891 | } |
---|
892 | }, this ) ); |
---|
893 | select.selectFirst( false ); |
---|
894 | selectList[index] = select; |
---|
895 | }, |
---|
896 | |
---|
897 | showErrors: function( result ) |
---|
898 | { |
---|
899 | //this.containerErrors.show(); |
---|
900 | // this.containerErrors.html( tapasTexts[result.responseText] ); |
---|
901 | }, |
---|
902 | |
---|
903 | createForm: function() |
---|
904 | { |
---|
905 | |
---|
906 | |
---|
907 | |
---|
908 | var divAll = $( document.createElement( "div" ) ); |
---|
909 | divAll.attr( {id:"all_" + this.nbRequest, class:"divAll"} ); |
---|
910 | |
---|
911 | |
---|
912 | //Creation div |
---|
913 | var divPreference = $( document.createElement( "div" ) ); |
---|
914 | var tabPreference = $( document.createElement( "table" ) ); |
---|
915 | tabPreference.attr( {cellspacing:3} ); |
---|
916 | |
---|
917 | var divObservation = $( document.createElement( "div" ) ); |
---|
918 | var tabObservation = $( document.createElement( "table" ) ); |
---|
919 | //tabObservation.attr({border:1}); |
---|
920 | tabObservation.attr( {id:"tabObservation_" + this.nbRequest, cellspacing:3} ); |
---|
921 | |
---|
922 | |
---|
923 | var divAtmosphere = $( document.createElement( "div" ) ); |
---|
924 | var tabAtmosphere = $( document.createElement( "table" ) ); |
---|
925 | |
---|
926 | |
---|
927 | var fieldSetObservation = $( document.createElement( "fieldset" ) ); |
---|
928 | fieldSetObservation.addClass( "cfs1" ); |
---|
929 | divObservation.append( fieldSetObservation ); |
---|
930 | |
---|
931 | var legendObservation = $( document.createElement( "legend" ) ); |
---|
932 | legendObservation.html( "Observation" ); |
---|
933 | fieldSetObservation.append( legendObservation ); |
---|
934 | legendObservation.addClass( "containerField" ); |
---|
935 | |
---|
936 | var fieldSetPreference = $( document.createElement( "fieldset" ) ); |
---|
937 | fieldSetPreference.addClass( "cfs2" ); |
---|
938 | divPreference.append( fieldSetPreference ); |
---|
939 | |
---|
940 | var legendPreference = $( document.createElement( "legend" ) ); |
---|
941 | legendPreference.html( tapasTexts["label.preferences"] ); |
---|
942 | fieldSetPreference.append( legendPreference ); |
---|
943 | legendPreference.addClass( "containerField" ); |
---|
944 | |
---|
945 | fieldSetObservation.append( tabObservation ); |
---|
946 | divObservation.addClass( "divObservation" ); |
---|
947 | divAll.append( divObservation ); |
---|
948 | |
---|
949 | |
---|
950 | divAtmosphere.append( tabAtmosphere ); |
---|
951 | //divAtmosphere.addClass("divAtmosphere"); |
---|
952 | //this.containerForm.append( divAtmosphere ); |
---|
953 | fieldSetObservation.append( divAtmosphere ); |
---|
954 | |
---|
955 | fieldSetPreference.append( tabPreference ); |
---|
956 | divPreference.addClass( "divPreference" ); |
---|
957 | divAll.append( divPreference ); |
---|
958 | |
---|
959 | this.containerForm.append( divAll ); |
---|
960 | this.containerForm.append( this.divE ); |
---|
961 | //this.tabInput = new Array(3); |
---|
962 | |
---|
963 | this.createTrList( tapasTexts["label.format"], "iformat_" + this.nbRequest, this.nbRequest, tabPreference, 'format' ); |
---|
964 | this.createTrList( tapasTexts["label.era"], "irextinction_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
965 | this.createTrList( tapasTexts["label.eh2o"], "ih2oe_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
966 | this.createTrList( tapasTexts["label.eo3"], "io3e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
967 | this.createTrList( tapasTexts["label.eo2"], "io2e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
968 | this.createTrList( tapasTexts["label.eco2"], "ico2e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
969 | this.createTrList( tapasTexts["label.berv"], "ibervC_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
970 | |
---|
971 | this.createTrList( tapasTexts["label.observatory"], "iobservatory_" + this.nbRequest, this.nbRequest, tabObservation, 'observatories',true ); |
---|
972 | this.createCalendar( tabObservation, tapasTexts["label.datemesure"], "iobservation_date_" + this.nbRequest, false, true ); |
---|
973 | |
---|
974 | //unite |
---|
975 | this.createTrList( tapasTexts["label.spectralUnit"], "ispectral_choice_" + this.nbRequest, this.nbRequest, tabObservation, 'spectralUnit' ); |
---|
976 | this.createTr2Input( tapasTexts["label.spectralRange"], tapasTexts["label.to"], "iminspectral_ranger_" + this.nbRequest, "imaxspectral_ranger_" + this.nbRequest, tabObservation, "[350,2500] nm" ); |
---|
977 | |
---|
978 | //fonction instrumentale |
---|
979 | this.createTrList( tapasTexts["label.ifunction"], "ifunction_" + this.nbRequest, this.nbRequest, tabObservation, "ilsf" ); |
---|
980 | //reference climato |
---|
981 | //this.createTrList( tapasTexts["label.climato"], "icr", tabAtmosphere, "climatoReference" ); |
---|
982 | this.createTrList( tapasTexts["label.climato"], "icr_" + this.nbRequest, this.nbRequest, tabObservation, "climatoReference" ); |
---|
983 | |
---|
984 | |
---|
985 | this.createTr( tapasTexts["label.resolution"], "irp_" + this.nbRequest, tabObservation, "", "", "","",true ); |
---|
986 | this.createTr( tapasTexts["label.ratio"], "isr_" + this.nbRequest, tabObservation, "", "","","",true ); |
---|
987 | |
---|
988 | |
---|
989 | this.createTr( tapasTexts["label.ira"], "ira_" + this.nbRequest,tabObservation,"hh:mm:ss (J2000)","keypress","ra","2",true ); |
---|
990 | //this.createTime( tabObservation, tapasTexts["label.ira"], "ira_" + this.nbRequest, false, true,"hh:mm:ss (J2000)" ); |
---|
991 | this.createTr( tapasTexts["label.ide"], "ide_" + this.nbRequest, tabObservation, "deg:':''","keypress","de","2",true ); |
---|
992 | this.createTrTxt( tapasTexts["label.or"], tabObservation ); |
---|
993 | this.createTr( tapasTexts["label.iza"], "iza_" + this.nbRequest, tabObservation, "[0,90] °","keypress","za","2",true ); |
---|
994 | |
---|
995 | |
---|
996 | this.initRequestFields(); |
---|
997 | //jQuery.proxy permet d'envoyer le contexte this courant |
---|
998 | |
---|
999 | }, |
---|
1000 | |
---|
1001 | |
---|
1002 | createTapasObject: function() |
---|
1003 | { |
---|
1004 | |
---|
1005 | var requests = new Array(); |
---|
1006 | |
---|
1007 | for( var i = 1; i <= this.nbRequest; i++ ) |
---|
1008 | { |
---|
1009 | // PREFERENCE |
---|
1010 | var preference = new Object(); |
---|
1011 | |
---|
1012 | preference.format = new Object(); |
---|
1013 | //toutes les valeurs possibles |
---|
1014 | preference.format.firstValue = this.selectFileFormatsList[i].getValuesInString(); |
---|
1015 | //la valeur selectionnee |
---|
1016 | preference.format.secondValue = this.selectFileFormatsList[i].getValue(); |
---|
1017 | |
---|
1018 | preference.rayleighExtinction = new Object(); |
---|
1019 | preference.rayleighExtinction.firstValue = this.select_irextinctionList[i].getValuesInString(); |
---|
1020 | preference.rayleighExtinction.secondValue = this.select_irextinctionList[i].getValue(); |
---|
1021 | |
---|
1022 | preference.h2oExtinction = new Object(); |
---|
1023 | preference.h2oExtinction.firstValue = this.select_ih2oeList[i].getValuesInString(); |
---|
1024 | preference.h2oExtinction.secondValue = this.select_ih2oeList[i].getValue(); |
---|
1025 | |
---|
1026 | preference.o3Extinction = new Object(); |
---|
1027 | preference.o3Extinction.firstValue = this.select_io3eList[i].getValuesInString(); |
---|
1028 | preference.o3Extinction.secondValue = this.select_io3eList[i].getValue(); |
---|
1029 | |
---|
1030 | preference.o2Extinction = new Object(); |
---|
1031 | preference.o2Extinction.firstValue = this.select_io2eList[i].getValuesInString(); |
---|
1032 | preference.o2Extinction.secondValue = this.select_io2eList[i].getValue(); |
---|
1033 | |
---|
1034 | preference.co2Extinction = new Object(); |
---|
1035 | preference.co2Extinction.firstValue = this.select_ico2eList[i].getValuesInString(); |
---|
1036 | preference.co2Extinction.secondValue = this.select_ico2eList[i].getValue(); |
---|
1037 | |
---|
1038 | preference.bervCorrection = new Object(); |
---|
1039 | preference.bervCorrection.firstValue = this.select_ibervCList[i].getValuesInString(); |
---|
1040 | preference.bervCorrection.secondValue = this.select_ibervCList[i].getValue(); |
---|
1041 | |
---|
1042 | |
---|
1043 | // OBSERVATION |
---|
1044 | var observatory = new Object(); |
---|
1045 | observatory.id = this.selectObservatoriesList[i].getValue(); |
---|
1046 | |
---|
1047 | // Los |
---|
1048 | var los = new Object(); |
---|
1049 | |
---|
1050 | //if ($( "#iza_" + i ).val().toString() != null) |
---|
1051 | los.zenithAngle = $( "#iza_" + i ).val(); |
---|
1052 | //else { |
---|
1053 | los.raJ2000 = $( "#ira_" + i ).val(); |
---|
1054 | los.decJ2000 = $( "#ide_" + i ).val(); |
---|
1055 | //} |
---|
1056 | |
---|
1057 | |
---|
1058 | //los.raJ2000 = "22:22:22";//$( "#ira_" + i ).val(); |
---|
1059 | //los.decJ2000 = "22:22:22";//$( "#ide_" + i ).val(); |
---|
1060 | //los.zenithAngle = "12";//$( "#iza_" + i ).val("12"); |
---|
1061 | |
---|
1062 | |
---|
1063 | // Instrument |
---|
1064 | var instrument = new Object(); |
---|
1065 | instrument.ilsfChoice = new Object(); |
---|
1066 | instrument.ilsfChoice.firstValue = "-1,0,1";//this.selectInstrumentalFunctionsList[i].getValuesInString(); |
---|
1067 | instrument.ilsfChoice.secondValue = this.selectInstrumentalFunctionsList[i].getValue(); |
---|
1068 | |
---|
1069 | this.selectSpectralUnitsList[i].remove( "-1" ); |
---|
1070 | instrument.spectralChoice = new Object(); |
---|
1071 | instrument.spectralChoice.firstValue = this.selectSpectralUnitsList[i].getValuesInString(); |
---|
1072 | instrument.spectralChoice.secondValue = this.selectSpectralUnitsList[i].getValue(); |
---|
1073 | |
---|
1074 | instrument.spectralRange = $( "#iminspectral_ranger_" + i ).val() + ' ' + $( "#imaxspectral_ranger_" + i ).val(); |
---|
1075 | |
---|
1076 | instrument.resolvingPower = new Object(); |
---|
1077 | instrument.resolvingPower.firstValue = "0"; |
---|
1078 | instrument.resolvingPower.secondValue = $( "#irp_" + i ).val(); |
---|
1079 | |
---|
1080 | instrument.samplingRatio = new Object(); |
---|
1081 | instrument.samplingRatio.firstValue = "0"; |
---|
1082 | instrument.samplingRatio.secondValue = $( "#isr_" + i ).val(); |
---|
1083 | |
---|
1084 | var observation = new Object(); |
---|
1085 | observation.date = this.calendarConverter.parse( $( "#iobservation_date_" + i ).val() ).getTime(); |
---|
1086 | |
---|
1087 | |
---|
1088 | observation.observatory = observatory; |
---|
1089 | |
---|
1090 | observation.los = los; |
---|
1091 | observation.instrument = instrument; |
---|
1092 | |
---|
1093 | // ATMOSPHERE |
---|
1094 | var atmosphere = new Object(); |
---|
1095 | |
---|
1096 | atmosphere.reference = new Object(); |
---|
1097 | atmosphere.reference.firstValue = this.selectClimatoReferencesList[i].getValuesInString(); |
---|
1098 | atmosphere.reference.secondValue = this.selectClimatoReferencesList[i].getValue(); |
---|
1099 | |
---|
1100 | |
---|
1101 | // REQUEST |
---|
1102 | var request = new Object(); |
---|
1103 | request.id = i; |
---|
1104 | request.preference = preference; |
---|
1105 | request.observation = observation; |
---|
1106 | request.atmosphere = atmosphere; |
---|
1107 | |
---|
1108 | requests[i - 1] = request; |
---|
1109 | } |
---|
1110 | |
---|
1111 | // TAPAS |
---|
1112 | var tapas = new Object(); |
---|
1113 | tapas.requests = requests; |
---|
1114 | return tapas; |
---|
1115 | }, |
---|
1116 | |
---|
1117 | validFields: function() |
---|
1118 | { |
---|
1119 | for( var i = 1; i <= this.nbRequest; i++ ) |
---|
1120 | { |
---|
1121 | |
---|
1122 | var chaine = tapasTexts["text.erreur.saisie"] + " " + i + "<br>"; |
---|
1123 | var testOk1=false; |
---|
1124 | var testOk2=false; |
---|
1125 | var testOk3=false; |
---|
1126 | var testOk = isSup( this.selectObservatoriesList[i].getValue(), 0 ); |
---|
1127 | if( !testOk ) |
---|
1128 | { |
---|
1129 | this.divE.html( chaine + tapasTexts["label.observatory"] + " : " + tapasTexts["text.toselect"] ); |
---|
1130 | this.divE.show(); |
---|
1131 | return false; |
---|
1132 | } |
---|
1133 | |
---|
1134 | testOk = isDiff( this.selectSpectralUnitsList[i].getValue(), -1 ); |
---|
1135 | if( !testOk ) |
---|
1136 | { |
---|
1137 | this.divE.html( chaine + tapasTexts["label.spectralUnit"] + " : " + tapasTexts["text.toselect"] ); |
---|
1138 | this.divE.show(); |
---|
1139 | return false; |
---|
1140 | } |
---|
1141 | |
---|
1142 | testOk = isValidRange( $( "#iminspectral_ranger_" + i ).val(), $( "#imaxspectral_ranger_" + i ).val(), this.selectSpectralUnitsList[i].getValue() ); |
---|
1143 | if( !testOk ) |
---|
1144 | { |
---|
1145 | this.divE.html( chaine + tapasTexts["label.spectralRange"] + " : " + tapasTexts["text.badvalue"] ); |
---|
1146 | this.divE.show(); |
---|
1147 | return false; |
---|
1148 | } |
---|
1149 | |
---|
1150 | /*testOk = isDeg( $( "#ide_" + i ).val() ); |
---|
1151 | if( !testOk ) |
---|
1152 | { |
---|
1153 | this.divE.html( chaine + tapasTexts["label.ide"] + " : " + tapasTexts["text.badvalue"] ); |
---|
1154 | this.divE.show(); |
---|
1155 | return false; |
---|
1156 | } */ |
---|
1157 | |
---|
1158 | |
---|
1159 | testOk = isBetween( $( "#iza_" + i ).val(), 0, 90 ); |
---|
1160 | testOk1 = isValidNum( $( "#iza_" + i ).val()); |
---|
1161 | testOk2 = isDeg( $( "#ide_" + i ).val()); |
---|
1162 | testOk3 = isHourDeg( $( "#ira_" + i ).val()); |
---|
1163 | if( !((testOk && testOk1) || (testOk2 && testOk3)) ) |
---|
1164 | { |
---|
1165 | if ( !(testOk && testOk1) ) |
---|
1166 | this.divE.html( chaine + "LOS : " + tapasTexts["text.badvalue"] ); |
---|
1167 | else |
---|
1168 | this.divE.html( chaine + tapasTexts["label.iza"] + " : " + tapasTexts["text.badvalue"] ); |
---|
1169 | this.divE.show(); |
---|
1170 | return false; |
---|
1171 | } |
---|
1172 | |
---|
1173 | /*testOk = isBetween( $( "#iza_" + i ).val(), 0, 90 ); |
---|
1174 | if( !testOk ) |
---|
1175 | { |
---|
1176 | this.divE.html( chaine + tapasTexts["label.iza"] + " : " + tapasTexts["text.badvalue"] ); |
---|
1177 | this.divE.show(); |
---|
1178 | return false; |
---|
1179 | } */ |
---|
1180 | |
---|
1181 | testOk = isValidNum( $( "#irp_" + i ).val() ); |
---|
1182 | if( !testOk ) |
---|
1183 | { |
---|
1184 | this.divE.html( chaine + tapasTexts["label.resolution"] + " : " + tapasTexts["text.badvalue"] ); |
---|
1185 | this.divE.show(); |
---|
1186 | return false; |
---|
1187 | } |
---|
1188 | |
---|
1189 | testOk = isSup( $( "#irp_" + i ).val(), 1 ); |
---|
1190 | if( !testOk ) |
---|
1191 | { |
---|
1192 | this.divE.html( chaine + tapasTexts["label.resolution"] + " : " + tapasTexts["text.badvalue"] ); |
---|
1193 | this.divE.show(); |
---|
1194 | return false; |
---|
1195 | } |
---|
1196 | |
---|
1197 | testOk = isValidNum( $( "#isr_" + i ).val() ); |
---|
1198 | if( !testOk ) |
---|
1199 | { |
---|
1200 | this.divE.html( chaine + tapasTexts["label.ratio"] + " : " + tapasTexts["text.badvalue"] ); |
---|
1201 | this.divE.show(); |
---|
1202 | return false; |
---|
1203 | } |
---|
1204 | |
---|
1205 | testOk = isSup( $( "#isr_" + i ).val(), 1 ); |
---|
1206 | if( !testOk ) |
---|
1207 | { |
---|
1208 | this.divE.html( chaine + tapasTexts["label.ratio"] + " : " + tapasTexts["text.badvalue"] ); |
---|
1209 | this.divE.show(); |
---|
1210 | return false; |
---|
1211 | } |
---|
1212 | } |
---|
1213 | |
---|
1214 | return true; |
---|
1215 | }, |
---|
1216 | |
---|
1217 | updateButtons: function() |
---|
1218 | { |
---|
1219 | if( 1 < this.nbRequest ) |
---|
1220 | this.delRequestButton.enable(); |
---|
1221 | else |
---|
1222 | this.delRequestButton.disable(); |
---|
1223 | |
---|
1224 | if( 9 <= this.nbRequest ) |
---|
1225 | this.addRequestButton.disable(); |
---|
1226 | else |
---|
1227 | this.addRequestButton.enable(); |
---|
1228 | }, |
---|
1229 | |
---|
1230 | |
---|
1231 | angleChoice: function(params) |
---|
1232 | { |
---|
1233 | var context = params.data[0]; |
---|
1234 | var champ = params.data[1]; |
---|
1235 | //alert(context.nbRequest); |
---|
1236 | var indice = context.nbRequest; |
---|
1237 | if (champ == "za") { |
---|
1238 | //$( "#iza_"+indice ).val($( "#iza_"+indice ).val().replace(/^\s+|\s+$/g,"")); |
---|
1239 | //alert($( "#iza_"+indice ).val($( "#iza_"+indice ).val().replace(/^\s+|\s+$/g,"")).length); |
---|
1240 | //if ($( "#iza_"+indice ).val($( "#iza_"+indice ).val().replace(/^\s+|\s+$/g,"")).length >0 ) { |
---|
1241 | $( "#ira_"+indice ).val(""); |
---|
1242 | $( "#ide_"+indice ).val(""); |
---|
1243 | //} |
---|
1244 | } |
---|
1245 | else { |
---|
1246 | $( "#iza_"+indice ).val(""); |
---|
1247 | } |
---|
1248 | |
---|
1249 | |
---|
1250 | }, |
---|
1251 | |
---|
1252 | |
---|
1253 | |
---|
1254 | /*this.createTrList( tapasTexts["label.format"], "iformat_" + this.nbRequest, this.nbRequest, tabPreference, 'format' ); |
---|
1255 | this.createTrList( tapasTexts["label.era"], "irextinction_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
1256 | this.createTrList( tapasTexts["label.eh2o"], "ih2oe_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
1257 | this.createTrList( tapasTexts["label.eo3"], "io3e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
1258 | this.createTrList( tapasTexts["label.eo2"], "io2e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
1259 | this.createTrList( tapasTexts["label.eco2"], "ico2e_" + this.nbRequest, this.nbRequest, tabPreference, 'yesno' ); |
---|
1260 | |
---|
1261 | this.createTrList( tapasTexts["label.observatory"], "iobservatory_" + this.nbRequest, this.nbRequest, tabObservation, 'observatories' ); |
---|
1262 | this.createCalendar( tabObservation, tapasTexts["label.datemesure"], "iobservation_date_" + this.nbRequest, false, true ); |
---|
1263 | |
---|
1264 | //unite |
---|
1265 | this.createTrList( tapasTexts["label.spectralUnit"], "ispectral_choice_" + this.nbRequest, this.nbRequest, tabObservation, 'spectralUnit' ); |
---|
1266 | this.createTr2Input( tapasTexts["label.spectralRange"], tapasTexts["label.to"], "iminspectral_ranger_" + this.nbRequest, "imaxspectral_ranger_" + this.nbRequest, tabObservation, "[350,2500] nm" ); |
---|
1267 | |
---|
1268 | //fonction instrumentale |
---|
1269 | this.createTrList( tapasTexts["label.ifunction"], "ifunction_" + this.nbRequest, this.nbRequest, tabObservation, "ilsf" ); |
---|
1270 | //reference climato |
---|
1271 | //this.createTrList( tapasTexts["label.climato"], "icr", tabAtmosphere, "climatoReference" ); |
---|
1272 | this.createTrList( tapasTexts["label.climato"], "icr_" + this.nbRequest, this.nbRequest, tabObservation, "climatoReference" ); |
---|
1273 | |
---|
1274 | |
---|
1275 | this.createTr( tapasTexts["label.ira"], "ira_" + this.nbRequest,tabObservation,"hh:mm:ss (J2000)","keypress","ra","2" ); |
---|
1276 | //this.createTime( tabObservation, tapasTexts["label.ira"], "ira_" + this.nbRequest, false, true,"hh:mm:ss (J2000)" ); |
---|
1277 | this.createTr( tapasTexts["label.ide"], "ide_" + this.nbRequest, tabObservation, "deg:':''","keypress","de","2" ); |
---|
1278 | |
---|
1279 | this.createTrTxt( "or", tabObservation ); |
---|
1280 | this.createTr( tapasTexts["label.iza"], "iza_" + this.nbRequest, tabObservation, "[0,90] °","keypress","za","2" ); |
---|
1281 | |
---|
1282 | this.createTr( tapasTexts["label.resolution"], "irp_" + this.nbRequest, tabObservation, "", "", "","" ); |
---|
1283 | this.createTr( tapasTexts["label.ratio"], "isr_" + this.nbRequest, tabObservation, "", "","","" ); |
---|
1284 | */ |
---|
1285 | |
---|
1286 | |
---|
1287 | initRequestFields: function() |
---|
1288 | { |
---|
1289 | if (this.nbRequest > 1 && this.nbRequest <=9) { |
---|
1290 | var indice = this.nbRequest; |
---|
1291 | var indice0 = indice - 1; |
---|
1292 | |
---|
1293 | this.selectObservatoriesList[indice].select(this.selectObservatoriesList[indice-1].getValue(),false); |
---|
1294 | $( "#iobservation_date_" + indice ).val( $( "#iobservation_date_" + indice0).val() ); |
---|
1295 | this.selectSpectralUnitsList[indice].select(this.selectSpectralUnitsList[indice-1].getValue(),false); |
---|
1296 | |
---|
1297 | |
---|
1298 | this.selectInstrumentalFunctionsList[indice].select(this.selectInstrumentalFunctionsList[indice-1].getValue(),false); |
---|
1299 | this.selectClimatoReferencesList[indice].select(this.selectClimatoReferencesList[indice-1].getValue(),false); |
---|
1300 | |
---|
1301 | this.selectFileFormatsList[indice].select(this.selectFileFormatsList[indice-1].getValue(),false); |
---|
1302 | this.select_irextinctionList[indice].select(this.select_irextinctionList[indice-1].getValue(),false); |
---|
1303 | this.select_ih2oeList[indice].select(this.select_ih2oeList[indice-1].getValue(),false); |
---|
1304 | this.select_io3eList[indice].select(this.select_io3eList[indice-1].getValue(),false); |
---|
1305 | this.select_io2eList[indice].select(this.select_io2eList[indice-1].getValue(),false); |
---|
1306 | this.select_ico2eList[indice].select(this.select_ico2eList[indice-1].getValue(),false); |
---|
1307 | this.select_ibervCList[indice].select(this.select_ibervCList[indice-1].getValue(),false); |
---|
1308 | |
---|
1309 | $( "#iminspectral_ranger_" + indice ).val($( "#iminspectral_ranger_" + indice0 ).val() ); |
---|
1310 | $( "#imaxspectral_ranger_" + indice ).val($( "#imaxspectral_ranger_" + indice0 ).val() ); |
---|
1311 | |
---|
1312 | $( "#irp_" + indice ).val($( "#irp_" + indice0 ).val() ); |
---|
1313 | $( "#isr_" + indice ).val($( "#isr_" + indice0 ).val() ); |
---|
1314 | $( "#ira_" + indice ).val($( "#ira_" + indice0 ).val() ); |
---|
1315 | $( "#ide_" + indice ).val($( "#ide_" + indice0 ).val() ); |
---|
1316 | $( "#iza_" + indice ).val($( "#iza_" + indice0 ).val() ); |
---|
1317 | |
---|
1318 | |
---|
1319 | |
---|
1320 | // $( "#iobservatory_date_" + indice ).val( $( "#iobservatory_date_" + indice0 ).val() ); |
---|
1321 | // $( "#iobservatory_date_" + indice ).val( this.calendarConverter.format( currentDate ) ); |
---|
1322 | |
---|
1323 | //$( "#iobservatory_date_" + indice ).val( this.calendarConverter.format( this.calendarConverter.parse( $( "#iobservation_date_" + indice0 ).val() ).getTime() ) ); |
---|
1324 | // this.selectSpectralUnitsList[z] = this.selectSpectralUnitsList[i]; |
---|
1325 | /*this.selectSpectralUnitsList[i] = null; |
---|
1326 | $( "#iminspectral_ranger_" + i ).attr( {id:"iminspectral_ranger_" + z} ); |
---|
1327 | $( "#imaxspectral_ranger_" + i ).attr( {id:"imaxspectral_ranger_" + z} );*/ |
---|
1328 | |
---|
1329 | //$( "#irp_"+indice ).val($( "#irp_"+(indice-1)).val() ); |
---|
1330 | |
---|
1331 | } |
---|
1332 | } |
---|
1333 | |
---|
1334 | } ); |
---|
1335 | |
---|
1336 | </script> |
---|