-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
118 lines (99 loc) · 3.58 KB
/
index.html
File metadata and controls
118 lines (99 loc) · 3.58 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
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
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.5.0/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.5.0/firebase-database.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.5.0/firebase-firestore.js"></script>
<link rel="stylesheet" href="css/normalize.css">
<link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Open+Sans'>
<link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.3/jquery.mCustomScrollbar.min.css'>
<link rel="stylesheet" href="css/style.css">
<!-- 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: "AIzaSyCIW4NPOTP6L2AZDJyZEkd9PkdNLLp8gbA",
authDomain: "inquid-chat.firebaseapp.com",
databaseURL: "https://inquid-chat-default-rtdb.firebaseio.com",
projectId: "inquid-chat",
storageBucket: "inquid-chat.appspot.com",
messagingSenderId: "771474336667",
appId: "1:771474336667:web:819d6a6fe187018f0a0f3e",
measurementId: "G-2SRNLJ8J2X"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
var db = firebase.firestore();
firebase.database().ref("messages").on("child_removed", function (snapshot) {
document.getElementById("message-" + snapshot.key).innerHTML = "This message has been deleted";
});
function deleteMessage(self) {
var messageId = self.getAttribute("data-id");
db.collection("messages").doc(messageId).delete().then(() => {
console.log("Document successfully deleted!");
}).catch((error) => {
console.error("Error removing document: ", error);
});
}
function sendMessage() {
var message = document.getElementById("message").value;
db.collection("messages").add({
message: message,
sender: myName
})
.then((docRef) => {
console.log("Document written with ID: ", docRef.id);
document.getElementById("message").value = "";
})
.catch((error) => {
console.error("Error adding document: ", error);
});
return false;
}
</script>
<style>
figure.avatar {
bottom: 0px !important;
}
.btn-delete {
background: red;
color: white;
border: none;
margin-left: 10px;
border-radius: 5px;
}
</style>
<div class="chat">
<div class="chat-title">
<h1>Chat Room</h1>
<h2>Firebase</h2>
<figure class="avatar">
<img src="https://p7.hiclipart.com/preview/349/273/275/livechat-online-chat-computer-icons-chat-room-web-chat-others.jpg" /></figure>
</div>
<div class="messages">
<div class="messages-content"></div>
</div>
<div class="message-box">
<textarea type="text" class="message-input" id="message" placeholder="Type message..."></textarea>
<button type="submit" class="message-submit">Send</button>
</div>
</div>
<div class="bg"></div>
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/malihu-custom-scrollbar-plugin/3.1.3/jquery.mCustomScrollbar.concat.min.js'></script>
<script src="js/index.js"></script>
<style>
.fixed-bottom {
position: fixed;
left: 0;
bottom: 0;
width: 100%;
background-color: lightseagreen;
color: white;
text-align: center;
padding: 25px;
font-size: 20px;
}
</style>
<div class="footer fixed-bottom">
Inquid
</div>