-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
245 lines (221 loc) · 11.4 KB
/
index.html
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<!DOCTYPE html>
<!--
JBoss, Home of Professional Open Source
Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
contributors by the @authors tag. See the copyright.txt in the
distribution for a full listing of individual contributors.
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.
-->
<html>
<head>
<title>HTML5 QuickStart</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- Disable phone number detection on iOS. -->
<meta name="format-detection" content="telephone=no" />
<!-- Set the tab, home page, shortcut icons -->
<!-- <link rel="Shortcut Icon" href="img/"> -->
<!-- <link rel="apple-touch-icon" href="img/"/> -->
<!-- For minification, comment out this link -->
<link rel="stylesheet" href="css/jquery.mobile-1.4.2.css"/>
<!-- For minification, uncomment out this file -->
<!--<link rel="stylesheet" href="css/jquery.mobile-1.4.2.min.css"/>-->
<!-- For minification, comment out this link -->
<link rel="stylesheet" href="css/screen.css"/>
<!-- For minification, uncomment out this file -->
<!--<link rel="stylesheet" href="css/screen.min.css"/>-->
<!-- Set viewport scaling and zoom features -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- For minification, comment out this file -->
<script type="text/javascript" src="js/libs/jquery-2.0.3.js"></script>
<!-- For minification, uncomment out this file -->
<!--<script type="text/javascript" src="js/libs/jquery-2.0.3.min.js"></script>-->
<!-- For minification, comment out this file -->
<script type="text/javascript" src="js/libs/jquery.mobile-1.4.2.js"></script>
<!-- For minification, uncomment out this file -->
<!--<script type="text/javascript" src="js/libs/jquery.mobile-1.4.2.min.js"></script>-->
<!-- For minification, comment out this file -->
<script type="text/javascript" src="js/libs/lodash-2.4.1.js"></script>
<!-- For minification, uncomment out this file -->
<!--<script type="text/javascript" src="js/libs/lodash-2.4.1.min.js"></script>-->
<!-- For minification, comment out this file -->
<script type="text/javascript" src="js/app.js"></script>
<script type="text/javascript" src="js/env.js"></script>
<!-- For minification, uncomment out this file -->
<!-- <script type="text/javascript" src="js/app.min.js"></script> -->
<script type="text/javascript">
$( document ).ready( function() {
//setup the app after all scripts have loaded
$(function() {
// Enhance the footer since it is present outside the page definition and hence not enhanced automatically.
$( "[data-role='footer']" ).toolbar();
$( "[data-role='navbar']" ).navbar();
});
// Update the contents of the toolbars
$( document ).on( "pageshow", "[data-role='page']", function() {
var current = $( this ).jqmData( "title" );
// Remove active class from nav buttons
$( "[data-role='navbar'] a.ui-btn-active" ).removeClass( "ui-btn-active" );
// Add active class to current nav button
$( "[data-role='navbar'] a" ).each(function() {
if ( $( this ).text() === current ) {
$( this ).addClass( "ui-btn-active" );
}
});
});
// On browsing to the Members jQuery Mobile page, update it to show all members
$("#member-art").on("pagebeforeshow", function() {
// Fetches the initial member data and populates the table using lodash templates
updateMemberTable();
});
//Register an event listener on the submit action
$('#reg').submit(function(event) {
event.preventDefault();
var memberData = $(this).serializeObject();
registerMember(memberData);
});
//Register the cancel listener
$('#cancel').click(function(event) {
//clear input fields
$('#reg')[0].reset();
//clear existing msgs
$('span.invalid').remove();
$('span.success').remove();
});
$("#refreshButton").click(function(event) {
updateMemberTable();
});
//Clear member registration and error messages on page change
$("#register-art").on("pagebeforeshow", function(event) {
$("#formMsgs").empty();
$('span.invalid').remove();
});
});
$.fn.serializeObject = function() {
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
</script>
</head>
<body>
<div id="container">
<section>
<!-- New HTML5 article tag -->
<article id="register-art" data-role="page" data-title="Add a Member">
<!-- Header -->
<div data-role="header" class="header">
<h3>Contact List</h3>
</div>
<!-- /Header -->
<div class="ui-content" role="main">
<div class="wrap">
<!-- For now mapping bean validation constraints from server side model is a manual task -->
<form name="reg" id="reg" data-ajax="false">
<fieldset>
<legend>Register a member:</legend>
<div class="ui-field-contain">
<label for="name">Name:</label>
<input type="text" name="name" id="name" placeholder="Your Name" required autofocus/>
</div>
<div class="ui-field-contain">
<label for="email">Email:</label>
<input type="email" name="email" id="email" placeholder="Your Email" required/>
</div>
<div class="ui-field-contain">
<label for="phoneNumber">Phone #:</label>
<input type="tel" name="phoneNumber" id="phoneNumber" pattern="[0-9]{10,12}" placeholder="Your Phone #" required/>
</div>
<div id="formMsgs"></div>
<div class="ui-grid-a app-responsive">
<div class="ui-block-a"><input type="submit" id="register" value="Register" data-theme="b"/></div>
<div class="ui-block-b"><input type="button" name="cancel" id="cancel" value="Reset"/></div>
</div>
</fieldset>
</form>
</div>
</div>
</article>
<!-- New HTML5 article tag -->
<article id="member-art" data-role="page" data-title="List Members">
<!-- Header -->
<div data-role="header" class="header" data-position="fixed">
<h3>HTML5 Quickstart</h3>
</div>
<!-- /Header -->
<div class="ui-content" role="main">
<div class="wrap">
<button id="refreshButton" data-role="button" data-inline="true" data-icon="refresh">Refresh Members</button>
<table data-role="table" id="member-table" data-mode="reflow" class="app-responsive table-stroke">
<thead>
<tr>
<th data-priority="1">Id</th>
<th data-priority="persist">Name</th>
<th data-priority="2">Email</th>
<th data-priority="3">Phone #</th>
<th data-priority="4">REST URL</th>
</tr>
</thead>
<tbody id="members">
<!-- This is where the list of members gets populated by the templates. This row is only
here as an example of the code that will be inserted.
<tr>
<th>0</td>
<td>John Smith</td>
<td><a href="mailto:[email protected]" class="ui-link">[email protected]</a></td>
<td><a href="tel:2125551212" class="ui-link">Call</a> or <a href="sms:2125551212" class="ui-link">SMS</a> 2125551212</td>
<td><a href="rest/members/0" rel="external" target="_blank" class="resturl ui-link">JSON</a></td>
</tr>
-->
</tbody>
</table>
<div class="member-foot">
<!-- Sets the JAX-RS URLs to retrieve all members either as XML or JSON data.-->
REST URL for all members:
<a href="rest/members" target="_blank" rel="external">JSON</a>
</div>
</div>
</div>
</article>
<!-- Footer -->
<div data-role="footer" data-tap-toggle="false" data-position="fixed" data-theme="a">
<div data-role="navbar">
<ul>
<li><a href="#register-art" data-icon="plus">Add a Member</a></li>
<li><a href="#member-art" data-icon="grid">List Members</a></li>
</ul>
</div>
</div>
<!-- /Footer -->
</section>
</div>
<script type="text/template" id="member-tmpl">
<% _.each(members, function(member) { %>
<tr>
<th><%=member.id%></td>
<td><%=member.name%></td>
<td><a href="mailto:<%=member.email%>" class="ui-link"><%=member.email%></a></td>
<td><a href="tel:<%=member.phoneNumber%>" class="ui-link">Call</a> or <a href="sms:<%=member.phoneNumber%>" class="ui-link">SMS</a> <%=member.phoneNumber%></td>
<td><a href="http://"+env.hostname+"/rest/members/<%=member.id%>" rel="external" target="_blank" class="resturl ui-link">JSON</a></td>
</tr>
<% }); %>
</script>
</body>
</html>