Update index.html
Browse files- index.html +132 -70
index.html
CHANGED
|
@@ -6,67 +6,88 @@
|
|
| 6 |
<title>Chat CVNSS4.0</title>
|
| 7 |
<style>
|
| 8 |
:root{
|
| 9 |
-
--bg:#0b0d10; --card:#
|
| 10 |
--primary:#1a73e8; --danger:#d93025; --accent:#ffeb3b;
|
| 11 |
-
/*
|
| 12 |
-
--ov-top:
|
| 13 |
-
--ov-right:
|
| 14 |
}
|
| 15 |
*{box-sizing:border-box}
|
| 16 |
-
body{
|
| 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 |
</style>
|
| 58 |
</head>
|
| 59 |
<body>
|
| 60 |
<header>💬 Chat CVNSS4.0</header>
|
| 61 |
|
| 62 |
-
<!-- Bước 1-2-3 -->
|
| 63 |
<section id="login" class="card">
|
| 64 |
<h2>Tham gia phòng chat</h2>
|
| 65 |
<p class="muted">Luồng 3 bước siêu gọn: nhập tên → <b>Vào Chat</b> → (tuỳ chọn) <b>✨ Tạo phòng bí mật</b> để mời người khác.</p>
|
| 66 |
<ol class="guide">
|
| 67 |
<li><b>Nhập tên</b> của bạn ở ô dưới đây (có thể sửa lại sau).</li>
|
| 68 |
<li>Nhấn <b>Vào Chat</b> (nút đỏ). <span class="muted">Form Join gốc của tlk.io sẽ bị ẩn hoàn toàn.</span></li>
|
| 69 |
-
<li><b>✨ Tạo phòng bí mật</b> (ID ngẫu nhiên + Copy link tự ẩn). <span class="muted">Nếu bạn không cần “✨ Tạo phòng bí mật”, hãy <u>bỏ qua bước này</u>.</span></li>
|
| 70 |
</ol>
|
| 71 |
|
| 72 |
<div class="row" style="margin-top:12px">
|
|
@@ -86,19 +107,18 @@
|
|
| 86 |
</div>
|
| 87 |
</section>
|
| 88 |
|
| 89 |
-
<!-- Khối chat (không có “Đổi tên / Iframe”) -->
|
| 90 |
<section id="chatBox" class="card" style="display:none">
|
| 91 |
<div class="status" id="statusBar">
|
| 92 |
<span class="me-pill">👤 <span id="meName">Guest</span></span>
|
| 93 |
<span class="room-pill">Phòng: <span id="roomPill" class="mono"></span></span>
|
| 94 |
</div>
|
| 95 |
<div class="chat-wrap">
|
| 96 |
-
<!--
|
| 97 |
-
<div class="ov-top"></div>
|
| 98 |
-
<div class="ov-right"></div>
|
| 99 |
-
<!-- chỉ highlight đáy để người dùng thấy khu nhập tin nhắn -->
|
| 100 |
<div class="focus-bottom"></div>
|
| 101 |
-
|
|
|
|
| 102 |
</div>
|
| 103 |
</section>
|
| 104 |
|
|
@@ -111,11 +131,12 @@
|
|
| 111 |
const qs = new URLSearchParams(location.search);
|
| 112 |
let room = (qs.get("room") || "cvnss4-0").trim().toLowerCase();
|
| 113 |
const base = `${location.origin}${location.pathname}`;
|
|
|
|
| 114 |
|
| 115 |
const els = {
|
| 116 |
login: document.getElementById("login"),
|
| 117 |
chatBox: document.getElementById("chatBox"),
|
| 118 |
-
|
| 119 |
name: document.getElementById("nickname"),
|
| 120 |
join: document.getElementById("joinBtn"),
|
| 121 |
newRoom: document.getElementById("newRoomBtn"),
|
|
@@ -127,36 +148,78 @@
|
|
| 127 |
roomPill: document.getElementById("roomPill"),
|
| 128 |
status: document.getElementById("statusBar"),
|
| 129 |
toast: document.getElementById("toast"),
|
|
|
|
|
|
|
| 130 |
};
|
| 131 |
|
| 132 |
function toast(msg){ els.toast.textContent = msg; els.toast.classList.add("show"); setTimeout(()=>els.toast.classList.remove("show"), 1400); }
|
| 133 |
function getName(){ return (els.name.value || localStorage.getItem("cvnss4_name") || "Guest").trim() || "Guest"; }
|
| 134 |
function setName(n){ els.meName.textContent = n; localStorage.setItem("cvnss4_name", n); }
|
| 135 |
function syncRoomUI(){ els.roomPill.textContent = room; els.hint.textContent = `(đang ở phòng ${room})`; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
setName(n);
|
| 143 |
syncRoomUI();
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
|
|
|
|
|
|
| 145 |
els.login.style.display = "none";
|
| 146 |
els.chatBox.style.display = "block";
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
// Iframe đi thẳng vào room với nickname => không bao giờ thấy Join
|
| 150 |
-
els.frame.src = tlkUrl(n);
|
| 151 |
-
|
| 152 |
-
// Cuộn tới chat
|
| 153 |
-
setTimeout(()=> els.chatBox.scrollIntoView({behavior:"smooth"}), 40);
|
| 154 |
}
|
| 155 |
|
| 156 |
els.join.addEventListener("click", enterChat);
|
| 157 |
els.name.addEventListener("keydown", e => { if(e.key === "Enter") enterChat(); });
|
| 158 |
|
| 159 |
-
// Tạo phòng bí mật
|
| 160 |
els.newRoom.addEventListener("click", async ()=>{
|
| 161 |
room = `cvnss4-0-${Math.random().toString(36).slice(2,8)}`;
|
| 162 |
syncRoomUI();
|
|
@@ -179,10 +242,9 @@
|
|
| 179 |
};
|
| 180 |
});
|
| 181 |
|
| 182 |
-
// Prefill tên
|
| 183 |
const last = localStorage.getItem("cvnss4_name"); if(last) els.name.value = last;
|
| 184 |
-
syncRoomUI();
|
| 185 |
-
els.name.focus({preventScroll:true});
|
| 186 |
})();
|
| 187 |
</script>
|
| 188 |
</body>
|
|
|
|
| 6 |
<title>Chat CVNSS4.0</title>
|
| 7 |
<style>
|
| 8 |
:root{
|
| 9 |
+
--bg:#0b0d10; --card:#0f141a; --text:#e6edf3; --muted:#9aa4af;
|
| 10 |
--primary:#1a73e8; --danger:#d93025; --accent:#ffeb3b;
|
| 11 |
+
/* Cỡ overlay an toàn: không che nội dung chat/textarea */
|
| 12 |
+
--ov-top: 160px; /* che header & Join (nếu còn hở tăng 180–200) */
|
| 13 |
+
--ov-right: clamp(220px, 24vw, 320px);/* che panel phải */
|
| 14 |
}
|
| 15 |
*{box-sizing:border-box}
|
| 16 |
+
body{
|
| 17 |
+
margin:0; font-family:"Google Sans",system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
|
| 18 |
+
background:var(--bg); color:var(--text); display:flex; flex-direction:column; min-height:100vh;
|
| 19 |
+
}
|
| 20 |
+
header{ padding:14px 16px; text-align:center; font-weight:800; background:#0f172a; color:#e2e8f0; border-bottom:1px solid #1f2937 }
|
| 21 |
+
.card{
|
| 22 |
+
width:min(980px,94vw); margin:22px auto; background:var(--card);
|
| 23 |
+
border:1px solid #1f2937; border-radius:14px; box-shadow:0 10px 30px rgba(0,0,0,.35);
|
| 24 |
+
padding:18px;
|
| 25 |
+
}
|
| 26 |
+
h2{ margin:0 0 6px; font-weight:900 }
|
| 27 |
+
.muted{ color:var(--muted) }
|
| 28 |
+
.row{ display:flex; gap:10px; flex-wrap:wrap; align-items:center }
|
| 29 |
+
input[type=text]{
|
| 30 |
+
flex:1 1 260px; padding:12px 14px; font-size:16px; border:1px solid #263042; background:#0b1220;
|
| 31 |
+
color:var(--text); border-radius:10px;
|
| 32 |
+
}
|
| 33 |
+
input[type=text]:focus{ outline:none; border-color:#3b82f6; box-shadow:0 0 0 3px rgba(59,130,246,.25) }
|
| 34 |
+
button{ padding:12px 18px; border:0; border-radius:10px; font-weight:900; cursor:pointer; letter-spacing:.2px }
|
| 35 |
+
.btn-red{ background:var(--danger); color:var(--accent) }
|
| 36 |
+
.btn-ghost{ background:#0f172a; color:#93c5fd; border:1px dashed #1f2937 }
|
| 37 |
+
.mono{ font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace }
|
| 38 |
+
|
| 39 |
+
/* Status: chỉ hiện tên + phòng (không có “Đổi tên / Iframe”) */
|
| 40 |
+
.status{ display:none; align-items:center; gap:10px; padding:10px 12px;
|
| 41 |
+
border:1px dashed #223047; border-radius:12px; margin-bottom:10px; background:#0b1220 }
|
| 42 |
+
.me-pill{ display:inline-flex; align-items:center; gap:6px; background:#0a0a0a; border:1px solid #2a1d00;
|
| 43 |
+
color:#ffd166; padding:6px 12px; border-radius:999px; font-weight:900 }
|
| 44 |
+
.room-pill{ display:inline-block; background:#0a1628; color:#8ab4ff; padding:6px 10px; border-radius:999px }
|
| 45 |
+
|
| 46 |
+
/* Khung chat + overlay ẩn header & panel phải (pointer-events:none nên không chặn click) */
|
| 47 |
+
.chat-wrap{ position:relative; border:1px solid #243145; border-radius:12px; overflow:hidden;
|
| 48 |
+
box-shadow:inset 0 0 0 1px #1f2a3a, 0 12px 30px rgba(0,0,0,.35) }
|
| 49 |
+
/* điểm mount (embed) hoặc chứa iframe */
|
| 50 |
+
#chatMount{ min-height:580px }
|
| 51 |
+
iframe{ width:100%; height:72vh; min-height:580px; border:0; background:#0b1220 }
|
| 52 |
+
|
| 53 |
+
/* Overlays — KHÔNG che phần giữa, KHÔNG che đáy (textarea) */
|
| 54 |
+
.ov-top{
|
| 55 |
+
position:absolute; left:0; right:0; top:0; height:var(--ov-top);
|
| 56 |
+
background:var(--card); z-index:3; pointer-events:none;
|
| 57 |
+
box-shadow:0 10px 12px -10px rgba(0,0,0,.6);
|
| 58 |
+
}
|
| 59 |
+
.ov-right{
|
| 60 |
+
position:absolute; top:0; right:0; bottom:0; width:var(--ov-right);
|
| 61 |
+
background:var(--card); z-index:2; pointer-events:none;
|
| 62 |
+
box-shadow:-10px 0 12px -10px rgba(0,0,0,.6);
|
| 63 |
+
}
|
| 64 |
+
/* Glow nhẹ ở đáy để “gợi ý” chỗ gõ — không che click */
|
| 65 |
+
.focus-bottom{
|
| 66 |
+
position:absolute; left:0; right:var(--ov-right); bottom:0; height:128px; pointer-events:none; z-index:1;
|
| 67 |
+
background:radial-gradient(120% 120% at 50% 100%, rgba(255,235,59,.16) 0%, rgba(255,235,59,.08) 40%, rgba(0,0,0,0) 72%);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
.links{ display:none; gap:8px; align-items:center; flex-wrap:wrap; margin-top:10px }
|
| 71 |
+
.link-badge{ background:#0b1220; border:1px solid #223047; color:#b6c2d2; padding:6px 8px; border-radius:8px }
|
| 72 |
+
.toast{ position:fixed; left:50%; bottom:22px; transform:translateX(-50%); background:#111827; color:#e5e7eb;
|
| 73 |
+
border:1px solid #374151; padding:10px 14px; border-radius:10px; font-size:14px; opacity:0; pointer-events:none; transition:opacity .2s }
|
| 74 |
+
.toast.show{ opacity:1 }
|
| 75 |
+
|
| 76 |
+
footer{ margin-top:auto; text-align:center; color:#8b9bb1; font-size:13px; padding:16px }
|
| 77 |
+
ol.guide{ margin:0; padding-left:20px } ol.guide li{ margin:6px 0 }
|
| 78 |
+
@media (max-width:820px){ :root{ --ov-right:0px } } /* mobile: tlk.io thường không có panel phải */
|
| 79 |
</style>
|
| 80 |
</head>
|
| 81 |
<body>
|
| 82 |
<header>💬 Chat CVNSS4.0</header>
|
| 83 |
|
|
|
|
| 84 |
<section id="login" class="card">
|
| 85 |
<h2>Tham gia phòng chat</h2>
|
| 86 |
<p class="muted">Luồng 3 bước siêu gọn: nhập tên → <b>Vào Chat</b> → (tuỳ chọn) <b>✨ Tạo phòng bí mật</b> để mời người khác.</p>
|
| 87 |
<ol class="guide">
|
| 88 |
<li><b>Nhập tên</b> của bạn ở ô dưới đây (có thể sửa lại sau).</li>
|
| 89 |
<li>Nhấn <b>Vào Chat</b> (nút đỏ). <span class="muted">Form Join gốc của tlk.io sẽ bị ẩn hoàn toàn.</span></li>
|
| 90 |
+
<li><b>✨ Tạo phòng bí mật</b> nếu cần (ID ngẫu nhiên + Copy link tự ẩn). <span class="muted">Nếu bạn không cần “✨ Tạo phòng bí mật”, hãy <u>bỏ qua bước này</u>.</span></li>
|
| 91 |
</ol>
|
| 92 |
|
| 93 |
<div class="row" style="margin-top:12px">
|
|
|
|
| 107 |
</div>
|
| 108 |
</section>
|
| 109 |
|
|
|
|
| 110 |
<section id="chatBox" class="card" style="display:none">
|
| 111 |
<div class="status" id="statusBar">
|
| 112 |
<span class="me-pill">👤 <span id="meName">Guest</span></span>
|
| 113 |
<span class="room-pill">Phòng: <span id="roomPill" class="mono"></span></span>
|
| 114 |
</div>
|
| 115 |
<div class="chat-wrap">
|
| 116 |
+
<!-- Che header kênh + panel phải, KHÔNG che đáy -->
|
| 117 |
+
<div class="ov-top" id="ovTop"></div>
|
| 118 |
+
<div class="ov-right" id="ovRight"></div>
|
|
|
|
| 119 |
<div class="focus-bottom"></div>
|
| 120 |
+
<!-- mount cho embed hoặc iframe -->
|
| 121 |
+
<div id="chatMount"></div>
|
| 122 |
</div>
|
| 123 |
</section>
|
| 124 |
|
|
|
|
| 131 |
const qs = new URLSearchParams(location.search);
|
| 132 |
let room = (qs.get("room") || "cvnss4-0").trim().toLowerCase();
|
| 133 |
const base = `${location.origin}${location.pathname}`;
|
| 134 |
+
const debug = qs.get("debug")==="1"; // ?debug=1 để tắt overlay khi test
|
| 135 |
|
| 136 |
const els = {
|
| 137 |
login: document.getElementById("login"),
|
| 138 |
chatBox: document.getElementById("chatBox"),
|
| 139 |
+
mount: document.getElementById("chatMount"),
|
| 140 |
name: document.getElementById("nickname"),
|
| 141 |
join: document.getElementById("joinBtn"),
|
| 142 |
newRoom: document.getElementById("newRoomBtn"),
|
|
|
|
| 148 |
roomPill: document.getElementById("roomPill"),
|
| 149 |
status: document.getElementById("statusBar"),
|
| 150 |
toast: document.getElementById("toast"),
|
| 151 |
+
ovTop: document.getElementById("ovTop"),
|
| 152 |
+
ovRight: document.getElementById("ovRight"),
|
| 153 |
};
|
| 154 |
|
| 155 |
function toast(msg){ els.toast.textContent = msg; els.toast.classList.add("show"); setTimeout(()=>els.toast.classList.remove("show"), 1400); }
|
| 156 |
function getName(){ return (els.name.value || localStorage.getItem("cvnss4_name") || "Guest").trim() || "Guest"; }
|
| 157 |
function setName(n){ els.meName.textContent = n; localStorage.setItem("cvnss4_name", n); }
|
| 158 |
function syncRoomUI(){ els.roomPill.textContent = room; els.hint.textContent = `(đang ở phòng ${room})`; }
|
| 159 |
+
function clearMount(){ els.mount.replaceChildren(); }
|
| 160 |
+
|
| 161 |
+
// Tạm tắt overlay khi debug
|
| 162 |
+
if (debug){ els.ovTop.style.display="none"; els.ovRight.style.display="none"; }
|
| 163 |
+
|
| 164 |
+
// ======== Renderer A: embed.js (ưu tiên) ========
|
| 165 |
+
function renderEmbed(name){
|
| 166 |
+
clearMount();
|
| 167 |
+
const holder = document.createElement("div");
|
| 168 |
+
holder.id = "tlkio";
|
| 169 |
+
holder.dataset.channel = room;
|
| 170 |
+
holder.dataset.nickname = name;
|
| 171 |
+
holder.dataset.theme = "theme--day";
|
| 172 |
+
holder.style.minHeight = "580px";
|
| 173 |
+
els.mount.appendChild(holder);
|
| 174 |
+
|
| 175 |
+
const s = document.createElement("script");
|
| 176 |
+
s.async = true;
|
| 177 |
+
s.src = "https://tlk.io/embed.js";
|
| 178 |
+
let fallbackTimer = setTimeout(()=>{ renderIframe(name); }, 4500); // nếu embed.js bị chặn → dùng iframe
|
| 179 |
+
s.onload = () => { clearTimeout(fallbackTimer); };
|
| 180 |
+
s.onerror = () => { clearTimeout(fallbackTimer); renderIframe(name); };
|
| 181 |
+
els.mount.appendChild(s);
|
| 182 |
+
}
|
| 183 |
|
| 184 |
+
// ======== Renderer B: iframe (fallback) ========
|
| 185 |
+
function renderIframe(name){
|
| 186 |
+
clearMount();
|
| 187 |
+
const url = `https://tlk.io/${encodeURIComponent(room)}?nickname=${encodeURIComponent(name)}#embed`;
|
| 188 |
+
const ifr = document.createElement("iframe");
|
| 189 |
+
ifr.title = "tlk.io chat";
|
| 190 |
+
ifr.src = url;
|
| 191 |
+
ifr.referrerPolicy = "no-referrer";
|
| 192 |
+
// Nếu iframe không tải được trong 6s → nhắc kiểm tra mạng/CSP
|
| 193 |
+
let watch = setTimeout(() => {
|
| 194 |
+
const warn = document.createElement("div");
|
| 195 |
+
warn.style.padding = "16px"; warn.style.color = "#ffd166";
|
| 196 |
+
warn.textContent = "⚠️ Không tải được khung chat. Thử mở trang này trong cửa sổ mới hoặc bật cho phép nội dung bên thứ ba.";
|
| 197 |
+
els.mount.appendChild(warn);
|
| 198 |
+
}, 6000);
|
| 199 |
+
ifr.addEventListener("load", ()=> clearTimeout(watch));
|
| 200 |
+
els.mount.appendChild(ifr);
|
| 201 |
+
}
|
| 202 |
|
| 203 |
+
function renderChat(){
|
| 204 |
+
const name = getName();
|
| 205 |
+
setName(name);
|
|
|
|
| 206 |
syncRoomUI();
|
| 207 |
+
els.status.style.display = "flex";
|
| 208 |
+
renderEmbed(name); // sẽ tự fallback nếu cần
|
| 209 |
+
setTimeout(()=> els.chatBox.scrollIntoView({behavior:"smooth", block:"start"}), 50);
|
| 210 |
+
}
|
| 211 |
|
| 212 |
+
// ======== Actions ========
|
| 213 |
+
function enterChat(){
|
| 214 |
els.login.style.display = "none";
|
| 215 |
els.chatBox.style.display = "block";
|
| 216 |
+
renderChat();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 217 |
}
|
| 218 |
|
| 219 |
els.join.addEventListener("click", enterChat);
|
| 220 |
els.name.addEventListener("keydown", e => { if(e.key === "Enter") enterChat(); });
|
| 221 |
|
| 222 |
+
// Tạo phòng bí mật
|
| 223 |
els.newRoom.addEventListener("click", async ()=>{
|
| 224 |
room = `cvnss4-0-${Math.random().toString(36).slice(2,8)}`;
|
| 225 |
syncRoomUI();
|
|
|
|
| 242 |
};
|
| 243 |
});
|
| 244 |
|
| 245 |
+
// Prefill tên
|
| 246 |
const last = localStorage.getItem("cvnss4_name"); if(last) els.name.value = last;
|
| 247 |
+
syncRoomUI(); els.name.focus({preventScroll:true});
|
|
|
|
| 248 |
})();
|
| 249 |
</script>
|
| 250 |
</body>
|