-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
68 lines (59 loc) · 1.98 KB
/
main.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
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
var images = [
{
title:"Image 1",
link:'images/AdAddnAddy.jpg'
},
{
title:"Image 2",
link:'images/gaming.jpg'
},
{
title:"Image 3",
link:'images/CodeALine.jpg'
},
{
title:"Image 3",
link:'images/Crossword.jpg'
}
]
window.onload = function(){
var fileSelector = document.getElementById('fileSelector');
var galleryContainer = document.getElementById("galleryContainer");
var galleryItems;
var items = "";
for(var i=0;i<images.length;i++){
items = items + `<div class="galleryItem" onClick="openImage(`+ i +`)">
<div class="overlay">
<h2 id="title">`+ images[i].title +`</h2>
</div>
</div>`;
}
galleryContainer.innerHTML = items;
for(var i=0;i<images.length;i++){
console.log(galleryContainer.children[i]);
galleryContainer.children[i].style.backgroundImage = "url("+images[i].link+")";
}
var openContainer = document.getElementById("openContainer");
var closeButton = document.getElementById("closeButton");
var image = document.getElementById("image");
var imageTitle = document.getElementById("imageTitle");
}
fileSelector.addEventListener("change",function(input){
var storageRef = firebase.storage().ref();
console.log(fileSelector.files);
for (var i = 0; i < fileSelector.files.length; i++) {
storageRef.child(fileSelector.files[i].name).put(fileSelector.files[i]).then(function(snapshot) {
console.log('Uploaded a blob or file!');
});
}
})
function openImage(imageNumber){
openContainer.style.marginLeft = "0";
imageTitle.innerHTML = images[imageNumber].title;
image.setAttribute("src",images[imageNumber].link);
};
function closeImage(){
imageTitle.innerHTML = "";
openContainer.style.marginLeft = "100%";
image.setAttribute("src","");
};