forked from GoogleCloudPlatform/prediction-try-java-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.jsp
More file actions
129 lines (126 loc) · 5.53 KB
/
Copy pathindex.jsp
File metadata and controls
129 lines (126 loc) · 5.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!--
/*
* Copyright 2012 Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Marc Cohen
*
*/
-->
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<!--[if lt IE 7 ]> <html class="no-js ie6" lang="en"> <![endif]-->
<!--[if IE 7 ]> <html class="no-js ie7" lang="en"> <![endif]-->
<!--[if IE 8 ]> <html class="no-js ie8" lang="en"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<!-- HTML 5 Boilerplate -->
<link rel="stylesheet" href="/css/base_style.css?v=2">
<!-- app specific styles -->
<link rel="stylesheet" href="/css/style.css">
<link rel="shortcut icon" href="/images/favicon.ico" /> <title>Try the Google Prediction API</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.5
.1/jquery.js"></script>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1
.8.13/jquery-ui.js"></script> <script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="/js/predict.js"></script>
</head>
<body>
<div>
<header>
<div id="logo"></div>
<div id="app_title">Try the <a id="api_link" href="https://developers.google.com/prediction/">Google Prediction API</a></div>
</header>
<table cellspacing="10">
<tr><td> </td></tr>
<tr><td> </td></tr>
<tr><td><div class="label">Select a model:</div></td><td colspan="2">
<select id="model_id" onchange="change_model(this)">
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%
Map<String, Object> selectedModel = null;
String selectedModelName =
(String) request.getAttribute("selected_model_name");
String selectedModelDesc = "";
Map<String, Object> models =
(Map<String, Object>) request.getAttribute("models");
String user_email = (String) request.getAttribute("user_email");
// Iterate model description data, building pull-down menu
// and display selected model's description data.
for (Map.Entry entry : models.entrySet()) {
String modelName = (String) entry.getKey();
Map<String, Object> model = (Map<String, Object>) entry.getValue();
String modelId = (String) model.get("model_id");
Map<String, Integer> user_list =
(Map<String, Integer>) model.get("user_list");
if ((user_list.size() > 0) &&
(!user_list.containsKey(user_email))) {
continue;
}
// Mark selected model for generating input fields below.
if (selectedModelName == null) {
selectedModelName = modelName;
selectedModel = model;
}
String selectedMarker = "";
if (modelName.equals(selectedModelName)) {
selectedModelName = modelName;
selectedModel = model;
selectedMarker = " selected";
selectedModelDesc = (String) model.get("description");
}
out.println("<option value=\"" + modelName + "\"" +
selectedMarker + ">" + modelName + "</option>");
}
out.println("</select><span class=\"help\">" +
selectedModelDesc + "</span></td></tr>");
// Display selected model's input fields.
List<Map<String, String> > fields =
(List<Map<String, String> >) selectedModel.get("fields");
for (Map<String, String> field : fields) {
String label = field.get("label");
String help = field.get("help");
String rows = field.get("rows");
Integer num_rows = Integer.parseInt(rows);
String cols = field.get("cols");
Integer num_cols = Integer.parseInt(cols);
out.println("<tr><td><div class=\"label\">" + label +
":</div></td><td>");
if (num_rows > 1) {
out.println("<textarea cols=\"" + num_cols + "\" rows=\"" +
num_rows + "\" id=\"" + label +
"\" class=\"input\"></textarea></td><td><div class=\"help\">"
+ help + "</div></td></tr>");
} else {
out.println(
"<input onkeydown=\"keydown(event)\" type=\"text\" size=\"" +
cols + "\" id=\"" + label +
"\" class=\"input\"></input></td><td><div class=\"help\">" +
help + "</div></td></tr>");
}
}
%>
</td></tr>
<tr><td></td><td>
<a class="atd-button atd-search-button" style="margin-left: 0px; margin-top: 10px;" onclick="predict()">Predict</a>
</td></tr>
<tr><td> </td></tr>
<tr><td><div class="label">Results:</div></td><td><b><div id="prediction_result"></div></b><a href='' id="switch_chart_link"></a></td></tr>
<tr><td> </td><td>
<div id="results_chart"></div>
</td></tr>
</table>
</div>
</body>