-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
47 lines (43 loc) · 1.29 KB
/
app.js
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
var success = false;
document.addEventListener('DOMContentLoaded', () => {
document.getElementById('start_button').addEventListener('click', function (e) {
fetch('/spotifyRedirectUri')
.then(e => e.json())
.then(data => {
var x = document.getElementById("grid");
var xList = document.querySelectorAll("input[type='checkbox']");
var checkedNum = 0;
xList.forEach(el => {
if (el.checked) {
checkedNum++;
}
});
if (checkedNum == 0) {
alert("Please first select your choices.");
} else if (checkedNum > 5) {
alert("Please only select five (5) choices.");
} else if (success) {
window.location = '/login.html';
} else if (!success) {
success = true;
window.location = data.redirectUri;
}
})
.catch(error => { alert("Failed to prepare for Spotify Authentication")});
});
});
function btnActivate() {
var x = document.getElementById("grid");
var xList = document.querySelectorAll("input[type='checkbox']");
var checkedNum = 0;
xList.forEach(el => {
if (el.checked) {
checkedNum++;
}
});
if (checkedNum == 0) {
alert("Please first select your choices.");
} else if (checkedNum > 5) {
alert("Please only select five (5) choices.");
}
}