-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapprovid3.html
161 lines (142 loc) · 5.02 KB
/
approvid3.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://cdn.tailwindcss.com"></script>
<title>Approprite Technology Video Portal</title>
<style>
#newVideoButton {
display: none;
}
/* Modal styles */
.modal {
display: none;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 80%;
}
.close {
color: #aaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,
.close:focus {
color: black;
text-decoration: none;
cursor: pointer;
}
</style>
</head>
<body class="bg-gray-100">
<div class="container mx-auto p-4">
<h1 class="text-3xl font-bold mb-4">Video Portal</h1>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4" id="videoGrid">
</div>
<button
id="newVideoButton"
class="fixed bottom-4 right-4 bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded-full"
>
+
</button>
</div>
<div id="editModal" class="modal">
<div class="modal-content">
<span class="close">×</span>
<p>Edit video form will go here</p>
</div>
</div>
<script type="module">
import { createClient } from "https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm";
const supabaseUrl = "https://vlvbodwrtblttvwnxkjx.supabase.co";
const supabaseAnonKey ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZsdmJvZHdydGJsdHR2d254a2p4Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2ODY3NDk2NzIsImV4cCI6MjAwMjMyNTY3Mn0.TRT1HeX85vP1zDxnU7qBz5GqNPgYZUj-BOdek4qmtEg";
const supabase = createClient(supabaseUrl, supabaseAnonKey);
async function loadVideos() {
try {
const { data: videos, error } = await supabase
.from("Video")
.select("*");
if (error) {
console.error("Error loading videos:", error);
return;
}
const videoGrid = document.getElementById("videoGrid");
videoGrid.innerHTML = "";
videos.forEach((video) => {
const videoElement = `
<div class="bg-white rounded-lg shadow-md overflow-hidden">
<img src="${video.thumbnail_url}" alt="${video.title}" class="w-full">
<div class="p-4">
<h2 class="text-xl font-semibold mb-2">${video.title}</h2>
<p class="text-gray-600 text-sm">${video.description}</p>
<div class="flex justify-end mt-2">
<button class="text-blue-500 hover:text-blue-700 edit-button" data-video-id="${video.id}">Edit</button>
</div>
</div>
</div>
`;
videoGrid.innerHTML += videoElement;
});
// Add event listeners to edit buttons after they are created
const editButtons = document.querySelectorAll(".edit-button");
editButtons.forEach((button) => {
button.addEventListener("click", () => {
const videoId = button.dataset.videoId;
// Here you can fetch video data based on videoId and populate the modal
// For now, we'll just open the modal
openModal(videoId);
});
});
} catch (error) {
console.error("Error loading videos:", error);
}
}
// Modal functions
function openModal(videoId) {
console.log("Editing video:", videoId); // Log the video ID
const modal = document.getElementById("editModal");
modal.style.display = "block";
}
function closeModal() {
const modal = document.getElementById("editModal");
modal.style.display = "none";
}
// Close the modal when the close button is clicked
const closeButton = document.querySelector(".close");
closeButton.onclick = closeModal;
// Close the modal when the user clicks outside of the modal content
const modal = document.getElementById("editModal");
window.onclick = function (event) {
if (event.target == modal) {
closeModal();
}
};
// Function to toggle the new video button
function toggleNewVideoButton() {
const isLoggedIn = true; // Replace with your actual login check or fake it
const newVideoButton = document.getElementById("newVideoButton");
if (isLoggedIn) {
newVideoButton.style.display = "block";
} else {
newVideoButton.style.display = "none";
}
}
loadVideos();
toggleNewVideoButton();
</script>
</body>
</html>