1<!DOCTYPE html>
2<html lang="en">
3
4<head>
5 <meta charset="UTF-8">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <title>We Chat: Empowered by I Plus T Solutions</title>
8 <meta name="description" content="A cutting-edge communication platform designed to facilitate seamless interactions and foster meaningful connections." />
9 <link rel="icon" type="image/png" href="https://www.iplust.in/icon.png" />
10 <script src="https://cdn.socket.io/4.0.0/socket.io.min.js"></script>
11 <style>
12 /* chat.module.css */
13 * {
14 margin: 0;
15 padding: 0;
16 box-sizing: border-box;
17 scrollbar-width: 0;
18 }
19
20 /* For WebKit browsers (Chrome, Safari) */
21 *::-webkit-scrollbar {
22 display: none;
23 /* Hides the scrollbar */
24 }
25
26 .container {
27 display: flex;
28 flex-direction: column;
29 justify-content: space-between;
30 width: 100vw;
31 height: 100dvh;
32 padding: 20px;
33 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
34 font-family: 'Poppins', sans-serif;
35 box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
36 }
37
38 .header {
39 display: flex;
40 justify-content: space-between;
41 align-items: center;
42 margin-bottom: 20px;
43 }
44
45 .roomTitle {
46 color: white;
47 font-size: 1.5rem;
48 margin: 0;
49 text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
50 }
51
52 .copyButton {
53 padding: 0.5rem 1rem;
54 font-size: 1rem;
55 color: white;
56 background-color: #ff512f;
57 border: none;
58 border-radius: 8px;
59 cursor: pointer;
60 transition: background 0.3s ease;
61 box-shadow: 0 4px 10px rgba(255, 81, 47, 0.3);
62 }
63
64 .copyButton:hover {
65 background-color: #f09819;
66 }
67
68 .chatBox {
69 flex: 1;
70 /* This makes the chatbox grow to fill the space */
71 overflow-y: auto;
72 background-color: rgba(255, 255, 255, 0.1);
73 padding: 20px;
74 border-radius: 10px;
75 box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.2);
76 backdrop-filter: blur(10px);
77 }
78
79 .senderMessage,
80 .receiverMessage {
81 padding: 10px 15px;
82 border-radius: 10px;
83 font-size: 1rem;
84 width: fit-content;
85 line-height: 1.4;
86 box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1);
87 }
88
89 .chatBoxInputleft {
90 width: 100%;
91 display: flex;
92 justify-content: end;
93 margin-bottom: 15px;
94 }
95
96 .chatBoxInputright {
97 width: 100%;
98 margin-bottom: 15px;
99 display: flex;
100 justify-content: flex-start;
101 }
102
103 .senderMessage {
104 background: linear-gradient(135deg, #ff512f, #f09819);
105 color: white;
106 min-width: 40px;
107 text-align: end;
108 }
109
110 .receiverMessage {
111 background: rgba(255, 255, 255, 0.8);
112 color: #333;
113 min-width: 40px;
114 }
115
116 .inputContainer {
117 display: flex;
118 gap: 10px;
119 margin-top: 20px;
120 }
121
122 .input {
123 flex: 1;
124 padding: 10px;
125 font-size: 1rem;
126 border-radius: 8px;
127 border: none;
128 box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.1);
129 }
130
131 .input:focus {
132 outline: none;
133 box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
134 }
135
136 .sendButton {
137 padding: 10px 20px;
138 font-size: 1rem;
139 font-weight: bold;
140 color: white;
141 background: linear-gradient(135deg, #667eea, #764ba2);
142 border: none;
143 border-radius: 8px;
144 cursor: pointer;
145 transition: background 0.3s ease, transform 0.3s ease;
146 box-shadow: 0 6px 12px rgba(118, 75, 162, 0.3);
147 }
148
149 .sendButton:hover {
150 background: linear-gradient(135deg, #546de5, #5f27cd);
151 transform: translateY(-2px);
152 }
153
154 .sendButton:active {
155 transform: translateY(0);
156 }
157
158 @media screen and (max-width: 600px) {
159 .container {
160 padding: 5px;
161 }
162
163 .chatBox {
164 padding: 10px;
165 }
166
167 .senderMessage {
168 padding: 5px;
169 border-radius: 5px;
170 }
171
172 .receiverMessage {
173 padding: 5px;
174 border-radius: 5px;
175 }
176 }
177 </style>
178</head>
179
180<body>
181 <div class="container">
182 <div class="header">
183 <h2 class="roomTitle" id="roomTitle">Room: </h2>
184 <button onclick="copyRoomId()" class="copyButton">Invite Others to JOIN</button>
185 </div>
186 <div id="chatBox" class="chatBox"></div>
187 <form id="messageForm" class="inputContainer">
188 <input type="text" id="messageInput" placeholder="Type a message..." class="input" required />
189 <button type="submit" class="sendButton">Send</button>
190 </form>
191 </div>
192
193 <script>
194 const chatBox = document.getElementById('chatBox');
195 const messageForm = document.getElementById('messageForm');
196 const messageInput = document.getElementById('messageInput');
197 const roomTitle = document.getElementById('roomTitle');
198
199 const socket = io(window.location.origin);
200 const urlParams = new URLSearchParams(window.location.search);
201 const roomId = urlParams.get('roomId') || 'defaultRoom';
202 const name = urlParams.get('name') || 'Anonymous';
203
204 roomTitle.textContent = 'Room: ' + roomId;
205
206 socket.emit('JoinWeChatRoom', roomId);
207
208 socket.on('receiveMessage', (message) => {
209 const messageDiv = document.createElement('div');
210 messageDiv.className = message.sender === name ? 'chatBoxInputleft' : 'chatBoxInputright';
211 const messageContent = document.createElement('div');
212 messageContent.className = message.sender === name ? 'senderMessage' : 'receiverMessage';
213 messageContent.textContent = message.text;
214 messageDiv.appendChild(messageContent);
215 chatBox.appendChild(messageDiv);
216 chatBox.scrollTop = chatBox.scrollHeight;
217 });
218
219 messageForm.addEventListener('submit', function (e) {
220 e.preventDefault();
221 const newMessage = messageInput.value.trim();
222 if (newMessage) {
223 const messageData = { roomId, text: newMessage, sender: name };
224 socket.emit('SendMessage', messageData);
225 messageInput.value = '';
226 }
227 });
228
229 function copyRoomId() {
230 navigator.clipboard.writeText(window.location.origin + `?roomId=${roomId}`);
231 alert('Link copied!');
232 }
233 </script>
234</body>
235
236</html>
Comments Of This Blog ...