-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.js
51 lines (37 loc) · 1.47 KB
/
list.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
function startDisplay(snapshot) {
while (document.getElementById("myUL").firstChild) {
document.getElementById("myUL").removeChild(document.getElementById("myUL").firstChild);
}
snapshot.forEach((doc) => {
newElement(doc.data(), doc.id)
});
}
function addCloseTag() {
// var docRef = db.collection('UploadedFiles').doc(snapId);
var close = document.getElementsByClassName("close");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function () {
downloadInfo(this.parentElement.getAttribute('name'));
window.open(this.parentElement.title, "_blank");
db.collection('UploadedFiles').doc(this.parentElement.getAttribute('saveID')).update({
DownloadLimit: firebase.firestore.FieldValue.increment(-1)
});
}
}
}
function newElement(snapData, snapId) {
var li = document.createElement("li");
li.setAttribute('title', snapData.DownloadLink);
li.setAttribute('name', snapData.FileName);
li.setAttribute('saveID', snapId);
var t = document.createTextNode(snapData.FileName + ' By:- ' + snapData.UserName);
li.appendChild(t);
document.getElementById("myUL").appendChild(li);
var span = document.createElement("SPAN");
var txt = document.createTextNode("\u21E9");
span.className = "close";
span.appendChild(txt);
li.appendChild(span);
addCloseTag()
}