-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
113 lines (100 loc) · 3.98 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
109
110
111
112
113
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content ="IE=edge">
<metae name="viewport" content="width=device-width, initial-scale=1.0">
<title> YouTube->Spotify </title>
<link rel="stylesheet" href="style.css">
<link rel="stylesheet" href = "{{ url_for('static', filename='css/style.css')}}">
<!--
<link rel="stylesheet" href = "other.css">
-->
<script src="script.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="https://kit.fontawesome.com/96e88eed38.js" crossorigin="anonymous"></script>
<script src="https://unpkg.com/[email protected]/dist/typed.umd.js"></script>
</head>
<body>
<section>
<div class = "music">
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
<div class = "bar"></div>
</div>
<div class = "content">
<div class = "title">
<h1> Youtube -> Spotify </h1>
</div>
<div class = "info">
<p> Enter your playlist like below and see it automaitcally appear in your Spotify account!<p>
</div>
<form action = '/youtube_scrape' class="form__group field" method="post">
<input type="input" class="form__field" placeholder="Link" name="link" id="link" required />
<label for="link" class="form__label">Link</label>
</form>
<div class="loader-container">
<div class="animation">
<span></span>
<span></span>
<span></span>
<span></span>
<span></span>
</div>
</div>
</div>
</section>
<script>
document.addEventListener('DOMContentLoaded', function () {
const form = document.querySelector('.form__group');
const loaderContainer = document.querySelector('.loader-container');
const inputField = document.getElementById('link');
let isLoading = false;
form.addEventListener('submit', function(event) {
event.preventDefault(); // Prevent form submission
if (!isLoading) {
const input = inputField.value.trim();
if (input !== '') {
isLoading = true; // Set loading state to true
loaderContainer.classList.add('show-animation'); // Show loader animation
// Set the content type to JSON
const headers = new Headers();
headers.append('Content-Type', 'application/json');
// Prepare the request options
const requestOptions = {
method: 'POST',
headers: headers,
body: JSON.stringify({ link: input }) // Convert input to JSON format
};
// Make the fetch request
fetch('/youtube_scrape', requestOptions)
.then(response => response.json())
.then(data => {
// Handle response data if needed
console.log(data);
// After loading is done, reset the loading state and hide the loader
isLoading = false;
loaderContainer.classList.remove('show-animation');
})
.catch(error => {
console.error('Error:', error);
// Handle errors if needed
isLoading = false; // Reset loading state even if there's an error
loaderContainer.classList.remove('show-animation');
});
} else {
alert('Please provide a valid link');
}
}
});
});
</script>
</body>