forked from Adi142857/World-chat-app
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
80 lines (63 loc) · 2.42 KB
/
script.js
File metadata and controls
80 lines (63 loc) · 2.42 KB
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
window.onload = function(){
//x();
{
document.body.onclick=(e)=>{
let x= e.clientX
let y= e.clientY
let ripple= document.createElement("span")
ripple.className="ripple"
ripple.style.left=x-75+"px"
ripple.style.top=y-75+"px"
document.body.appendChild(ripple)
setTimeout(()=>{
ripple.remove()
},500)}}
const config = {
apiKey: "AIzaSyAjYvGo-i9tPUJebCvfCHRKZZ5mhkGh0oU",
authDomain: "hello-4ee02.firebaseapp.com",
projectId: "hello-4ee02",
storageBucket: "hello-4ee02.appspot.com",
messagingSenderId: "404320860501",
appId: "1:404320860501:web:7833523d305c643eeb57dc"
};
// Initialize Firebase
// inteliging firebase
firebase.initializeApp(config);
var db=firebase.firestore();
db.settings({timestampsInSnapshots: true});
// reciving data from fire base
function tp(){
db.collection('Details').orderBy("Sn").get().then(l);
}
//setInterval(tp,1000);
tp();
function l(snap){
var a = 1;
document.getElementById("dv").innerHTML = "";
// getting catogrical data by for loop
for(pg in snap.docs){
/*data deleting
var Id = snap.docs[pg].id;
db.collection("Details").doc(Id).delete();
//*/
var name = snap.docs[pg].data().Name;
var num = snap.docs[pg].data().Number;
var numb = snap.docs[pg].data()["Your_msg"];
var ht = "<div id='mn'><div id='nm'>"+a+". "+name+"</div><div id='nb'>"+num+"</div><div id='nb'>"+numb+"</div></div>";
dv.insertAdjacentHTML("afterbegin",ht);
a++; document.getElementById("count").innerHTML=a;
}
}
// sending data to datatabase
var bn = document.getElementById("myBtn");
bn.addEventListener("click", function(){
var in1 = document.getElementById("inp1").value;
var in2 = document.getElementById("inp2").value;
var in3 = document.getElementById("inp3").value;
var a=document.getElementById("count").innerHTML;
var datatasend= {Name:in1,Number:in2,Your_msg:in3,Sn:a}
db.collection('Details').add(datatasend);
document.getElementById("inp3").value="";
tp();
});
}