1 | <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> |
---|
2 | |
---|
3 | <script type="text/javascript"> |
---|
4 | |
---|
5 | var InterfaceIasi = Class.create( { |
---|
6 | initialize: function() |
---|
7 | { |
---|
8 | /** *********** CONTAINERS *********** **/ |
---|
9 | this.parent = $( "#pageWrapper" ); |
---|
10 | this.containerSelect = $( "#containerSelect" ); |
---|
11 | this.containerCalendar = $( "#containerCalendar" ); |
---|
12 | this.containerQuickLookA = $( "#containerQuickLookA" ); |
---|
13 | this.containerQuickLookB = $( "#containerQuickLookB" ); |
---|
14 | this.containerResultA = $( "#containerResultA" ); |
---|
15 | this.containerResultB = $( "#containerResultB" ); |
---|
16 | this.containerErrors = $( "#errors" ); |
---|
17 | |
---|
18 | /** *********** VARIABLES *********** **/ |
---|
19 | |
---|
20 | |
---|
21 | this.createTools(); |
---|
22 | this.getQuicklook(); |
---|
23 | |
---|
24 | }, |
---|
25 | |
---|
26 | |
---|
27 | // CREATES AND BINDS ******************************************************** |
---|
28 | createTools: function() |
---|
29 | { |
---|
30 | this.createSelectSatellites(); |
---|
31 | this.createSelectProjections(); |
---|
32 | this.createSelectSpecies(); |
---|
33 | // this.createSelectLevel(); |
---|
34 | this.createCalendar(); |
---|
35 | |
---|
36 | |
---|
37 | <%--var quickLookButton = new Button( {id:"quickLookButton", value:"<spring:message code="label.quicklook.button"/>", parent:this.containerSelect, className: "small", onClick:jQuery.proxy( this.onClickQuicklook, this )} );--%> |
---|
38 | }, |
---|
39 | |
---|
40 | createSelectSatellites: function() |
---|
41 | { |
---|
42 | var div = $( document.createElement( "div" ) ); |
---|
43 | div.html( '<spring:message code="label.satellite"/> :' ); |
---|
44 | div.addClass( "selectTools" ); |
---|
45 | this.containerSelect.append( div ); |
---|
46 | |
---|
47 | var paramSelect = new Object(); |
---|
48 | paramSelect.id = "selectSatellites"; |
---|
49 | paramSelect.parent = div; |
---|
50 | this.selectSatellites = new Select( paramSelect ); |
---|
51 | this.selectSatellites.add( "metopa", "MetOp-A", jQuery.proxy(this.getQuicklook, this )); |
---|
52 | this.selectSatellites.add( "metopb", "MetOp-B", jQuery.proxy(this.getQuicklook, this )); |
---|
53 | this.selectSatellites.add( "metopab", '<spring:message code="label.either"/>', jQuery.proxy(this.getQuicklook, this )); |
---|
54 | this.selectSatellites.selectFirst(); |
---|
55 | }, |
---|
56 | |
---|
57 | createSelectProjections: function() |
---|
58 | { |
---|
59 | var div = $( document.createElement( "div" ) ); |
---|
60 | div.html( '<spring:message code="label.projection"/> :' ); |
---|
61 | div.addClass( "selectTools" ); |
---|
62 | this.containerSelect.append( div ); |
---|
63 | |
---|
64 | var paramSelect = new Object(); |
---|
65 | paramSelect.id = "selectProjections"; |
---|
66 | paramSelect.parent = div; |
---|
67 | this.selectProjections = new Select( paramSelect ); |
---|
68 | this.selectProjections.add( "global", '<spring:message code="label.globe"/>', jQuery.proxy(this.getQuicklook, this )); |
---|
69 | this.selectProjections.add( "europe", '<spring:message code="label.europe"/>', jQuery.proxy(this.getQuicklook, this )); |
---|
70 | this.selectProjections.add( "pn", '<spring:message code="label.pole.north"/>', jQuery.proxy(this.getQuicklook, this )); |
---|
71 | this.selectProjections.add( "ps", '<spring:message code="label.pole.south"/>', jQuery.proxy(this.getQuicklook, this )); |
---|
72 | this.selectProjections.selectFirst(); |
---|
73 | }, |
---|
74 | |
---|
75 | createSelectSpecies: function() |
---|
76 | { |
---|
77 | var div = $( document.createElement( "div" ) ); |
---|
78 | div.html( '<spring:message code="label.species"/> :' ); |
---|
79 | div.addClass( "selectTools" ); |
---|
80 | this.containerSelect.append( div ); |
---|
81 | |
---|
82 | var paramSelect = new Object(); |
---|
83 | paramSelect.id = "selectSpecies"; |
---|
84 | paramSelect.parent = div; |
---|
85 | this.selectSpecies = new Select( paramSelect ); |
---|
86 | this.selectSpecies.add( "CO", 'CO', jQuery.proxy(this.getQuicklook, this )); |
---|
87 | // this.selectSpecies.add( "H2O", 'H2O', jQuery.proxy(this.getQuicklook, this )); |
---|
88 | this.selectSpecies.add( "SKT", '<spring:message code="label.surftemp"/>', jQuery.proxy(this.getQuicklook, this )); |
---|
89 | this.selectSpecies.selectFirst(); |
---|
90 | }, |
---|
91 | |
---|
92 | <%--createSelectLevel: function()--%> |
---|
93 | <%--{--%> |
---|
94 | <%--var div = $( document.createElement( "div" ) );--%> |
---|
95 | <%--div.html( '<spring:message code="label.level"/> :' );--%> |
---|
96 | <%--div.addClass( "selectTools" );--%> |
---|
97 | <%--this.containerSelect.append( div );--%> |
---|
98 | |
---|
99 | <%--var paramSelect = new Object();--%> |
---|
100 | <%--paramSelect.id = "selectLevel";--%> |
---|
101 | <%--paramSelect.parent = div;--%> |
---|
102 | <%--this.selectLevel = new Select( paramSelect );--%> |
---|
103 | <%--this.selectLevel.add( "1000", '1000', jQuery.proxy(this.getQuicklook, this ));--%> |
---|
104 | <%--this.selectLevel.add( "500", '500', jQuery.proxy(this.getQuicklook, this ));--%> |
---|
105 | <%--this.selectLevel.add( "10", '10', jQuery.proxy(this.getQuicklook, this ));--%> |
---|
106 | <%--this.selectLevel.selectFirst();--%> |
---|
107 | <%--},--%> |
---|
108 | |
---|
109 | createCalendar: function() |
---|
110 | { |
---|
111 | this.calendarFormat = "%Y-%m-%d"; |
---|
112 | this.calendarConverter = new AnyTime.Converter( { format: this.calendarFormat } ); |
---|
113 | |
---|
114 | AnyTime.picker( "beginDate", { format: this.calendarFormat, firstDOW: 1, |
---|
115 | labelTitle: '<spring:message code="label.titlecalendar"/> :' , |
---|
116 | labelYear: '<spring:message code="label.yearcalendar"/> :' , |
---|
117 | labelMonth: '<spring:message code="label.monthcalendar"/> :', |
---|
118 | labelDayOfMonth: '<spring:message code="label.daycalendar"/> :', |
---|
119 | |
---|
120 | methodToCall: jQuery.proxy( this.onClickBeginDate, this ) |
---|
121 | } ); |
---|
122 | |
---|
123 | $( "#beginDate" ).val( formatDate( removeDaysToDate( new Date(), 1 ), "%Y-%m-%d" ) ); |
---|
124 | this.beginDate = this.calendarConverter.parse( $( "#beginDate" ).val() ).getTime(); |
---|
125 | }, |
---|
126 | |
---|
127 | // REQUESTS ******************************************************** |
---|
128 | requestQuickLooksBySelectValues: function() |
---|
129 | { |
---|
130 | $.ajax( { |
---|
131 | // url: "project?methodName=getQuicklookByValues&satellite=" + this.selectSatellites.getValue() + "&projection=" + this.selectProjections.getValue() + "&species=" + this.selectSpecies.getValue() + "&level=" + this.selectLevel.getValue() + "&date=" + this.beginDate, |
---|
132 | url: "project?methodName=getQuicklookByValues&satellite=" + this.selectSatellites.getValue() + "&projection=" + this.selectProjections.getValue() + "&species=" + this.selectSpecies.getValue() + "&date=" + this.beginDate, |
---|
133 | success:jQuery.proxy( this.handleQuickLooksBySelectValues, this ), |
---|
134 | error: jQuery.proxy( this.showErrors, this ) |
---|
135 | } ); |
---|
136 | }, |
---|
137 | |
---|
138 | |
---|
139 | // HANDLES ******************************************************** |
---|
140 | handleQuickLooksBySelectValues: function( result ) |
---|
141 | { |
---|
142 | |
---|
143 | var plotNameA = jQuery.parseJSON( result ).plotNameResultA; |
---|
144 | var plotNameB = jQuery.parseJSON( result ).plotNameResultB; |
---|
145 | var plotNameC = jQuery.parseJSON( result ).plotNameResultC; |
---|
146 | var plotNameD = jQuery.parseJSON( result ).plotNameResultD; |
---|
147 | var repDate = jQuery.parseJSON( result ).plotRepResult; |
---|
148 | |
---|
149 | |
---|
150 | if( plotNameA && plotNameB ) |
---|
151 | { |
---|
152 | this.containerResultA.html( "<center>MetOp-A</center><img src='resources/imgiasiA/" + repDate + "/" + plotNameA + "' width='430px' height='350px' onerror='javascript:displayNoImage()'><img src='resources/imgiasiA/" + repDate + "/" + plotNameC + "' width='430px' height='350px'>" ); |
---|
153 | this.containerResultB.html( "<center>MetOp-B</center><img src='resources/imgiasiB/" + repDate + "/" + plotNameB + "' width='430px' height='350px' onerror='javascript:displayNoImageB()'><img src='resources/imgiasiB/" + repDate + "/" + plotNameD + "' width='430px' height='350px'>" ); |
---|
154 | } |
---|
155 | else |
---|
156 | { |
---|
157 | if( plotNameA ) |
---|
158 | this.containerResultA.html( "<center>MetOp-A</center><img src='resources/imgiasiA/" + repDate + "/" + plotNameA + "' width='430px' height='350px' onerror='javascript:displayNoImage()'><img src='resources/imgiasiA/" + repDate + "/" + plotNameC + "' width='430px' height='350px'>" ); |
---|
159 | |
---|
160 | if( plotNameB ) |
---|
161 | this.containerResultA.html( "<center>MetOp-B</center><img src='resources/imgiasiB/" + repDate + "/" + plotNameB + "' width='430px' height='350px' onerror='javascript:displayNoImage()'><img src='resources/imgiasiB/" + repDate + "/" + plotNameD + "' width='430px' height='350px'>" ); |
---|
162 | |
---|
163 | } |
---|
164 | |
---|
165 | }, |
---|
166 | |
---|
167 | |
---|
168 | // EVENTS ******************************************************** |
---|
169 | onClickBeginDate: function() |
---|
170 | { |
---|
171 | this.beginDate = this.calendarConverter.parse( $( "#beginDate" ).val() ).getTime(); |
---|
172 | this.getQuicklook(); |
---|
173 | }, |
---|
174 | |
---|
175 | |
---|
176 | |
---|
177 | // OTHERS ******************************************************** |
---|
178 | showErrors: function( result ) |
---|
179 | { |
---|
180 | this.containerErrors.show(); |
---|
181 | this.containerErrors.html( result ); |
---|
182 | }, |
---|
183 | |
---|
184 | getQuicklook: function() |
---|
185 | { |
---|
186 | this.containerResultA.empty(); |
---|
187 | this.containerResultB.empty(); |
---|
188 | this.requestQuickLooksBySelectValues(); |
---|
189 | } |
---|
190 | |
---|
191 | |
---|
192 | } ); |
---|
193 | |
---|
194 | function displayNoImage() |
---|
195 | { |
---|
196 | $( "#containerResultA" ).html( '<spring:message code="label.error"/>' ); |
---|
197 | } |
---|
198 | function displayNoImageB() |
---|
199 | { |
---|
200 | $( "#containerResultB" ).html( '<spring:message code="label.error"/>' ); |
---|
201 | } |
---|
202 | </script> |
---|