summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kobert <dennis@kobert.dev>2020-02-22 20:04:01 +0100
committerDennis Kobert <dennis@kobert.dev>2020-02-22 20:04:01 +0100
commita09c4a1304d2697231aacf520357c6f21dfb9784 (patch)
tree7ce9b8da2ba0829de0850470b2dfe4fc5f697476
parente6436d20ea0b2ae7799b588e4df1f4e120c2c53c (diff)
Unify button and callback.html
-rw-r--r--dist/callback.html14
1 files changed, 13 insertions, 1 deletions
diff --git a/dist/callback.html b/dist/callback.html
index 8f46292..ec2e584 100644
--- a/dist/callback.html
+++ b/dist/callback.html
@@ -61,7 +61,8 @@ body {
</div>
<div class="main">
<h1>Spotify Intersect</h1>
- <button id="Load_button" onclick="load_songs()">Load songs to database</button>
+ <button id="Connect_button" onclick="connect_button()">Connect to Spotify</button>
+ <button id="Load_button" onclick="load_songs()" disabled=true>Load songs to database</button>
<p id="status"></p>
<input type="text" id="name1" value="First name">
<input type="text" id="name2" value="Second name">
@@ -80,6 +81,13 @@ body {
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
+ function connect_button() {
+ //http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
+ let token = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
+ sessionStorage.setItem('token', token);
+ document.getElementById("Connect_button").disabled = true;
+ window.location = "https://kobert.dev/spotify-api/token/" + token;
+ }
function load_songs() {
console.log("loading songs");
@@ -112,6 +120,10 @@ function match_users() {
});
}
function populate_users() {
+ if (getParameterByName("code") != null) {
+ document.getElementById("Connect_button").disabled = true;
+ document.getElementById("Load_button").disabled = false;
+ }
fetch("https://kobert.dev/spotify-api/user")
.then(function(response) {
if (!response.ok) {