7 |
7 |
--%>
|
8 |
8 |
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
9 |
9 |
<!DOCTYPE html>
|
10 |
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
|
10 |
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
11 |
11 |
<html lang="en-gb" dir="ltr" vocab="http://schema.org/">
|
12 |
12 |
<head>
|
13 |
13 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
... | ... | |
24 |
24 |
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
|
25 |
25 |
<link rel="icon" type="image/png" sizes="96x96" href="images/favicon//favicon-96x96.png">
|
26 |
26 |
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
|
27 |
|
<link href="images/favicon/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
|
|
27 |
<link href="images/favicon/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"/>
|
28 |
28 |
</head>
|
29 |
29 |
<body class="" style="">
|
30 |
30 |
<div class="uk-offcanvas-content uk-height-viewport">
|
31 |
|
<!-- MENU STARTS HERE -->
|
32 |
|
<!-- MAIN MENU STARTS HERE -->
|
33 |
|
<div class="tm-header tm-header-transparent" uk-header="">
|
34 |
|
<div class="uk-container uk-container-expand">
|
35 |
|
<nav class="uk-navbar" uk-navbar="{"align":"left"}">
|
36 |
|
<div class="uk-navbar-center">
|
37 |
|
<div class="uk-logo uk-navbar-item">
|
38 |
|
<img alt="OpenAIRE" class="uk-responsive-height" src="./images/Logo_Horizontal.png">
|
39 |
|
</div>
|
40 |
|
</div>
|
41 |
|
<!-- user menu -->
|
42 |
|
<div class=uk-navbar-right>
|
43 |
|
<ul class="uk-navbar-nav user_actions">
|
44 |
|
<c:choose>
|
45 |
|
<c:when test="${not authenticated}">
|
46 |
|
<li><a href="./openid_connect_login"> Sign in </a></li>
|
47 |
|
</c:when>
|
48 |
|
<c:otherwise>
|
49 |
|
<li>
|
50 |
|
<a class="login uk-icon" aria-expanded="false">
|
51 |
|
<svg height="60" width="60">
|
52 |
|
<span uk-icon="icon: user; ratio: 2"></span></svg>
|
53 |
|
</a>
|
54 |
|
</c:otherwise>
|
55 |
|
</c:choose>
|
56 |
|
<div class="uk-navbar-dropdown uk-navbar-dropdown-bottom-right" id="userMenu" style="left: 344.433px; top: 100px;">
|
57 |
|
<div class="uk-navbar-dropdown-grid uk-child-width-1-1 uk-grid uk-grid-stack" uk-grid="">
|
58 |
|
<div class="uk-first-column uk-height-max-medium uk-overflow-auto">
|
59 |
|
<ul class="uk-nav uk-navbar-dropdown-nav">
|
60 |
|
<li class=""><a href="./personalToken">Personal token</a></li>
|
61 |
|
<li class=""><a href="./registeredServices">Registered services</a></li>
|
62 |
|
<li class="uk-nav-divider "></li>
|
63 |
|
<li>
|
64 |
|
<a href="./openid_logout" id="logout">Log out</a>
|
65 |
|
</li>
|
66 |
|
</ul>
|
67 |
|
</div>
|
68 |
|
</div>
|
69 |
|
</div>
|
70 |
|
</li>
|
71 |
|
</ul>
|
72 |
|
</div>
|
73 |
|
<!-- USER MENU ENDS HERE -->
|
74 |
|
</nav>
|
75 |
|
</div>
|
76 |
|
</div>
|
77 |
|
<!-- MENU ENDS HERE -->
|
|
31 |
<jsp:include page="header.jsp"/>
|
78 |
32 |
<!-- CONTENT STARTS HERE -->
|
79 |
33 |
<div class="first_page_section uk-section-default uk-section uk-padding-remove-vertical">
|
80 |
|
<div class="first_page_banner_headline uk-grid-collapse uk-flex-middle uk-margin-remove-vertical uk-grid" uk-grid="">
|
|
34 |
<div class="first_page_banner_headline uk-grid-collapse uk-flex-middle uk-margin-remove-vertical uk-grid"
|
|
35 |
uk-grid="">
|
81 |
36 |
</div>
|
82 |
37 |
</div>
|
83 |
38 |
<div class=" uk-section uk-margin-small-top uk-container uk-container-large" id="tm-main">
|
84 |
39 |
<div class="uk-grid ">
|
85 |
40 |
<div class="uk-width-1-4@m">
|
86 |
|
<div class="uk-card uk-card-default uk-card-body">
|
|
41 |
<div class="uk-card uk-card-default uk-card-body">
|
87 |
42 |
<div class="uk-h4">API Access</div>
|
88 |
43 |
<ul class="uk-nav uk-nav-default">
|
89 |
44 |
<li class=""><a href="./personalToken">Personal token</a></li>
|
... | ... | |
93 |
48 |
</div>
|
94 |
49 |
<!-- CENTER SIDE -->
|
95 |
50 |
<div class="uk-width-2-3@l uk-width-2-3@m">
|
96 |
|
<h2 class="uk-h2 uk-margin-small-bottom">Add a new service</h2>
|
97 |
|
<div class="middle-box text-center loginscreen animated fadeInDown ">
|
98 |
|
<div class="k-width-1-1@m uk-width-1-1@s uk-text-center">
|
99 |
|
<!-- REGISTER FORM -->
|
100 |
|
<div id="registerForm">
|
101 |
|
<form action="registerService" method="POST" role="form" class="m-t uk-form-horizontal" id="register_form">
|
102 |
|
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
103 |
|
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div>
|
104 |
|
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div>
|
105 |
|
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span>
|
106 |
|
<c:remove var="message" scope="session" />
|
107 |
|
<h5 class="uk-h5">General</h5>
|
108 |
|
<div class="uk-margin">
|
109 |
|
<label class="uk-form-label" for="form-horizontal-text">Name(*)</label>
|
110 |
|
<span class="msg_first_name_error uk-text-danger uk-text-small uk-float-left" style='${msg_first_name_error_display}'>Please enter a name for your service.</span>
|
111 |
|
<input id="first_name" name="first_name" type="text" placeholder="Name (*)" class="form-control" value="${first_name}">
|
112 |
|
<c:remove var="msg_first_name_error_display" scope="session" />
|
113 |
|
<c:remove var="first_name" scope="session" />
|
114 |
|
</div>
|
115 |
|
<div class="uk-margin">
|
116 |
|
<label class="uk-form-label" for="form-horizontal-text">Description</label>
|
117 |
|
<textarea id="description" name="description" type="textarea" placeholder="Description:" class="form-control uk-textarea" rows="3" value=${description}></textarea>
|
118 |
|
<c:remove var="organization" scope="session" />
|
119 |
|
</div>
|
120 |
|
<hr class="uk-margin-remove-top">
|
121 |
|
<h5 class="uk-h5">Access</h5>
|
122 |
|
<div class="uk-margin">
|
123 |
|
<label class="uk-form-label" for="form-horizontal-text">Scope</label>
|
124 |
|
<input disabled value="openid" class="uk-input"></input>
|
125 |
|
</div>
|
126 |
|
<div class="uk-margin">
|
127 |
|
<label class="uk-form-label" for="form-horizontal-text">Grant Types</label>
|
128 |
|
<input disabled value="client credentials" class="uk-input"></input>
|
129 |
|
</div>
|
130 |
|
<hr class="uk-margin-remove-top">
|
131 |
|
<h5 class="uk-h5">Credentials</h5>
|
132 |
|
<div class="uk-margin">
|
133 |
|
<label class="uk-form-label" for="form-horizontal-text">Authentication Method</label>
|
134 |
|
<input disabled value="Asymmetrically-signed JWT assertion" class="uk-input"></input>
|
135 |
|
</div>
|
136 |
|
<div class="uk-margin">
|
137 |
|
<label class="uk-form-label" for="form-horizontal-text">Token Endpoint Authentication Signing Algorithm</label>
|
138 |
|
<input disabled value="RSASSA using SHA-256 hash algorithm" class="uk-input"></input>
|
139 |
|
</div>
|
140 |
|
<div class="uk-margin">
|
141 |
|
<label class="uk-form-label" for="form-horizontal-text">Public Key Set</label>
|
142 |
|
|
143 |
|
<label><input class="uk-radio" type="radio" name="key_radio" value="value" ${(key_radio == 'value' || key_radio == '') ? 'checked' : ''} >By Value</label>
|
144 |
|
<label><input class="uk-radio" type="radio" name="key_radio" value="${uri}" ${key_radio == 'uri' ? 'checked' : ''} >By URI</label><br>
|
145 |
|
|
146 |
|
<div id="value_input">
|
147 |
|
<span class="msg_key_value_error uk-text-danger uk-text-small uk-float-left" style='${msg_key_value_error_display}'>Please provide a valid JSON.</span>
|
148 |
|
<textarea id="value" name="value" type="textarea" placeholder='{"keys":[]}' class="form-control uk-textarea" rows="10" value="${value}"></textarea>
|
149 |
|
</div>
|
150 |
|
<div id="uri_input" style="display:none;">
|
151 |
|
<span class="msg_key_uri_error uk-text-danger uk-text-small uk-float-left" style='${msg_key_uri_error_display}'>Please provide a valid URI (do not forget the protocol! https://...)</span>
|
152 |
|
<input id="uri" name="uri" type="text" placeholder="https://" class="form-control" value=${uri}>
|
153 |
|
</div>
|
154 |
|
</div>
|
155 |
|
<hr class="uk-margin-remove-top">
|
156 |
|
<div class="uk-width-1-1 uk-grid-margin uk-first-column">
|
157 |
|
<a type="submit" class="uk-button uk-button-default" href="./registeredServices">Cancel</a>
|
158 |
|
<button type="submit" class="uk-button uk-button-primary" onclick="return validate();">Add new service</button>
|
159 |
|
</div>
|
160 |
|
</form>
|
|
51 |
<h4 class="uk-margin-remove-top uk-text-bold uk-text-primary">Add a new service</h4>
|
|
52 |
<!-- REGISTER FORM -->
|
|
53 |
<div id="registerForm">
|
|
54 |
<form action="registerService" method="POST" role="form" class="m-t uk-form-horizontal"
|
|
55 |
id="register_form">
|
|
56 |
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
|
|
57 |
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div>
|
|
58 |
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div>
|
|
59 |
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span>
|
|
60 |
<c:remove var="message" scope="session"/>
|
|
61 |
<h4 class="uk-text-bold uk-text-center">General</h4>
|
|
62 |
<div class="uk-margin-medium-top">
|
|
63 |
<label class="uk-form-label uk-text-bold" for="first_name">Name*</label>
|
|
64 |
<input id="first_name" name="first_name" type="text" placeholder="Name (*)"
|
|
65 |
class="form-control" value=${first_name}>
|
|
66 |
<span class="uk-text-danger uk-text-small">
|
|
67 |
Please enter a name for your service.</span>
|
|
68 |
<c:remove var="msg_first_name_error_display" scope="session"/>
|
161 |
69 |
</div>
|
162 |
|
<!-- END OF REGISTER FORM -->
|
163 |
|
<script>
|
164 |
|
$('input[type=radio][name=key_radio]').change(function() {
|
165 |
|
if (this.value == 'uri') {
|
166 |
|
$("#uri_input").show();
|
167 |
|
$("#value_input").hide();
|
168 |
|
|
169 |
|
} else if (this.value == 'value') {
|
170 |
|
$("#uri_input").hide();
|
171 |
|
$("#value_input").show();
|
172 |
|
}
|
173 |
|
});
|
174 |
|
|
175 |
|
function validate() {
|
176 |
|
var isValid = false;
|
177 |
|
if($("#first_name").val() != undefined) {
|
178 |
|
if($.trim($("#first_name").val()).length <= 0) {
|
179 |
|
$("#first_name").addClass('uk-input aai-form-danger');
|
180 |
|
$(".msg_first_name_error").show();
|
181 |
|
return false;
|
182 |
|
} else {
|
183 |
|
$(".msg_first_name_error").hide();
|
184 |
|
$("#first_name").removeClass('aai-form-danger');
|
185 |
|
}
|
186 |
|
}
|
187 |
|
|
188 |
|
if ($('input[type=radio][name=key_radio]:checked').val()==='value') {
|
189 |
|
isValid = validateJSON();
|
190 |
|
if (!isValid) {
|
191 |
|
$("#value_input").addClass('uk-input aai-form-danger');
|
192 |
|
$(".msg_key_value_error_display").show();
|
193 |
|
return false;
|
194 |
|
}
|
195 |
|
}
|
196 |
|
|
197 |
|
if ($('input[type=radio][name=key_radio]:checked').val()==='uri') {
|
198 |
|
isValid = validateURI();
|
199 |
|
if (!isValid) {
|
200 |
|
$("#uri_input").addClass('uk-input aai-form-danger');
|
201 |
|
$(".msg_key_uri_error_display").show();
|
202 |
|
return false;
|
203 |
|
}
|
204 |
|
}
|
205 |
|
|
206 |
|
}
|
207 |
|
|
208 |
|
function validateJSON() {
|
209 |
|
if ($("#value").val() != undefined && $("#value").val()!=="") {
|
210 |
|
if (/^[\],:{}\s]*$/.test($("#value").val().replace(/\\["\\\/bfnrtu]/g, '@').
|
211 |
|
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
|
212 |
|
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
213 |
|
return true;
|
214 |
|
|
215 |
|
} else {
|
216 |
|
return false;
|
217 |
|
}
|
218 |
|
}
|
219 |
|
return false;
|
220 |
|
}
|
221 |
|
|
222 |
|
function validateURI() {
|
223 |
|
if ($("#uri").val() != undefined && $("#uri").val()!=="") {
|
224 |
|
return /^(?:(?:(?:https):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test($("#uri").val());
|
225 |
|
}
|
226 |
|
return false;
|
227 |
|
}
|
228 |
|
|
229 |
|
$("#first_name").focusin(function () {
|
230 |
|
$(this).removeClass('aai-form-danger');
|
231 |
|
$(".msg_first_name_error").fadeOut();
|
232 |
|
});
|
233 |
|
|
234 |
|
$("#value_input").focusin(function () {
|
235 |
|
$(this).removeClass('aai-form-danger');
|
236 |
|
$(".msg_key_value_error").fadeOut();
|
237 |
|
});
|
238 |
|
|
239 |
|
$("#uri_input").focusin(function () {
|
240 |
|
$(this).removeClass('aai-form-danger');
|
241 |
|
$(".msg_key_uri_error").fadeOut();
|
242 |
|
});
|
243 |
|
</script>
|
244 |
|
</div>
|
245 |
|
</ul>
|
|
70 |
<div class="uk-margin-medium-top">
|
|
71 |
<label class="uk-form-label uk-text-bold" for="description">Description</label>
|
|
72 |
<textarea id="description" name="description" type="textarea" placeholder="Description:"
|
|
73 |
class="form-control uk-textarea" rows="3" value=${description}></textarea>
|
|
74 |
</div>
|
|
75 |
<hr class="uk-margin-medium uk-divider">
|
|
76 |
<h4 class="uk-text-bold uk-text-center">Access</h4>
|
|
77 |
<div class="uk-margin-medium-top">
|
|
78 |
<label class="uk-form-label uk-text-bold">Scope</label>
|
|
79 |
<input disabled value="openid" class="uk-input">
|
|
80 |
</div>
|
|
81 |
<div class="uk-margin-medium-top">
|
|
82 |
<label class="uk-form-label uk-text-bold">Grant Types</label>
|
|
83 |
<input disabled value="client credentials" class="uk-input">
|
|
84 |
</div>
|
|
85 |
<hr class="uk-margin-medium uk-divider">
|
|
86 |
<h4 class="uk-text-bold uk-text-center">Credentials</h4>
|
|
87 |
<div class="uk-margin-medium-top">
|
|
88 |
<label class="uk-form-label uk-text-bold">Authentication Method</label>
|
|
89 |
<input disabled value="Asymmetrically-signed JWT assertion" class="uk-input">
|
|
90 |
</div>
|
|
91 |
<div class="uk-margin-medium-top">
|
|
92 |
<label class="uk-form-label uk-text-bold">Token Endpoint Authentication
|
|
93 |
Signing Algorithm</label>
|
|
94 |
<input disabled value="RSASSA using SHA-256 hash algorithm" class="uk-input">
|
|
95 |
</div>
|
|
96 |
<div class="uk-margin-medium-top">
|
|
97 |
<label class="uk-form-label uk-text-bold">Public Key Set</label>
|
|
98 |
<span class="uk-float-right">
|
|
99 |
<span class="uk-margin-small-right">
|
|
100 |
<input id="by_value" class="uk-radio uk-margin-small-right" type="radio" name="key_radio" value="value" checked>
|
|
101 |
<label class="clickable" for="by_value">By Value</label>
|
|
102 |
</span>
|
|
103 |
<span>
|
|
104 |
<input id="by_uri" class="uk-radio uk-margin-small-right" type="radio" name="key_radio" value="uri">
|
|
105 |
<label class="clickable" for="by_uri">By URI</label>
|
|
106 |
</span>
|
|
107 |
</span>
|
|
108 |
<div id="value_input">
|
|
109 |
<textarea id="value" name="value" type="textarea" placeholder='{"keys":[]}'
|
|
110 |
class="form-control uk-textarea" rows="10">{"keys":[]}</textarea>
|
|
111 |
<span class="uk-text-danger uk-text-small">Please provide a valid JSON.</span>
|
|
112 |
</div>
|
|
113 |
<div id="uri_input" style="display:none;">
|
|
114 |
<input id="uri" name="uri" type="text" placeholder="https://" class="form-control" value="${jwksUri}">
|
|
115 |
<span class="uk-text-danger uk-text-small">Please provide a valid URI (do not forget the protocol! https://...)</span>
|
|
116 |
</div>
|
|
117 |
</div>
|
|
118 |
<div class="uk-flex uk-flex-right uk-margin-medium-top">
|
|
119 |
<a type="submit" class="uk-button uk-button-default uk-margin-small-right"
|
|
120 |
href="./registeredServices">Cancel</a>
|
|
121 |
<button type="submit" class="uk-button uk-button-primary" onclick="return validate();">
|
|
122 |
Add new service
|
|
123 |
</button>
|
|
124 |
</div>
|
|
125 |
</form>
|
246 |
126 |
</div>
|
|
127 |
<!-- END OF REGISTER FORM -->
|
|
128 |
</ul>
|
247 |
129 |
</div>
|
248 |
130 |
<!-- END OF CENTER SIDE -->
|
249 |
131 |
</div>
|
250 |
132 |
</div>
|
251 |
133 |
<!-- CONTENT ENDS HERE -->
|
252 |
134 |
<!-- FOOTER STARTS HERE-->
|
253 |
|
<div class="custom-footer" style="z-index: 200;">
|
254 |
|
<div class="uk-section-primary uk-section uk-section-small">
|
|
135 |
<div class="custom-footer" style="z-index: 200;">
|
|
136 |
<div class="uk-section-primary uk-section uk-section-small">
|
255 |
137 |
<div class="uk-container">
|
256 |
|
<div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid="">
|
257 |
|
<div class="uk-width-1-1@m uk-first-column">
|
258 |
|
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-center">
|
259 |
|
<img alt="OpenAIRE" class="el-image" src="./images/Logo_Horizontal_white_small.png">
|
260 |
|
</div>
|
261 |
|
<div class="footer-license uk-margin uk-margin-remove-bottom uk-text-center uk-text-lead">
|
262 |
|
<div><a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" rel="license"><img alt="Creative" src="./images/80x15.png" style="height: auto; max-width: 100%; vertical-align: middle;"></a> UNLESS OTHERWISE INDICATED, ALL MATERIALS CREATED BY THE OPENAIRE CONSORTIUM ARE LICENSED UNDER A <a href="http://creativecommons.org/licenses/by/4.0/" rel="license">CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE</a>.</div>
|
263 |
|
<div>OPENAIRE IS POWERED BY <a href="http://www.d-net.research-infrastructures.eu/">D-NET</a>.</div>
|
264 |
|
</div>
|
265 |
|
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-right">
|
266 |
|
<a class="uk-totop uk-icon" href="#" uk-scroll="" uk-totop="">
|
267 |
|
</a>
|
268 |
|
</div>
|
|
138 |
<div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid="">
|
|
139 |
<div class="uk-width-1-1@m uk-first-column">
|
|
140 |
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-center">
|
|
141 |
<img alt="OpenAIRE" class="el-image" src="./images/Logo_Horizontal_white_small.png">
|
|
142 |
</div>
|
|
143 |
<div class="footer-license uk-margin uk-margin-remove-bottom uk-text-center uk-text-lead">
|
|
144 |
<div><a href="http://creativecommons.org/licenses/by/4.0/" target="_blank"
|
|
145 |
rel="license"><img alt="Creative" src="./images/80x15.png"
|
|
146 |
style="height: auto; max-width: 100%; vertical-align: middle;"></a> UNLESS
|
|
147 |
OTHERWISE INDICATED, ALL MATERIALS CREATED BY THE OPENAIRE CONSORTIUM ARE LICENSED UNDER
|
|
148 |
A <a href="http://creativecommons.org/licenses/by/4.0/" rel="license">CREATIVE
|
|
149 |
COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE</a>.
|
|
150 |
</div>
|
|
151 |
<div>OPENAIRE IS POWERED BY <a href="http://www.d-net.research-infrastructures.eu/">D-NET</a>.
|
|
152 |
</div>
|
|
153 |
</div>
|
|
154 |
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-right">
|
|
155 |
<a class="uk-totop uk-icon" href="#" uk-scroll="" uk-totop="">
|
|
156 |
</a>
|
|
157 |
</div>
|
|
158 |
</div>
|
269 |
159 |
</div>
|
270 |
|
</div>
|
271 |
160 |
</div>
|
272 |
|
</div>
|
273 |
161 |
</div>
|
|
162 |
</div>
|
274 |
163 |
</div>
|
275 |
164 |
</body>
|
276 |
165 |
</html>
|
|
166 |
<script>
|
|
167 |
$('input[type=radio][name=key_radio]').change(function () {
|
|
168 |
if (this.value == 'uri') {
|
|
169 |
$("#uri_input").show();
|
|
170 |
$("#value_input").hide();
|
|
171 |
|
|
172 |
} else if (this.value == 'value') {
|
|
173 |
$("#uri_input").hide();
|
|
174 |
$("#value_input").show();
|
|
175 |
}
|
|
176 |
});
|
|
177 |
|
|
178 |
function validate() {
|
|
179 |
var isValid = false;
|
|
180 |
if ($("#first_name").val() != undefined) {
|
|
181 |
if ($.trim($("#first_name").val()).length <= 0) {
|
|
182 |
$("#first_name").addClass('uk-input aai-form-danger');
|
|
183 |
$(".msg_first_name_error").show();
|
|
184 |
return false;
|
|
185 |
} else {
|
|
186 |
$(".msg_first_name_error").hide();
|
|
187 |
$("#first_name").removeClass('aai-form-danger');
|
|
188 |
}
|
|
189 |
}
|
|
190 |
|
|
191 |
if ($('input[type=radio][name=key_radio]:checked').val() === 'value') {
|
|
192 |
isValid = validateJSON();
|
|
193 |
if (!isValid) {
|
|
194 |
$("#value_input").addClass('uk-input aai-form-danger');
|
|
195 |
$(".msg_key_value_error_display").show();
|
|
196 |
return false;
|
|
197 |
}
|
|
198 |
}
|
|
199 |
|
|
200 |
if ($('input[type=radio][name=key_radio]:checked').val() === 'uri') {
|
|
201 |
isValid = validateURI();
|
|
202 |
if (!isValid) {
|
|
203 |
$("#uri_input").addClass('uk-input aai-form-danger');
|
|
204 |
$(".msg_key_uri_error_display").show();
|
|
205 |
return false;
|
|
206 |
}
|
|
207 |
}
|
|
208 |
|
|
209 |
}
|
|
210 |
|
|
211 |
function validateJSON() {
|
|
212 |
if ($("#value").val() != undefined && $("#value").val() !== "") {
|
|
213 |
if (/^[\],:{}\s]*$/.test($("#value").val().replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
|
214 |
return true;
|
|
215 |
|
|
216 |
} else {
|
|
217 |
return false;
|
|
218 |
}
|
|
219 |
}
|
|
220 |
return false;
|
|
221 |
}
|
|
222 |
|
|
223 |
function validateURI() {
|
|
224 |
if ($("#uri").val() != undefined && $("#uri").val() !== "") {
|
|
225 |
return /^(?:(?:(?:https):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test($("#uri").val());
|
|
226 |
}
|
|
227 |
return false;
|
|
228 |
}
|
|
229 |
|
|
230 |
$("#first_name").focusin(function () {
|
|
231 |
$(this).removeClass('aai-form-danger');
|
|
232 |
$(".msg_first_name_error").fadeOut();
|
|
233 |
});
|
|
234 |
|
|
235 |
$("#value_input").focusin(function () {
|
|
236 |
$(this).removeClass('aai-form-danger');
|
|
237 |
$(".msg_key_value_error").fadeOut();
|
|
238 |
});
|
|
239 |
|
|
240 |
$("#uri_input").focusin(function () {
|
|
241 |
$(this).removeClass('aai-form-danger');
|
|
242 |
$(".msg_key_uri_error").fadeOut();
|
|
243 |
});
|
|
244 |
</script>
|
[Users | Trunk]: Add login in all pages. Change form ui