-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup.html
59 lines (51 loc) · 2.35 KB
/
signup.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
<html>
<head>
<title>Sign up — maker.rocks</title>
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" href="img/emoji.png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body class="auth signup">
<header>
<h1 class="logo"><a href="/"><img src="img/emoji.png" alt=""> <span class="logo-text">maker.rocks</span></a></h1>
</header>
<section class="hero">
<form action="javascript:void(0)" onsubmit="submitForm()">
<h1>Sign up</h1>
<label class="error"></label>
<label><input name="email" type="email" placeholder="cool.maker@example.com" required></label>
<label>maker.rocks/ <input name="username" type="text" placeholder="username" required></label>
<label class="explainer">You will be emailed a login code.</label>
<button type="submit" class="btn">Claim my page!</button>
</form>
</section>
</body>
</html>
<script>
function submitForm() {
document.querySelector('button[type="submit"]').innerHTML = 'Processing...';
fetch('https://functions.maker.rocks/signup', {method: 'POST', body: JSON.stringify({
email: document.querySelector('input[name="email"]').value,
username: document.querySelector('input[name="username"]').value
})}).then(r => r.json()).then(res => {
document.querySelector('button[type="submit"]').innerHTML = 'Claim my page!';
var errorElem = document.querySelector('label.error');
if(res.code === 'USER_WITH_EMAIL_EXISTS') {
errorElem.innerHTML = 'This email address is already in use.';
} else if(res.code === 'USER_WITH_USERNAME_EXISTS') {
errorElem.innerHTML = 'This username is already in use.';
} else {
errorElem.innerHTML = '';
window.location = '/login-code-sent';
}
});
}
</script>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-103555680-7"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-103555680-7');
</script>