-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstagrameffect_page.html
119 lines (97 loc) · 4.46 KB
/
instagrameffect_page.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="/assets/profilicon.png"/>
<title>Instagram Effect </title>
<link rel="stylesheet" href="style.css">
</head>
<body >
<div id="idData">
<div id="titleApp" class="headerapp">Instagram Effect</div>
</div>
<div id="loading" class="loading hidden">Loading...</div>
<!-- <script src="script.js"></script> -->
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-app.js";
import { getFirestore, collection, getDocs } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-firestore.js";
import { getStorage, ref, getDownloadURL } from "https://www.gstatic.com/firebasejs/10.12.2/firebase-storage.js";
const firebaseConfig = {
apiKey: "AIzaSyCE_9p8CoPJ65wabhH-ZWdAZ4DHx75G09M",
authDomain: "porto-gallery.firebaseapp.com",
projectId: "porto-gallery",
storageBucket: "porto-gallery.appspot.com",
messagingSenderId: "37204390245",
appId: "1:37204390245:web:cfc26e30da3a2256e0b18c"
};
const app = initializeApp(firebaseConfig);
const db = getFirestore();
const storage = getStorage();
let idData = document.getElementById("idData");
let loading = document.getElementById("loading");
function getStudent() {
const studentsRef = collection(db, "portofolio");
getDocs(studentsRef)
.then((querySnapshot) => {
const filteredDocs = querySnapshot.docs.filter(
(doc) => doc.data().platform === "instagram"
);
filteredDocs.forEach((doc) => {
AddStudentAsListItem(doc);
});
loadingElement.classList.add("hidden");
titleAppElement.classList.add("visible");
idData.classList.add("visible");
})
.catch((error) => {
console.error("Error getting documents: ", error);
});
}
const loadingElement = document.getElementById("loading");
loadingElement.classList.remove("hidden");
const titleAppElement = document.getElementById("titleApp");
titleAppElement.classList.remove("visible");
const idDataElement = document.getElementById("idData");
idDataElement.classList.remove("visible");
async function getImageUrl(coverUrl) {
try {
const imageUrl = await getDownloadURL(ref(storage, `covers/${coverUrl}`));
return imageUrl;
} catch (error) {
console.error("Error getting image URL:", error);
return null;
}
}
function AddStudentAsListItem(doc) {
let data = doc.data();
let videoContainer = document.createElement("div");
videoContainer.classList.add("video-container");
let videoElement = document.createElement("video");
videoElement.src = data.fileUrl; // Set the fileUrl as the src of the video element
videoElement.controls = true;
videoElement.setAttribute("playsinline", ""); // Ensure video plays inline
if (data.coverUrl) {
getImageUrl(data.coverUrl).then((imageUrl) => {
videoElement.poster = imageUrl; // Set the fetched image URL as the poster of the video element
}).catch((error) => {
console.warn("Error fetching image URL:", error);
});
} else {
console.warn("No coverUrl found for document:", doc.id);
}
let videoTitle = document.createElement("h2");
videoTitle.innerText = data.judul;
let videoDescription = document.createElement("p");
videoDescription.innerText = data.deskripsi;
let textContainer = document.createElement("div");
textContainer.classList.add("text-container");
textContainer.append(videoTitle, videoDescription);
videoContainer.append(videoElement);
videoContainer.append(textContainer);
idData.append(videoContainer);
}
window.addEventListener("load", getStudent);
</script>
</body>
</html>