summaryrefslogtreecommitdiff
path: root/dist/callback.html
blob: 002515cbb3705810f1ce168e00fbe28e1f8e007f (plain)
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
<!DOCTYPE html>
<html>
<body>
    <h1>Spotify Intersect</h1>
    <button onclick="load_songs()">Load songs to database</button>
    <script>
        function getParameterByName(name) {
            let 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 load_songs() {
            console.log("loading songs");
            let token = sessionStorage.getItem('token');
            fetch("https://kobert.dev/spotify-api/callback/" + token + "/" + getParameterByName("code")).then(console.log("finished loading songs!"));
            //window.location = "https://kobert.dev/spotify-api/token/" + token;
        }
    </script>
</body>
</html>