forked from xriley/DevConf-Theme
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mentoring.html
200 lines (181 loc) · 9.4 KB
/
mentoring.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
---
permalink: /mentee/
---
<!doctype html>
<html lang="pl">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<title>Azure Community Mentoring Program 2020</title>
<meta name="theme-color" content="#563d7c">
<style>
.bd-placeholder-img {
font-size: 1.125rem;
text-anchor: middle;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
@media (min-width: 768px) {
.bd-placeholder-img-lg {
font-size: 3.5rem;
}
}
</style>
<script>
function get() {
var code = getParameterByName('code');
if (code != null) {
var code = fetch('https://mentoring-func.azurewebsites.net/api/read?code=' + code).then(handleErrorsRead)
.then(response => response.json())
.then((body) => {
for (var i in body) {
document.getElementById("zgloszenia").innerHTML += '<div id="' + body[i].Id + '" class="jumbotron mt-3"></div>'
for (var key in body[i]) {
if ((body[i].hasOwnProperty(key) && key == "Id")) {
document.getElementById('form').innerHTML += '<div class="form-group form-check"><input class="form-check-input" type="checkbox" value="' + body[i][key] + '" id="cb' + body[i][key] + '"><label class="form-check-label" for="cd' + body[i][key] + '"><a href="#' + body[i][key] + '">Zgłoszenie ' + body[i][key] + '</a></label></div>'
document.getElementById(body[i].Id).innerHTML += '<h4><a id="' + body[i][key] + '" href="#' + body[i][key] + '">Zgłoszenie ' + body[i][key] + '</a></h4>'
}
if ((body[i].hasOwnProperty(key)) && key != "Id") {
document.getElementById(body[i].Id).innerHTML += '<h4>' + key + '</h4><p>' + body[i][key] + '</p>'
}
}
document.getElementById(body[i].Id).innerHTML += '<button type="button" class="btn btn-primary" onclick="check(' + body[i].Id + ')">Wybieram kandydata</button>'
}
document.getElementById('form').innerHTML += '<button type="button" class="btn btn-primary" onclick="send()">Wyślij wybrane zgłoszenia</button>'
try { document.getElementById('spinner').remove(); } catch { }
})
.catch(error => showError(error));
} else {
notAuthorized();
}
}
function handleErrorsRead(response) {
if (!response.ok) {
if (response.status == '401') {
notAuthorized();
throw Error();
} else if (response.status == '403') {
document.getElementById('spinner').remove();
document.getElementById('zgloszenia').innerHTML = '<div class="alert alert-warning" role="alert">Wybrałeś już podopiecznego. Niedługo powinieneś dostać mail z danymi kontaktowymi. Jeśli tak się nie stało skontaktuj się z <a href="mailto:[email protected]">organizatorami</a></div>'
throw Error();
}
else {
throw Error(response.statusText);
}
}
return response;
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, '\\$&');
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, ' '));
}
function notAuthorized() {
try { document.getElementById('spinner').remove(); } catch { }
document.getElementById('zgloszenia').innerHTML = '<div class="alert alert-danger" role="alert">Użyj właściwego linku albo skontaktuj się z <a href="mailto:[email protected]">organizatorami</a></div>'
}
function showError(error) {
try { document.getElementById('spinner').remove(); } catch{ }
console.dir(error);
if (error != "Error") {
document.getElementById('zgloszenia').innerHTML = '<div class="alert alert-danger" role="alert">' + error + '</div>'
}
}
function showOk(ok) {
try { document.getElementById('spinner').remove(); } catch{ }
document.getElementById('zgloszenia').innerHTML = '<div class="alert alert-success" role="alert">' + ok + '</div>'
}
function check(id) {
if (confirm("Czy na pewno wybierasz tą kandydaturę?")) {
document.getElementById('cb' + id).checked = true;
$(document).ready(function () {
$(window).scrollTop(0);
});
} else {
}
}
function send() {
var checkboxes = document.getElementsByClassName('form-check-input')
selected = [];
for (var checkbox of checkboxes) {
if (checkbox.checked)
selected.push(checkbox.value);
}
if (selected.length > 0) {
if (confirm("Czy na pewno wysłać?")) {
console.log(selected);
var code = getParameterByName('code');
if (code != null) {
var code = fetch('https://mentoring-func.azurewebsites.net/api/send?code=' + code, { method: "POST", body: JSON.stringify(selected) })
.then(response => {
if (response.status == 200) {
showOk('Przyjęliśmy zgłoszenie od Ciebie! Niedługo prześlemy dane kandydata/kandydatów. Jeśli coś chcesz zmienić skontaktuj się z <a href="mailto:[email protected]">organizatorami</a>');
} else if (response.status == 403) {
showError('Już mamy od Ciebie wybrane zgłoszenia! Jeśli coś chcesz zmienić skontaktuj się z <a href="mailto:[email protected]">organizatorami</a>');
} else {
showError(response.statusText);
}
}).catch(error => showError(error));
} else {
notAuthorized();
}
}
} else {
alert("Wybierz przynajmniej jedno zgłoszenie")
}
}
</script>
<!-- Google Tag Manager -->
<script>(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', 'GTM-KWCRNJT');</script>
<!-- End Google Tag Manager -->
</head>
<body onload="get()">
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-KWCRNJT" height="0" width="0"
style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
<div class="container">
<div class="jumbotron mt-3">
<h1>Azure Community Mentoring Program 2020</h1>
<p class="lead">Wybierz z listy swojego podopiecznego!</p>
<form id="form">
</form>
</div>
<div class="d-flex justify-content-center" id="spinner">
<div class="spinner-border m-5" role="status" style="width: 4rem; height: 4rem;">
<span class="sr-only">Loading...</span>
</div>
</div>
<section id="zgloszenia">
</section>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js"
integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n"
crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"
integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"
integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6"
crossorigin="anonymous"></script>
</body>
</html>