-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
153 lines (143 loc) · 5.27 KB
/
index.html
File metadata and controls
153 lines (143 loc) · 5.27 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Matrix</title>
<script type="module">
// Import the functions you need from the SDKs you need
import { initializeApp } from "https://www.gstatic.com/firebasejs/11.5.0/firebase-app.js";
import { getAnalytics } from "https://www.gstatic.com/firebasejs/11.5.0/firebase-analytics.js";
import { getDatabase, ref, push, set, onChildAdded } from "https://www.gstatic.com/firebasejs/11.5.0/firebase-database.js";
// Your web app's Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyBGepN0JCQqPhySfxSUhsXPGoAKjgNbtHc",
authDomain: "neo9-c8021.firebaseapp.com",
projectId: "neo9-c8021",
storageBucket: "neo9-c8021.appspot.com",
messagingSenderId: "1093870223636",
appId: "1:1093870223636:web:0c6fd96045f609c02c8201",
measurementId: "G-0RP5GMBV81"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const database = getDatabase(app);
const chatDiv = document.getElementById('chat');
const messageInput = document.getElementById('message');
const sendButton = document.getElementById('send');
const usernameInput = document.getElementById('username');
// Sound effect for typing
const typingSound = new Audio('https://www.soundjay.com/button/beep-07.mp3'); // Replace with your sound file
// Function to send a message
const sendMessage = () => {
const message = messageInput.value;
const username = usernameInput.value || "Anonymous";
if (message) {
// Check if the message is "cls confirm"
if (message.trim().toLowerCase() === "cls confirm") {
// Clear the chat window
chatDiv.innerHTML = '';
messageInput.value = '';
return; // Exit the function
}
// Send the message to Firebase
set(push(ref(database, 'messages')), {
username: username,
message: message
}).catch((error) => {
console.error("Error sending message: ", error);
});
messageInput.value = '';
typingSound.play(); // Play sound on send
}
};
// Send message on button click
sendButton.addEventListener('click', sendMessage);
// Send message on Enter key press
messageInput.addEventListener('keypress', (event) => {
if (event.key === 'Enter') {
sendMessage();
}
});
// Listen for new messages
onChildAdded(ref(database, 'messages'), (snapshot) => {
const { username, message } = snapshot.val();
const messageElement = document.createElement('div');
messageElement.textContent = `[${username}] > ${message}`;
chatDiv.appendChild(messageElement);
setTimeout(() => {
chatDiv.scrollTop = chatDiv.scrollHeight;
}, 100);
typingSound.play(); // Play sound on receiving a message
});
</script>
<style>
/* Hacker GUI Style */
body {
font-family: 'Courier New', monospace;
background-color: black;
color: limegreen;
margin: 0;
padding: 20px;
align: center;
}
h1 {
color: limegreen;
text-align: center;
}
#chat {
border: 2px solid limegreen;
height: 300px;
overflow-y: scroll;
padding: 10px;
background-color: black;
color: limegreen;
font-family: 'Courier New', monospace;
}
#username {
width: 20%;
padding: 10px;
background-color: black;
color: limegreen;
border: 2px solid limegreen;
font-family: 'Courier New', monospace;
margin-bottom: 10px;
}
#message {
width: 60%;
padding: 10px;
background-color: black;
color: limegreen;
border: 2px solid limegreen;
font-family: 'Courier New', monospace;
}
#message::after {
content: '|';
animation: blink 1s steps(2, start) infinite;
}
@keyframes blink {
0%, 100% { opacity: 1; }
50% { opacity: 0; }
}
#send {
padding: 10px 20px;
background-color: limegreen;
color: black;
border: none;
cursor: pointer;
font-family: 'Courier New', monospace;
}
#send:hover {
background-color: green;
}
</style>
</head>
<body>
<h1>The Matrix</h1>
<input type="text" id="username" placeholder="Enter your username...">
<div id="chat"></div>
<input type="text" id="message" placeholder="Type your message here...">
<button id="send">Send</button>
</body>
</html>