-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
192 lines (153 loc) · 5.43 KB
/
index.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<title>Document</title>
<style>
@font-face {
font-family: 'Billabong';
src: url('billabong.ttf');
}
ul#images {
list-style:none;
margin:0;
padding:0;
}
ul#images img {
width: 614px;
border: 1px solid #e6e6e6;
margin-bottom:60px;
}
.title {
font-family: "Billabong";
font-size:60px;
}
.grey-box {
border: 1px solid #e6e6e6;
width:100%;
padding-left:16px;
padding-top:12px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-12"><span class='title'>LaterGram</span></div>
</div>
<div class="row">
<div class="col-12">
<div id="desc">
<textarea placeholder='Enter description here...' name="description" id="description" cols="100" rows="2"></textarea>
</div>
<div id="filesubmit">
<label for="">Upload photo</label>
<input type="file" class="file-select" accept="image/*"/>
<button class="btn btn-info file-submit">SUBMIT</button>
</div>
</div> <!-- end of row -->
</div>
<div style='height:50px;'>
</div>
<div class="row">
<div class="col-7">
<div id='app'>
<ul id='images'>
<li v-for="image in images">
<img v-bind:src="image" />
</li>
</ul>
</div>
</div> <!-- end of col-8 -->
<div class='col-4'>
<div style='height:250px;' class='grey-box'>
<div style='color:#999;font-size:14px;'>Stories</div>
</div>
<div style='height:400px;margin-top:20px;' class='grey-box'>
<div style='color:#999;font-size:14px;'>Suggestion for you</div>
</div>
</div>
</div>
</div>
</body>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- development version, includes helpful console warnings -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/6.2.3/firebase-storage.js"></script>
<!-- TODO: Add SDKs for Firebase products that you want to use
https://firebase.google.com/docs/web/setup#config-web-app -->
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyACBE1dRf5atbKcdJXDeBhUvv7o2Ss0s8c",
authDomain: "instademo-db1d0.firebaseapp.com",
databaseURL: "https://instademo-db1d0.firebaseio.com",
projectId: "instademo-db1d0",
storageBucket: "instademo-db1d0.appspot.com",
messagingSenderId: "1019223418110",
appId: "1:1019223418110:web:7bc1c4ea22ac2242"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
</script>
<script>
const storageService = firebase.storage();
const storageRef = storageService.ref();
document.querySelector('.file-select').addEventListener('change', handleFileUploadChange);
document.querySelector('.file-submit').addEventListener('click', handleFileUploadSubmit);
let selectedFile;
function handleFileUploadChange(e) {
selectedFile = e.target.files[0];
}
function handleFileUploadSubmit(e) {
var description = document.querySelector('#description').value
var metadata = {
customMetadata: {
'description': description
}
}
const uploadTask = storageRef.child(`images/${selectedFile.name}`).put(selectedFile, metadata); //create a child directory called images, and place the file inside this directory
uploadTask.on('state_changed', (snapshot) => {
// Observe state change events such as progress, pause, and resume
}, (error) => {
// Handle unsuccessful uploads
console.log(error);
}, () => {
// Do something once upload is complete
console.info('image uploaded successfully');
});
}
</script>
<script>
var app = new Vue({
el: '#app',
data: {
images:[],
currentImages:[]
}
})
</script>
<script>
// Create a reference under which you want to list
var listRef = storageRef.child('images/');
// Find all the prefixes and items.
listRef.listAll().then(function(res) {
console.log('res:', res);
res.items.forEach(function(itemRef) {
console.log(itemRef.location);
itemRef.getDownloadURL().then(function(url){
app.$data.images.push(url);
});
});
}).catch(function(error) {
// Uh-oh, an error occurred!
});
</script>
</html>