Ivan000 commited on
Commit
a1e2ea5
·
verified ·
1 Parent(s): 9e075db

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +4 -116
templates/index.html CHANGED
@@ -77,93 +77,6 @@
77
  </div>
78
 
79
  <script>
80
- const Toast = Swal.mixin({
81
- toast: true,
82
- position: 'top-end',
83
- showConfirmButton: false,
84
- timer: 3000,
85
- timerProgressBar: true,
86
- didOpen: (toast) => {
87
- toast.addEventListener('mouseenter', Swal.stopTimer)
88
- toast.addEventListener('mouseleave', Swal.resumeTimer)
89
- }
90
- });
91
-
92
- function showLoading(message) {
93
- return Swal.fire({
94
- html: `
95
- <div class="space-y-3">
96
- <div class="w-16 h-16 mx-auto border-4 border-gray-200 border-t-blue-500 rounded-full animate-spin"></div>
97
- <div class="text-gray-600 text-sm">${message}</div>
98
- </div>
99
- `,
100
- showConfirmButton: false,
101
- allowOutsideClick: false,
102
- background: '#ffffff',
103
- customClass: {
104
- popup: 'rounded-2xl'
105
- }
106
- });
107
- }
108
-
109
- function showSuccess(message) {
110
- Toast.fire({
111
- icon: 'success',
112
- title: message,
113
- background: '#F0FDF4',
114
- iconColor: '#22C55E'
115
- });
116
- }
117
-
118
- function showError(message) {
119
- Toast.fire({
120
- icon: 'error',
121
- title: message,
122
- background: '#FEF2F2',
123
- iconColor: '#EF4444'
124
- });
125
- }
126
-
127
- function formatDuration(seconds) {
128
- const minutes = Math.floor(seconds / 60);
129
- const remainingSeconds = seconds % 60;
130
- return `${minutes}:${remainingSeconds.toString().padStart(2, '0')}`;
131
- }
132
-
133
- function getVideoInfo() {
134
- const url = $('#youtubeUrl').val().trim();
135
- if (!url) {
136
- showError('Please enter a YouTube URL');
137
- return;
138
- }
139
-
140
- showLoading('Fetching video information...');
141
- $('#videoInfo').addClass('hidden');
142
-
143
- $.ajax({
144
- url: '/get-info',
145
- type: 'POST',
146
- contentType: 'application/json',
147
- data: JSON.stringify({ url: url }),
148
- success: function(response) {
149
- $('#thumbnailContainer').html(`
150
- <img src="${response.thumbnail}" alt="Video thumbnail"
151
- class="w-full object-cover transition-transform duration-300 hover:scale-105">
152
- `);
153
- $('#videoTitle').text(response.title);
154
- $('#channelName span').text(response.channel);
155
- $('#duration span').text(formatDuration(response.duration));
156
- $('#videoInfo').removeClass('hidden');
157
- Swal.close();
158
- showSuccess('Video information retrieved');
159
- },
160
- error: function(xhr) {
161
- Swal.close();
162
- showError(xhr.responseJSON?.error || 'Failed to get video information');
163
- }
164
- });
165
- }
166
-
167
  function playAudio() {
168
  const url = $('#youtubeUrl').val().trim();
169
  if (!url) {
@@ -184,24 +97,15 @@
184
  success: function(response) {
185
  const blob = new Blob([response], { type: 'audio/mp3' });
186
  const audioUrl = URL.createObjectURL(blob);
187
-
188
  const videoInfoContainer = document.querySelector('#videoInfo .p-6');
189
- // Remove any existing audio players
190
  const existingAudioPlayers = videoInfoContainer.querySelectorAll('audio');
191
  existingAudioPlayers.forEach(player => player.remove());
192
-
193
  const audioPlayer = document.createElement('audio');
194
  audioPlayer.src = audioUrl;
195
  audioPlayer.controls = true;
196
- audioPlayer.style.width = '100%';
197
- audioPlayer.style.marginTop = '1rem';
198
- audioPlayer.style.backgroundColor = 'rgba(255, 255, 255, 0.1)';
199
- audioPlayer.style.borderRadius = '8px';
200
- audioPlayer.style.padding = '1rem';
201
- audioPlayer.style.color = 'white';
202
- audioPlayer.style.border = '1px solid rgba(255, 255, 255, 0.2)';
203
-
204
- // Autoplay
205
  audioPlayer.autoplay = true;
206
 
207
  videoInfoContainer.appendChild(audioPlayer);
@@ -215,22 +119,6 @@
215
  }
216
  });
217
  }
218
-
219
- // Smooth page load animation
220
- document.addEventListener('DOMContentLoaded', () => {
221
- requestAnimationFrame(() => {
222
- document.body.style.opacity = '0';
223
- requestAnimationFrame(() => {
224
- document.body.style.transition = 'opacity 0.5s ease-in';
225
- document.body.style.opacity = '1';
226
- });
227
- });
228
- });
229
-
230
- // Check system dark mode preference
231
- if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
232
- document.documentElement.classList.add('dark');
233
- }
234
  </script>
235
  </body>
236
- </html>
 
77
  </div>
78
 
79
  <script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  function playAudio() {
81
  const url = $('#youtubeUrl').val().trim();
82
  if (!url) {
 
97
  success: function(response) {
98
  const blob = new Blob([response], { type: 'audio/mp3' });
99
  const audioUrl = URL.createObjectURL(blob);
100
+
101
  const videoInfoContainer = document.querySelector('#videoInfo .p-6');
 
102
  const existingAudioPlayers = videoInfoContainer.querySelectorAll('audio');
103
  existingAudioPlayers.forEach(player => player.remove());
104
+
105
  const audioPlayer = document.createElement('audio');
106
  audioPlayer.src = audioUrl;
107
  audioPlayer.controls = true;
108
+
 
 
 
 
 
 
 
 
109
  audioPlayer.autoplay = true;
110
 
111
  videoInfoContainer.appendChild(audioPlayer);
 
119
  }
120
  });
121
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  </script>
123
  </body>
124
+ </html>