-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
108 lines (93 loc) · 4.92 KB
/
index.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
<!doctype html>
<html lang="en" class="h-100">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Righteous&display=swap" rel="stylesheet">
<link rel="apple-touch-icon" sizes="180x180" href="/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/icons/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<title>Login to Spotify Data</title>
</head>
<body class="h-100" style="overflow: hidden; background-color: black">
<nav class="navbar navbar-expand-sm sticky-top navbar-light" style="background-color: #1DB954;">
<!--<a class="navbar-brand" href="https://spotifydata.com">Spotify Data</a>-->
</nav>
<div class="container h-100">
<div class="row justify-content-center align-items-center h-100">
<div class="col">
<h1 class="text-success text-center display-1" style="font-family: 'Righteous', cursive;">Spotify Data</h1>
<h5 class="text-light text-center">See all of the stats on your favorite songs!</h5>
<div class=" mt-4 text-center">
<a class="btn btn-primary text-white" id="login-button">Log in with Spotify</a>
</div>
</div>
</div>
<script>
(function() {
console.log(localStorage.getItem("logged out"));
var stateKey = 'spotify_auth_state';
var total = '';
function loadRequest(url) {
var xhttp;
xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
total = JSON.parse(this.responseText).total;
}
};
xhttp.ontimeout = function(e) {
console.log("Request timed out: " + url);
}
xhttp.open("GET", url, true);
//xhttp.setRequestHeader("Authorization", "Bearer " + oauth_id);
xhttp.timeout = 10000;
xhttp.send();
}
loadRequest("https://1ogie351wf.execute-api.us-west-2.amazonaws.com/dev/ClickHandler?add=1")
function generateRandomString(length) {
var text = '';
var possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (var i = 0; i < length; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
};
function callback(req) {
//let total = JSON.parse(req.responseText).total;
var client_id = 'fff2634975884bf88e3d3c9c2d77763d'; // Your client id
var redirect_uri = 'https://spotifydata.com/songdata'; // Your redirect uri
//var redirect_uri = 'http://localhost:8888/songdata.html'; // Your redirect uri
var state = generateRandomString(16);
sessionStorage.setItem(stateKey, state + total);
var scope = 'user-read-private user-read-email user-follow-read user-follow-modify user-read-private user-read-email streaming user-read-currently-playing user-read-recently-played user-modify-playback-state user-library-modify user-library-read user-top-read user-modify-private';
var url = 'https://accounts.spotify.com/authorize';
url += '?response_type=token';
url += '&client_id=' + encodeURIComponent(client_id);
url += '&scope=' + encodeURIComponent(scope);
url += '&redirect_uri=' + encodeURIComponent(redirect_uri);
url += '&state=' + encodeURIComponent(state) + total;
if (localStorage.getItem("logged out") == "true") {
url += '&show_dialog=true';
localStorage.setItem("logged out", "false")
}
window.location = url;
}
document.getElementById('login-button').addEventListener('click', function() {
callback()
}, false);
})();
</script>
<script>
var clicky_site_ids = clicky_site_ids || [];
clicky_site_ids.push(101276743);
</script>
<script async src="//static.getclicky.com/js"></script>
<noscript>
<p><img alt="Clicky" width="1" height="1" src="//in.getclicky.com/101276743ns.gif" /></p>
</noscript>
</body>
</html>