Skip to content

Commit 3fefd23

Browse files
author
Sachin Maheshwari
committed
adding regsource
1 parent 56f0ff6 commit 3fefd23

File tree

1 file changed

+186
-100
lines changed

1 file changed

+186
-100
lines changed
Lines changed: 186 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,198 @@
11
<!DOCTYPE html>
2-
<html>
3-
<head>
4-
<style>
5-
div {
6-
padding: 10px;
7-
}
8-
9-
#main {
10-
text-align: center;
11-
margin: 10%;
12-
}
13-
14-
#hd {
15-
text-align: left;
16-
margin-left: 25%;
17-
margin-right: 25%;
18-
}
19-
20-
#cc {
21-
text-align: left;
22-
margin-left: 25%;
23-
margin-right: 25%;
24-
}
25-
26-
#sb {
27-
text-align: center;
2+
<html lang="en">
3+
<head>
4+
<title>Signup</title>
5+
<meta charset="utf-8" />
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
7+
<meta name="viewport" content="width=device-width, initial-scale=1" />
8+
<link rel="shortcut icon" href="./images/favicon.ico" />
9+
<link
10+
href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700&display=swap"
11+
rel="stylesheet"
12+
/>
13+
<link rel="stylesheet" href="./styles.css" />
2814

15+
<script
16+
src="https://code.jquery.com/jquery-3.5.1.min.js"
17+
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
18+
crossorigin="anonymous"
19+
></script>
20+
<script src="https://authlib.topcoder-dev.com/country.js"></script>
21+
<script>
22+
var formAction = "https://topcoder-dev.auth0.com/continue";
23+
var apiServerUrl = "https://api.topcoder-dev.com/v3/users";
24+
var qs = (function (a) {
25+
if (a == "") return {};
26+
var b = {};
27+
for (var i = 0; i < a.length; ++i) {
28+
var p = a[i].split("=", 2);
29+
if (p.length == 1) b[p[0]] = "";
30+
else b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
2931
}
30-
31-
select {
32-
padding: 10px;
33-
}
34-
35-
input {
36-
padding: 10px;
37-
}
38-
39-
#error {
40-
text-align: center;
41-
color: red;
42-
}
43-
</style>
44-
<script src="https://code.jquery.com/jquery-3.5.1.min.js"
45-
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous">
32+
return b;
33+
})(window.location.search.substr(1).split("&"));
4634
</script>
47-
<script language="javascript" type="text/javascript" src="./country.js"></script>
4835
<script>
49-
var formAction = "https://<tenant>.auth0.com/continue";
50-
var apiServerUrl = "<tc-api-url>/v3/users"
51-
var qs = (function (a) {
52-
if (a == "") return {};
53-
var b = {};
54-
for (var i = 0; i < a.length; ++i) {
55-
var p = a[i].split('=', 2);
56-
if (p.length == 1)
57-
b[p[0]] = "";
58-
else
59-
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
36+
$(document).ready(function () {
37+
$.each(countryObjs, function () {
38+
$("#country").append(
39+
$("<option></option>").text(this.name).val(JSON.stringify(this))
40+
);
41+
});
42+
$("#continueBtn").click(function () {
43+
var handle = $("#handle").val();
44+
var country = $("#country").val();
45+
$.ajax({
46+
url: apiServerUrl + "/validateHandle?handle=" + handle,
47+
xhrFields: {
48+
withCredentials: true,
49+
},
50+
success: function (result) {
51+
if (
52+
result.result.status === 200 &&
53+
!result.result.content.valid
54+
) {
55+
$("#error").html("Error: " + result.result.content.reason);
56+
$("#error").closest(".message").fadeIn();
57+
}
58+
if (result.result.status === 200 && result.result.content.valid) {
59+
$("#error").closest(".message").fadeOut();
60+
$("#error").html("");
61+
document.getElementById("signup").action = formAction;
62+
document.getElementById("state").value = qs["state"];
63+
document.getElementById("regSource").value = qs["state"] || null;
64+
document.getElementById("signup").submit();
65+
}
66+
},
67+
});
68+
return false;
69+
});
70+
71+
/**
72+
* Script for field placeholder
73+
**/
74+
$(".messages .close-error").on("click", function () {
75+
$(this).closest(".message").fadeOut();
76+
});
77+
var inputObj = $(".input-field .input-text"),
78+
continueBtnDisable = false;
79+
inputObj
80+
.on("focus", function () {
81+
$(this).parent().addClass("active focussed");
82+
})
83+
.on("blur", function () {
84+
var parentObj = $(this).parent();
85+
if ($(this).val() === "") {
86+
parentObj.removeClass("active");
6087
}
61-
return b;
62-
})(window.location.search.substr(1).split('&'));
63-
</script>
64-
<script>
65-
$(document).ready(function () {
66-
$.each(countryObjs, function () {
67-
$('#country').append(
68-
$("<option></option>").text(this.name).val(JSON.stringify(this))
69-
);
88+
parentObj.removeClass("focussed");
89+
})
90+
.on("change", function () {
91+
var disableStatus = false;
92+
inputObj.each(function (index, element) {
93+
if ($(element).val() === "") {
94+
disableStatus = true;
95+
return;
96+
}
7097
});
71-
$("#continueBtn").click(function () {
72-
var handle = $("#handle").val();
73-
var country = $("#country").val();
74-
$("#error").html('');
75-
$.ajax({
76-
url: apiServerUrl + "/validateHandle?handle=" + handle,
77-
xhrFields: {
78-
withCredentials: true
79-
},
80-
success: function (result) {
81-
if ((result.result.status === 200) && (!result.result.content.valid)) {
82-
$("#error").html("Error: " + result.result.content.reason);
83-
}
84-
if ((result.result.status === 200) && (result.result.content.valid)) {
85-
document.getElementById("signup").action = formAction;
86-
document.getElementById("state").value = qs['state'];
87-
document.getElementById("signup").submit();
88-
}
89-
}
90-
});
91-
});
92-
});
98+
setContinueButtonDisabledStatus(disableStatus);
99+
})
100+
.each(function (index, element) {
101+
var parentObj = $(element).parent();
102+
if ($(element).val() !== "") {
103+
parentObj.addClass("active");
104+
} else {
105+
parentObj.removeClass("active");
106+
}
107+
108+
if ($(element).val() === "" && continueBtnDisable === false) {
109+
continueBtnDisable = true;
110+
}
111+
112+
setContinueButtonDisabledStatus(continueBtnDisable);
113+
});
114+
});
115+
function setContinueButtonDisabledStatus(status) {
116+
var continueBtnObj = $("#continueBtn");
117+
if (status) {
118+
continueBtnObj.attr("disabled", true);
119+
} else {
120+
continueBtnObj.removeAttr("disabled");
121+
}
122+
}
93123
</script>
94-
</head>
95-
<body>
96-
<div id='main'>
97-
<div id='error'></div>
98-
<form method="GET" id='signup' action="#">
99-
<input id='state' name="state" value="" type='hidden' />
100-
<div id='hd'>
101-
<span>Enter your handle </span> <input id="handle" placeholder="handle" name="handle" size="43" />
124+
</head>
125+
126+
<body class="center-align-card">
127+
<!-- Page Wrapper -->
128+
<div class="page-wrapper">
129+
<!-- For ADA - Skip to Content Area -->
130+
<a class="action skip" href="#contentarea">Skip to Content</a>
131+
<!-- Page Content Area - Header + Main content -->
132+
<div class="page-content">
133+
<header class="header">
134+
<a href="/" class="logo-link">
135+
<img
136+
src="./images/logo.png"
137+
alt="Topcoder Logo"
138+
width="94"
139+
height="30"
140+
/>
141+
</a>
142+
</header>
143+
<main id="main" class="page-main">
144+
<a id="contentarea" tabindex="-1"></a>
145+
<h1 id="page-title-heading" class="page-title-heading clip-me">
146+
Signup
147+
</h1>
148+
<div class="messages">
149+
<div role="alert" class="message error">
150+
<div id="error" class="message-content"></div>
151+
<span class="close-error" tabindex="0">
152+
<span class="clip-me">Close</span>
153+
</span>
154+
</div>
155+
</div>
156+
<form method="GET" id="signup" action="#">
157+
<input id="state" name="state" value="" type="hidden" />
158+
<input id="regSource" name="regSource" value="" type="hidden" />
159+
<div id="hd" class="input-field active">
160+
<label for="handle">Enter your handle</label>
161+
<input
162+
id="handle"
163+
name="handle"
164+
size="43"
165+
class="input-text"
166+
autocomplete="off"
167+
/>
102168
</div>
103-
<div id='cc'>
104-
<span>Select your country </span><select id="country" name="country"></select>
169+
<div id="cc" class="input-field active custom-dropdowm-arrow">
170+
<label for="country">Select your country </label>
171+
<select id="country" name="country" class="input-text"></select>
105172
</div>
106-
<div id='sb'>
107-
<input id='continueBtn' type="button" value="Continue" />
173+
<div id="sb" class="action-wrapper">
174+
<button
175+
type="submit"
176+
id="continueBtn"
177+
class="continue-btn"
178+
disabled="disabled"
179+
>
180+
Continue
181+
</button>
108182
</div>
109-
</form>
183+
</form>
184+
</main>
185+
</div>
186+
<footer class="footer">
187+
<div class="copyright-text">
188+
<strong>&copy;</strong> 2020 Topcoder. All Rights Reserved
189+
</div>
190+
<a
191+
class="privacy-policy"
192+
href="https://www.topcoder.com/privacy-policy/"
193+
>Privacy Policy</a
194+
>
195+
</footer>
110196
</div>
111-
</body>
112-
</html>
197+
</body>
198+
</html>

0 commit comments

Comments
 (0)