summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
Diffstat (limited to 'dist')
-rw-r--r--dist/callback.html26
1 files changed, 22 insertions, 4 deletions
diff --git a/dist/callback.html b/dist/callback.html
index 2cc891c..7bda9f3 100644
--- a/dist/callback.html
+++ b/dist/callback.html
@@ -2,8 +2,12 @@
<html>
<body>
<h1>Spotify Intersect</h1>
- <button onclick="load_songs()">Load songs to database</button>
- <p id="p1"></p>
+ <button id="Load_button" onclick="load_songs()">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">
+ <button id="Match_button" onclick="match_users()">Match users</button>
+ <p id="output"></p>
<script>
function getParameterByName(name) {
let url = window.location.href;
@@ -18,17 +22,31 @@
function load_songs() {
console.log("loading songs");
document.getElementById("p1").innerHTML = "Loading songs";
+ document.getElementById("Load_button").disabled = true;
let token = sessionStorage.getItem('token');
fetch("https://kobert.dev/spotify-api/callback/" + token + "/" + getParameterByName("code"))
.then(function(response) {
if (!response.ok) {
- document.getElementById("p1").innerHTML = "Error occured while loading songs: ${response.status}";
+ document.getElementById("status").innerHTML = "Error occured while loading songs: ${response.status}";
throw new Error(`HTTP error! status: ${response.status}`);
}
- document.getElementById("p1").innerHTML = "Loaded songs";
+ document.getElementById("status").innerHTML = "Loaded songs";
});
//window.location = "https://kobert.dev/spotify-api/token/" + token;
}
+function match_users() {
+ let name1 = document.getElementById("name1").value;
+ let name2 = document.getElementById("name2").value;
+
+ fetch("https://kobert.dev/spotify-api/match/" + name1 + "/" + name2)
+ .then(function(response) {
+ if (!response.ok) {
+ document.getElementById("status").innerHTML = "Error occured while loading songs: ${response.status}";
+ throw new Error(`HTTP error! status: ${response.status}`);
+ }
+ document.getElementById("output").innerHTML = response.body;
+ });
+}
</script>
</body>
</html>