CVNSS commited on
Commit
300677f
·
verified ·
1 Parent(s): 8348c3d

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +41 -68
index.html CHANGED
@@ -7,84 +7,60 @@
7
  <style>
8
  :root{
9
  --primary:#1a73e8; --bg:#f5f6f8; --text:#202124;
10
- --ov-top:72px; /* cao overlay che HEADER tlk (để lộ khung Join) */
11
- --ov-right:260px; /* rộng overlay che cột phải */
 
12
  }
13
  *{ box-sizing:border-box }
14
- body{
15
- margin:0; font-family:"Google Sans",Arial,sans-serif;
16
- background:var(--bg); color:var(--text);
17
- display:flex; flex-direction:column; min-height:100vh;
18
- }
19
- header{
20
- background:var(--primary); color:#fff; padding:16px;
21
- text-align:center; font-size:20px; font-weight:600;
22
- box-shadow:0 2px 6px rgba(0,0,0,.1);
23
- }
24
- .card{
25
- width:min(940px,92vw); margin:28px auto; background:#fff;
26
- border-radius:12px; box-shadow:0 6px 18px rgba(0,0,0,.08); padding:22px;
27
- }
28
  h2{ margin:0 0 14px 0; font-weight:600 }
29
  .row{ display:flex; gap:10px; flex-wrap:wrap }
30
- input[type="text"]{
31
- flex:1 1 260px; padding:12px 14px; font-size:16px;
32
- border:1px solid #dadce0; border-radius:8px;
33
- }
34
  input[type="text"]:focus{ outline:none; border-color:var(--primary) }
35
- button{
36
- padding:12px 18px; border:none; border-radius:8px;
37
- background:var(--primary); color:#fff; font-weight:600; cursor:pointer;
38
- }
39
  button:hover{ background:#0b5ed7 }
40
  .ghost{ background:#e9eef6; color:#174ea6 }
41
  .secondary{ background:#5f6368 }
42
  .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace }
43
  #chat-box{ display:none }
44
- .pill{
45
- display:inline-block; background:#eef3fd; color:#174ea6;
46
- padding:6px 10px; border-radius:999px; font-size:14px; margin-bottom:10px;
47
- }
48
  .chat-wrap{ position:relative; border:1px solid #e3e6ea; border-radius:10px; overflow:hidden }
49
  iframe{ width:100%; height:72vh; min-height:520px; border:0; background:#fff }
50
 
51
- /* Overlays: chỉ che header & cột phải của tlk.io */
52
- .ov-top{
53
- position:absolute; left:0; right:0; top:0;
54
- height:var(--ov-top); background:#fff; z-index:3; pointer-events:none;
55
- box-shadow:0 8px 10px -10px rgba(0,0,0,.12);
56
- }
57
- .ov-right{
58
- position:absolute; top:0; right:0; bottom:0;
59
- width:var(--ov-right); background:#fff; z-index:2; pointer-events:none;
60
- box-shadow:-8px 0 10px -10px rgba(0,0,0,.12);
61
- }
62
- @media (max-width:640px){ :root{ --ov-top:56px; --ov-right:200px } }
63
 
64
  .links{ display:none; gap:8px; align-items:center; flex-wrap:wrap; margin-top:12px }
65
  .link-badge{ background:#f1f3f4; padding:6px 8px; border-radius:6px }
66
-
67
- /* Toast thông báo */
68
- .toast{
69
- position:fixed; left:50%; bottom:24px; transform:translateX(-50%);
70
- background:#323232; color:#fff; padding:10px 14px; border-radius:8px;
71
- font-size:14px; opacity:0; pointer-events:none; transition:opacity .2s ease;
72
- }
73
  .toast.show{ opacity:1 }
74
  footer{ margin-top:auto; text-align:center; color:#6c727a; font-size:13px; padding:16px }
 
75
  </style>
76
  </head>
77
  <body>
78
  <header>💬 Chat CVNSS4.0</header>
79
 
80
- <!-- khối tạo phòng & vào chat -->
81
  <section id="login" class="card">
82
  <h2>Tham gia phòng chat</h2>
83
  <div class="row" style="margin-bottom:10px;">
84
  <input type="text" id="nickname" placeholder="Nhập tên của bạn…">
85
  <button id="joinBtn">Vào Chat</button>
86
  </div>
87
-
88
  <div class="row">
89
  <button class="ghost" id="newRoomBtn">✨ Tạo phòng bí mật</button>
90
  </div>
@@ -102,6 +78,7 @@
102
  <div class="chat-wrap">
103
  <div class="ov-top"></div>
104
  <div class="ov-right"></div>
 
105
  <iframe id="chatFrame" title="tlk.io chat"></iframe>
106
  </div>
107
  </section>
@@ -113,20 +90,17 @@
113
  </footer>
114
 
115
  <script>
116
- // Lấy room từ URL hoặc mặc định
117
  const qs = new URLSearchParams(location.search);
118
  let room = (qs.get("room") || "cvnss4-0").trim().toLowerCase();
119
  const base = `${location.origin}${location.pathname}`;
120
  document.getElementById("roomPill").textContent = "Phòng: " + room;
121
 
122
  // Toast helper
123
- function toast(msg){
124
- const t = document.getElementById('toast');
125
- t.textContent = msg; t.classList.add('show');
126
- setTimeout(()=> t.classList.remove('show'), 1400);
127
- }
128
 
129
- // Vào chat: nạp iframe với nickname
130
  document.getElementById("joinBtn").onclick = () => {
131
  const name = (document.getElementById("nickname").value || "").trim() || "Guest";
132
  document.getElementById("login").style.display = "none";
@@ -135,35 +109,34 @@
135
  document.getElementById("chatFrame").src = url;
136
  };
137
 
138
- // Tạo phòng bí mật: random id + cập nhật URL + hiển thị/copy link
139
  document.getElementById("newRoomBtn").onclick = () => {
140
  const rnd = Math.random().toString(36).slice(2,8);
141
  room = `cvnss4-0-${rnd}`;
142
  const link = `${base}?room=${room}`;
143
 
144
- // Cập nhật UI + URL hiện tại (để share đúng phòng)
145
  document.getElementById("roomPill").textContent = "Phòng: " + room;
146
  history.replaceState(null, "", `?room=${room}`);
147
 
148
- // Hiển thị block link
149
  const area = document.getElementById("linkArea");
150
  document.getElementById("roomUrl").textContent = link;
151
  area.style.display = "flex";
152
 
153
- // Copy & auto-ẩn block sau khi copy
154
  const copyBtn = document.getElementById("copyBtn");
155
  copyBtn.onclick = async () => {
156
  try {
157
- if (navigator.share) {
158
- // Ưu tiên chia sẻ hệ thống (nếu có)
159
- await navigator.share({ title: "Phòng chat CVNSS4.0", url: link });
160
- } else {
161
  await navigator.clipboard.writeText(link);
162
- toast("✅ Đã copy link phòng!");
163
  }
164
- } catch(e){ /* user huỷ share */ }
165
- // Ẩn khối link sau 1 giây để gọn gàng
166
- setTimeout(()=> area.style.display = "none", 1000);
 
 
 
167
  };
168
  };
169
  </script>
 
7
  <style>
8
  :root{
9
  --primary:#1a73e8; --bg:#f5f6f8; --text:#202124;
10
+ /* Che kín header + ô Join tlk.io (không che ô gõ tin nhắn) */
11
+ --ov-top:200px; /* nếu còn hở ô Join => tăng 220–260px */
12
+ --ov-right:260px; /* cột phải 220–300px tùy màn hình */
13
  }
14
  *{ box-sizing:border-box }
15
+ body{ margin:0; font-family:"Google Sans",Arial,sans-serif;
16
+ background:var(--bg); color:var(--text); display:flex; flex-direction:column; min-height:100vh; }
17
+ header{ background:var(--primary); color:#fff; padding:16px; text-align:center; font-size:20px; font-weight:600;
18
+ box-shadow:0 2px 6px rgba(0,0,0,.1); }
19
+ .card{ width:min(940px,92vw); margin:28px auto; background:#fff; border-radius:12px;
20
+ box-shadow:0 6px 18px rgba(0,0,0,.08); padding:22px; }
 
 
 
 
 
 
 
 
21
  h2{ margin:0 0 14px 0; font-weight:600 }
22
  .row{ display:flex; gap:10px; flex-wrap:wrap }
23
+ input[type="text"]{ flex:1 1 260px; padding:12px 14px; font-size:16px; border:1px solid #dadce0; border-radius:8px; }
 
 
 
24
  input[type="text"]:focus{ outline:none; border-color:var(--primary) }
25
+ button{ padding:12px 18px; border:none; border-radius:8px; background:var(--primary); color:#fff; font-weight:600; cursor:pointer; }
 
 
 
26
  button:hover{ background:#0b5ed7 }
27
  .ghost{ background:#e9eef6; color:#174ea6 }
28
  .secondary{ background:#5f6368 }
29
  .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace }
30
  #chat-box{ display:none }
31
+ .pill{ display:inline-block; background:#eef3fd; color:#174ea6; padding:6px 10px; border-radius:999px; font-size:14px; margin-bottom:10px; }
32
+
 
 
33
  .chat-wrap{ position:relative; border:1px solid #e3e6ea; border-radius:10px; overflow:hidden }
34
  iframe{ width:100%; height:72vh; min-height:520px; border:0; background:#fff }
35
 
36
+ /* Overlays: che hẳn header + ô Join + cột phải + footer tlk.io */
37
+ .ov-top{ position:absolute; left:0; right:0; top:0; height:var(--ov-top);
38
+ background:#fff; z-index:3; pointer-events:none; box-shadow:0 8px 10px -10px rgba(0,0,0,.12); }
39
+ .ov-right{ position:absolute; top:0; right:0; bottom:0; width:var(--ov-right);
40
+ background:#fff; z-index:2; pointer-events:none; box-shadow:-8px 0 10px -10px rgba(0,0,0,.12); }
41
+ .ov-bottom{ position:absolute; left:0; right:0; bottom:0; height:100px;
42
+ background:#fff; z-index:2; pointer-events:none; box-shadow:0 -8px 10px -10px rgba(0,0,0,.12); }
 
 
 
 
 
43
 
44
  .links{ display:none; gap:8px; align-items:center; flex-wrap:wrap; margin-top:12px }
45
  .link-badge{ background:#f1f3f4; padding:6px 8px; border-radius:6px }
46
+ .toast{ position:fixed; left:50%; bottom:24px; transform:translateX(-50%);
47
+ background:#323232; color:#fff; padding:10px 14px; border-radius:8px; font-size:14px; opacity:0;
48
+ pointer-events:none; transition:opacity .2s ease; }
 
 
 
 
49
  .toast.show{ opacity:1 }
50
  footer{ margin-top:auto; text-align:center; color:#6c727a; font-size:13px; padding:16px }
51
+ @media (max-width:640px){ :root{ --ov-right:200px } }
52
  </style>
53
  </head>
54
  <body>
55
  <header>💬 Chat CVNSS4.0</header>
56
 
57
+ <!-- tạo phòng & vào chat -->
58
  <section id="login" class="card">
59
  <h2>Tham gia phòng chat</h2>
60
  <div class="row" style="margin-bottom:10px;">
61
  <input type="text" id="nickname" placeholder="Nhập tên của bạn…">
62
  <button id="joinBtn">Vào Chat</button>
63
  </div>
 
64
  <div class="row">
65
  <button class="ghost" id="newRoomBtn">✨ Tạo phòng bí mật</button>
66
  </div>
 
78
  <div class="chat-wrap">
79
  <div class="ov-top"></div>
80
  <div class="ov-right"></div>
81
+ <div class="ov-bottom"></div>
82
  <iframe id="chatFrame" title="tlk.io chat"></iframe>
83
  </div>
84
  </section>
 
90
  </footer>
91
 
92
  <script>
93
+ // --- trạng thái & URL ---
94
  const qs = new URLSearchParams(location.search);
95
  let room = (qs.get("room") || "cvnss4-0").trim().toLowerCase();
96
  const base = `${location.origin}${location.pathname}`;
97
  document.getElementById("roomPill").textContent = "Phòng: " + room;
98
 
99
  // Toast helper
100
+ const toastEl = document.getElementById('toast');
101
+ function toast(msg){ toastEl.textContent = msg; toastEl.classList.add('show'); setTimeout(()=>toastEl.classList.remove('show'), 1400); }
 
 
 
102
 
103
+ // --- Vào chat: luôn ẩn Join gốc bằng overlay, chỉ dùng form ngoài ---
104
  document.getElementById("joinBtn").onclick = () => {
105
  const name = (document.getElementById("nickname").value || "").trim() || "Guest";
106
  document.getElementById("login").style.display = "none";
 
109
  document.getElementById("chatFrame").src = url;
110
  };
111
 
112
+ // --- Tạo phòng bí mật: random id + cập nhật URL + hiện link + copy & ẩn ngay ---
113
  document.getElementById("newRoomBtn").onclick = () => {
114
  const rnd = Math.random().toString(36).slice(2,8);
115
  room = `cvnss4-0-${rnd}`;
116
  const link = `${base}?room=${room}`;
117
 
118
+ // cập nhật pill & URL hiện tại để share đúng phòng
119
  document.getElementById("roomPill").textContent = "Phòng: " + room;
120
  history.replaceState(null, "", `?room=${room}`);
121
 
122
+ // hiện block link
123
  const area = document.getElementById("linkArea");
124
  document.getElementById("roomUrl").textContent = link;
125
  area.style.display = "flex";
126
 
127
+ // copy & ẨN NGAY block cho gọn, vẫn hiện toast báo
128
  const copyBtn = document.getElementById("copyBtn");
129
  copyBtn.onclick = async () => {
130
  try {
131
+ if (navigator.clipboard && navigator.clipboard.writeText) {
 
 
 
132
  await navigator.clipboard.writeText(link);
 
133
  }
134
+ // nếu Web Share API, ưu tiên dùng (không bắt buộc)
135
+ if (navigator.share) { try { await navigator.share({ title:"Phòng chat CVNSS4.0", url:link }); } catch(e){} }
136
+ toast("✅ Đã copy link phòng!");
137
+ } catch(e){ toast("⚠️ Sao chép không thành công—hãy copy thủ công"); }
138
+ // Ẩn ngay khối link
139
+ area.style.display = "none";
140
  };
141
  };
142
  </script>