Strabon
view endpoint/WebContent/query.jsp @ 616:398331eac419
Fix auto scroll for all views (except download).
Navigation bar expands the selected group automatically.
Navigation bar expands the selected group automatically.
author | Kostis Kyzirakos <kkyzir@di.uoa.gr> |
---|---|
date | Sat Sep 29 09:37:21 2012 +0300 (2012-09-29) |
parents | 32af1c2fc1da |
children | 62e39ced8771 |
line source
1 <%@page import="java.net.URLEncoder"%>
2 <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
3 <%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
4 <%@page import="org.springframework.web.context.WebApplicationContext"%>
5 <%@page import="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapper"%>
6 <%@page import="eu.earthobservatory.org.StrabonEndpoint.StrabonBeanWrapperConfiguration"%>
7 <%@page import="java.util.List"%>
8 <%@page import="java.util.Iterator"%>
9 <jsp:directive.page import="eu.earthobservatory.org.StrabonEndpoint.Common"/>
10 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
11 <html>
12 <head>
13 <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
14 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
15 <link rel="stylesheet" href="style.css" type="text/css" />
16 <script type="text/javascript">
17 function toggleMe(a) {
18 var e = document.getElementById(a);
19 if (!e) {
20 return true;
21 }
22 if (e.style.display == "none") {
23 e.style.display = "block";
24 } else {
25 e.style.display = "none";
26 }
27 return true;
28 }
29 </script>
30 <%
31 // get query parameter or attribute (the attribute comes from ConnectionBean)
32 String query = "";
33 if (request.getParameter("query") != null) {
34 query = request.getParameter("query");
36 } else if (request.getAttribute("query") != null) {
37 query = (String) request.getAttribute("query");
39 }
41 if ("null".equals(query)) {
42 query = "";
43 }
45 // get format parameter or attribute (the attribute comes from ConnectionBean)
46 String selFormat = "";
47 if (request.getParameter("format") != null) {
48 selFormat = request.getParameter("format");
50 } else if (request.getAttribute("format") != null) {
51 selFormat = (String) request.getAttribute("format");
53 }
55 // get handle parameter or attribute (the attribute comes from ConnectionBean)
56 String handle = "";
57 if (request.getParameter("handle") != null) {
58 handle = request.getParameter("handle");
60 } else if (request.getAttribute("handle") != null) {
61 handle = (String) request.getAttribute("handle");
63 }
65 if (request.getAttribute("pathToKML") != null) {
66 if ("map_local".equals(request.getAttribute("handle"))) {
67 %>
68 <script type="text/javascript" src="js/geoxml3-kmz.js"></script>
69 <script type="text/javascript" src="js/ProjectedOverlay.js"></script>
70 <%
71 }
72 %>
73 <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
74 <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
75 <script type="text/javascript">
76 function initialize() {
77 // center at Brahames
78 var brahames = new google.maps.LatLng(37.92253, 23.72275);
79 var myOptions = {
80 zoom: 11,
81 center: brahames,
82 mapTypeId: google.maps.MapTypeId.ROADMAP
83 };
85 // get KML filename
86 var kml = '<%=request.getAttribute("pathToKML")%>';
87 // create map
88 var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
90 // display using geoxml3
91 <%if ("map_local".equals(request.getAttribute("handle"))) {%>
92 var myParser = new geoXML3.parser({map: map});
93 myParser.parse(kml);
95 <%} else {%>
96 var ctaLayer = new google.maps.KmlLayer(kml);
97 ctaLayer.setMap(map);
98 <%}%>
100 <%if ("map".equals(request.getAttribute("handle")) || "map_local".equals(request.getAttribute("handle"))) {%>
101 $('html, body').animate({
102 scrollTop: $("#divResultsStart").offset().top
103 }, 1000);
104 <%}%>
105 }
106 </script>
107 <% } else { %>
108 <script type="text/javascript">
109 function initialize() {
110 <%
111 if (query != "" || selFormat != "" || handle != "") {
112 %>
113 $('html, body').animate({
114 scrollTop: $("#divResultsStart").offset().top
115 }, 1000);
116 <%}%>
117 }
118 </script>
119 <%}%>
121 <!-- jQuery start -->
122 <link type="text/css" href="style-menu.css" rel="stylesheet" />
123 <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
124 <script type="text/javascript" src="js/jquery-ui-1.8.23.custom.min.js"></script>
125 <script type="text/javascript">
126 $(function(){
127 // Accordion
128 $("#accordion").accordion({
129 header: "h3",
130 fillSpace: true,
131 navigation: true
132 });
133 //hover states on the static widgets
134 $('#dialog_link, ul#icons li').hover(
135 function() { $(this).addClass('ui-state-hover'); },
136 function() { $(this).removeClass('ui-state-hover'); }
137 );
138 });
139 </script>
140 <style type="text/css">
141 /*demo page css*/
142 body{ font: 90% "Trebuchet MS", sans-serif; margin: 50px;}
143 .container { height:700px; width:165px;}
144 .demoHeaders { margin-top: 1em;}
145 #dialog_link {padding: .4em 1em .4em 20px;text-decoration: none;position: relative;}
146 #dialog_link span.ui-icon {margin: 0 5px 0 0;position: absolute;left: .2em;top: 50%;margin-top: -8px;}
147 ul#icons {margin: 0; padding: 0;}
148 ul#icons li {margin: 1px; position: relative; padding: 1px 0; cursor: pointer; float: left; list-style: none;}
149 ul#icons span.ui-icon {float: left; margin: 0 1px;}
150 </style>
151 <!-- jQuery end -->
153 <title>TELEIOS: Strabon Endpoint</title>
154 </head>
155 <body topmargin="0" leftmargin="0" link="#FFFFFF" vlink="#FFFFFF" alink="#FFFFFF" onload="initialize()">
157 <!-- include TELEIOS header and description -->
158 <%@ include file="teleios-header.html"%>
159 <!-- include TELEIOS header and description -->
161 <FORM enctype="UTF-8" accept-charset="UTF-8" method="post" action="Query">
162 <INPUT type=hidden name="view" value="HTML"/>
164 <table border="0" width="100%">
165 <tr>
166 <td width="90" valign="top" bgcolor="#dfe8f0">
167 <table border="0" cellspacing="0" cellpadding="0" width="165">
168 <tr><td id="twidth">
169 <div class="container">
170 <div id="accordion">
171 <%
172 StrabonBeanWrapper strabonWrapper;
173 ServletContext context;
174 context = getServletContext();
175 WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(context);
176 strabonWrapper=(StrabonBeanWrapper) applicationContext.getBean("strabonBean");
178 Iterator <StrabonBeanWrapperConfiguration> entryListIterator = strabonWrapper.getEntries().iterator();
179 boolean first = true;
180 String hash = "";
181 while(entryListIterator.hasNext())
182 {
183 StrabonBeanWrapperConfiguration entry = entryListIterator.next();
185 if (entry.isHeader()) {
186 if (!first) {
187 %>
188 </div></div>
189 <%
190 } else {
191 first = false;
192 }
194 String label=entry.getLabel();
195 String bean=entry.getBean();
196 String style = "", href = "";
197 if (bean == null) {
198 hash = new Integer(Math.abs(label.hashCode())).toString();
199 href="href=\"#"+hash+"\"";
200 } else {
201 hash = new Integer(Math.abs(label.hashCode()*bean.hashCode())).toString();
202 href = "href=\"" +bean + "#"+ hash+"\"";
203 style = "class=\"navText\"";
204 }
206 %>
207 <div><h3><a <%=style%> <%=href%>><%=label%></a></h3><div>
208 <%
209 } else {
210 String href="\""+URLEncoder.encode(entry.getBean(),"utf-8")+"?view=HTML&handle="+entry.getHandle()+"&query="+URLEncoder.encode(entry.getStatement(),"utf-8")+"&format="+URLEncoder.encode(entry.getFormat(),"utf-8")+(hash == "" ? "" : "#" + hash)+"\"";
211 String title="\""+entry.getTitle()+"\"";
212 String label=entry.getLabel();
213 %>
214 <b>·</b> <a class="linkText" href=<%=href%> title=<%=title%>><%=label%></a><br/>
215 <%
217 }
218 }
219 %>
220 </div>
221 </div>
222 </td>
223 </tr>
224 <!--
225 <tr><td width="90" class="style4"><a href="describe.jsp" class="navText">Describe</a></td></tr>
226 <tr><td width="90" class="style4"><a href="store.jsp" class="navText" title="Store triples">Store</a></td></tr>
227 -->
228 </table>
229 </td>
230 <td width="*" valign="top" >
231 <table cellspacing="5">
232 <%if (request.getAttribute("info") != null) { %>
233 <!-- Info Message -->
234 <TR><TD colspan=2>
235 <CENTER><P><%=request.getAttribute("info") %></P></CENTER>
236 </TD></TR>
237 <!-- Info Message -->
238 <%}%>
239 <tr>
240 <td id="output">stSPARQL Query:</td>
241 <td id="output"><textarea name="query" title="pose your query/update here" rows="15" cols="100"><%=query%></textarea></td>
242 </tr>
243 <tr>
244 <td id="output"><center>Output Format:<br/>
245 <select name="format" title="select one of the following output format types">
246 <%
247 for (String format : Common.registeredQueryResultsFormatNames) {%>
248 <OPTION value="<%=format%>"<%=format.equals(selFormat) ? "selected":""%>><%=format%></OPTION>
249 <%}%>
250 </select></center>
251 </td>
252 <td colspan=2><br/><center>
253 <input type="submit" title="execute query" value="Query" name="submit" /><br/>
254 <input type="submit" title="execute update" value="Update" name="submit" style="width: 400px"/></center><br/></td>
255 </tr>
256 <tr>
257 <td id="output"><center>View Result:<br/>
258 <SELECT name="handle" title="select how you would like to view the result">
259 <OPTION value="plain"<%= ("plain".equals(handle)) ? "selected":""%>>Plain</OPTION>
260 <OPTION value="download"<%= ("download".equals(handle)) ? "selected":""%>>Download</OPTION>
261 <OPTION value="map"<%= ("map".equals(handle)) ? "selected":""%>>On a map</OPTION>
262 <OPTION value="map_local"<%= ("map_local".equals(handle)) ? "selected":""%>>On a map (localhost)</OPTION>
263 </SELECT></center>
264 </td>
265 <td colspan=2> </td>
266 </tr>
267 <% if (request.getAttribute("error") != null) {%>
268 <!-- Error Message -->
269 <TR>
270 <TD id="output">Result: </TD><TD id="output"><%=request.getAttribute("error") %></TD>
271 </TR>
272 <!-- Error Message -->
273 <%}%>
274 </table></td></tr></table><br/><br/>
275 </form>
276 <a name="#results"> </a>
277 <div id="divResultsStart"></div>
278 <!-- Response -->
279 <% if (request.getAttribute("response") != null) {
280 if (Common.getHTMLFormat().equals(request.getParameter("format"))) {%>
281 <%=request.getAttribute("response")%>
282 <%} else { %>
283 <PRE><%=request.getAttribute("response") %></PRE>
284 <%}%>
285 <%}%>
286 <!-- Response -->
287 <% if (request.getAttribute("pathToKML") != null) { %>
288 <div id="map_canvas"></div>
289 <%}%>
290 <div id="divResultsEnd" style="height: 1px; width 1px"></div>
291 </body>
292 </html>