Repository navigation
Expand file tree
/
Copy pathgithub-link.html
More file actions
74 lines (70 loc) · 2.71 KB
/
Copy pathgithub-link.html
File metadata and controls
74 lines (70 loc) · 2.71 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
<!DOCTYPE html>
<html lang="pt" dir="ltr">
<head>
<link rel="stylesheet" href="/css/index.css">
<link rel="stylesheet" href="/css/master.css">
<meta charset="utf-8">
<link rel="shortcut icon" href="assets/favicon.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<title>Marvin</title>
<script src="./helper.js" charset="utf-8"></script>
</head>
<body>
<main class="fullwidth">
<div class="login">
<h3>Parece que esse é seu primeiro acesso
<br>
ou sua conta do Github foi desvinculada.
<br>
<br>
<a href="#" onclick="openPDF()">Clique aqui para ver as instruções.</a>
</h3>
<form class="loginForm" hidden>
<input type="text" name="username" placeholder="usuário do Github" />
<br>
<button type="submit" class="full-green">continuar</button>
<br>
<br>
</form>
</div>
</main>
<a href="excel/home.html">Ir para excel</a>
<script type="text/javascript">
function openPDF() {
const pdf = window.open("https://app.projetomarvin.com/assets/pdf/Marvin+-+fase+00.pdf", '_blank');
$(".loginForm").show();
pdf.focus();
}
$('.loginForm').on('submit', function(e) {
e.preventDefault()
const usr = $('input[name=username]').val();
if (usr.includes("@")) {
$('input[name=username]').val("");
return alert("Ops, parece que você digitou seu email. Você precisa informar o seu USUÁRIO do github para continuar.")
}
$.ajax({
type: 'get',
url: url + 'students/' + localStorage.userId + '/checkRepository?username=' + usr + '&access_token=' + localStorage.access_token,
crossDomain: true,
success: function(responseData, textStatus, jqXHR) {
console.log(responseData);
if (responseData === "user not found") {
alert('Usuário não encontrado. Verifique o PDF e tente novamente.');
} else if (responseData === "repo not found") {
alert('Repositório "marvin" não encontrado no seu GitHub. Verifique o PDF e tente novamente.');
} else {
console.log(responseData);
localStorage.setItem('username', usr);
alert('Conta vinculada com sucesso e você conseguiu suas primeiras 42 moedas! Agora você deve vincular sua conta com o Github.')
window.location.href = 'https://github.com/login/oauth/authorize?client_id=ed378616412fc64a0ebc&scope=repo&login=' + usr;
}
},
error: function(responseData, textStatus, errorThrown) {
console.log(responseData);
alert('Algo deu errado, tente novamente.');
}
})
})
</script>
</body>
</html>