-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
31 lines (30 loc) · 1.4 KB
/
script.js
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
document.addEventListener('DOMContentLoaded', () => {
axios.get('/videos')
.then(response => {
const videos = response.data;
videos.forEach(video => {
axios.get(`/summary/${video.video_id}`)
.then(summaryResponse => {
const { summary, thumbnail_url } = summaryResponse.data;
const videoCard = document.createElement('div');
videoCard.classList.add('video-card');
videoCard.innerHTML = `
<img src="${thumbnail_url}" alt="${video.video_title}">
<h2>${video.video_title}</h2>
<p>${summary}</p>
`;
document.getElementById('video-container').appendChild(videoCard);
})
.catch(error => console.error('Error fetching summary:', error));
});
})
.catch(error => console.error('Error fetching videos:', error));
// Swipe functionality using Hammer.js
const videoContainer = document.getElementById('video-container');
const hammer = new Hammer(videoContainer);
hammer.get('swipe').set({ direction: Hammer.DIRECTION_VERTICAL });
hammer.on('swipeup swipedown', function(ev) {
// Handle swipe gestures as needed
console.log(ev);
});
});