Update index.html
Browse files- index.html +129 -132
index.html
CHANGED
|
@@ -1,151 +1,148 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="vi">
|
| 3 |
<head>
|
| 4 |
-
<meta charset="UTF-8"
|
| 5 |
-
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
| 6 |
<title>Chat CVNSS4.0</title>
|
|
|
|
| 7 |
<style>
|
| 8 |
:root { --primary:#1a73e8; --bg:#f5f6f8; --text:#202124; }
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
}
|
| 14 |
-
header{
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
-
/*
|
| 33 |
-
|
| 34 |
-
.ov-top{
|
| 35 |
position:absolute; left:0; right:0; top:0;
|
| 36 |
-
height:
|
| 37 |
-
|
| 38 |
-
box-shadow: 0 8px 10px -10px rgba(0,0,0,.12);
|
| 39 |
-
transition: height .15s ease;
|
| 40 |
}
|
| 41 |
-
|
| 42 |
-
.ov-right{
|
| 43 |
position:absolute; top:0; right:0; bottom:0;
|
| 44 |
-
width:
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
}
|
| 48 |
|
| 49 |
-
|
| 50 |
-
.
|
| 51 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
</style>
|
| 53 |
</head>
|
| 54 |
<body>
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
</div>
|
| 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 |
-
document.getElementById(
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
// - Guest: che thấp (để lộ form Join, người nhận link có thể nhấn Enter)
|
| 120 |
-
const ovTop = document.getElementById('ovTop');
|
| 121 |
-
ovTop.style.height = (view === "host") ? "180px" : "70px";
|
| 122 |
-
|
| 123 |
-
const url = "https://tlk.io/" + encodeURIComponent(room) + "?nickname=" + encodeURIComponent(name);
|
| 124 |
-
document.getElementById('tlk').src = url;
|
| 125 |
-
|
| 126 |
-
// Với host: cuộn nhẹ để đảm bảo phần chat lộ ngay
|
| 127 |
-
if (view === "host") {
|
| 128 |
-
setTimeout(() => {
|
| 129 |
-
try { document.getElementById('tlk').contentWindow.scrollTo(0, 260); } catch(e) {}
|
| 130 |
-
}, 1500);
|
| 131 |
-
}
|
| 132 |
-
};
|
| 133 |
-
|
| 134 |
-
// ── Tạo phòng bí mật & sinh 2 link: host/guest ─────────────────
|
| 135 |
-
document.getElementById('mkRoom').onclick = () => {
|
| 136 |
-
const rnd = Math.random().toString(36).slice(2,8);
|
| 137 |
-
const newRoom = `cvnss4-0-${rnd}`;
|
| 138 |
-
const base = `${location.origin}${location.pathname}`;
|
| 139 |
-
const host = `${base}?room=${newRoom}&view=host`;
|
| 140 |
-
const guest = `${base}?room=${newRoom}&view=guest`;
|
| 141 |
-
|
| 142 |
-
document.getElementById('links').style.display = 'block';
|
| 143 |
-
document.getElementById('hostLink').textContent = host;
|
| 144 |
-
document.getElementById('guestLink').textContent = guest;
|
| 145 |
-
|
| 146 |
-
document.getElementById('copyHost').onclick = () => navigator.clipboard.writeText(host).then(()=>alert("✅ Đã copy Host link!"));
|
| 147 |
-
document.getElementById('copyGuest').onclick = () => navigator.clipboard.writeText(guest).then(()=>alert("✅ Đã copy Guest link!"));
|
| 148 |
-
};
|
| 149 |
-
</script>
|
| 150 |
</body>
|
| 151 |
</html>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
<html lang="vi">
|
| 3 |
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
|
|
|
| 5 |
<title>Chat CVNSS4.0</title>
|
| 6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 7 |
<style>
|
| 8 |
:root { --primary:#1a73e8; --bg:#f5f6f8; --text:#202124; }
|
| 9 |
+
body {
|
| 10 |
+
margin:0; font-family: "Google Sans", Arial, sans-serif;
|
| 11 |
+
background:var(--bg); color:var(--text);
|
| 12 |
+
display:flex; flex-direction:column; min-height:100vh;
|
| 13 |
}
|
| 14 |
+
header {
|
| 15 |
+
background:var(--primary); color:#fff; padding:16px;
|
| 16 |
+
text-align:center; font-size:20px; font-weight:600;
|
| 17 |
+
box-shadow:0 2px 6px rgba(0,0,0,0.1);
|
| 18 |
+
}
|
| 19 |
+
.card {
|
| 20 |
+
width:min(940px, 92vw); margin:30px auto;
|
| 21 |
+
background:#fff; border-radius:12px;
|
| 22 |
+
box-shadow:0 4px 12px rgba(0,0,0,0.1); padding:24px;
|
| 23 |
+
}
|
| 24 |
+
h2 { margin-top:0; }
|
| 25 |
+
.row { display:flex; gap:10px; flex-wrap:wrap; }
|
| 26 |
+
input[type="text"] {
|
| 27 |
+
flex:1 1 260px; padding:12px 14px; font-size:16px;
|
| 28 |
+
border:1px solid #dadce0; border-radius:8px;
|
| 29 |
+
}
|
| 30 |
+
input[type="text"]:focus { border-color:var(--primary); outline:none; }
|
| 31 |
+
button {
|
| 32 |
+
padding:12px 18px; border:none; border-radius:8px;
|
| 33 |
+
background:var(--primary); color:#fff;
|
| 34 |
+
font-size:16px; font-weight:600; cursor:pointer;
|
| 35 |
+
}
|
| 36 |
+
button:hover { background:#0b5ed7; }
|
| 37 |
+
.ghost { background:#e9eef6; color:#174ea6; }
|
| 38 |
+
.secondary { background:#5f6368; }
|
| 39 |
+
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
| 40 |
+
#chat-box { display:none; }
|
| 41 |
+
.pill {
|
| 42 |
+
display:inline-block; background:#eef3fd; color:#174ea6;
|
| 43 |
+
padding:6px 10px; border-radius:999px; font-size:14px; margin-bottom:10px;
|
| 44 |
+
}
|
| 45 |
+
.chat-wrap { position:relative; border:1px solid #e0e3e7; border-radius:10px; overflow:hidden; }
|
| 46 |
+
iframe { width:100%; height:70vh; border:0; background:#fff; }
|
| 47 |
|
| 48 |
+
/* Overlays: che form Join + cột phải + footer tlk.io */
|
| 49 |
+
.ov-top {
|
|
|
|
| 50 |
position:absolute; left:0; right:0; top:0;
|
| 51 |
+
height:200px; background:#fff; z-index:3; pointer-events:none;
|
| 52 |
+
box-shadow:0 6px 8px -6px rgba(0,0,0,0.15);
|
|
|
|
|
|
|
| 53 |
}
|
| 54 |
+
.ov-right {
|
|
|
|
| 55 |
position:absolute; top:0; right:0; bottom:0;
|
| 56 |
+
width:260px; background:#fff; z-index:2; pointer-events:none;
|
| 57 |
+
box-shadow:-6px 0 8px -6px rgba(0,0,0,0.15);
|
| 58 |
+
}
|
| 59 |
+
.ov-bottom {
|
| 60 |
+
position:absolute; left:0; right:0; bottom:0;
|
| 61 |
+
height:100px; background:#fff; z-index:2; pointer-events:none;
|
| 62 |
+
box-shadow:0 -6px 8px -6px rgba(0,0,0,0.15);
|
| 63 |
}
|
| 64 |
|
| 65 |
+
.links { margin-top:14px; display:flex; flex-direction:column; gap:8px; }
|
| 66 |
+
.link-line { display:flex; gap:8px; align-items:center; flex-wrap:wrap; }
|
| 67 |
+
.link-badge { background:#f1f3f4; padding:6px 8px; border-radius:6px; }
|
| 68 |
+
footer {
|
| 69 |
+
margin-top:auto; background:#f1f3f4; padding:14px;
|
| 70 |
+
text-align:center; font-size:13px; color:#6c727a;
|
| 71 |
+
}
|
| 72 |
</style>
|
| 73 |
</head>
|
| 74 |
<body>
|
| 75 |
+
<header>💬 Chat CVNSS4.0</header>
|
| 76 |
+
|
| 77 |
+
<!-- Khối “tạo phòng” & “vào chat” -->
|
| 78 |
+
<div id="login" class="card">
|
| 79 |
+
<h2>Tham gia phòng chat</h2>
|
| 80 |
+
<div class="row" style="margin-bottom:10px;">
|
| 81 |
+
<input type="text" id="nickname" placeholder="Nhập tên của bạn…">
|
| 82 |
+
<button id="joinBtn">Vào Chat</button>
|
| 83 |
+
</div>
|
| 84 |
+
|
| 85 |
+
<div class="row">
|
| 86 |
+
<button class="ghost" id="newRoomBtn">✨ Tạo phòng bí mật</button>
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
<div id="linkArea" class="links" style="display:none;">
|
| 90 |
+
<div class="link-line">
|
| 91 |
+
<span>🔗 Link phòng:</span>
|
| 92 |
+
<span id="roomUrl" class="link-badge mono"></span>
|
| 93 |
+
<button class="secondary" id="copyBtn">📋 Copy</button>
|
| 94 |
</div>
|
| 95 |
+
<div style="color:#5f6368; font-size:13px;">Gửi link này cho mọi người để cùng vào phòng.</div>
|
| 96 |
+
</div>
|
| 97 |
+
</div>
|
| 98 |
+
|
| 99 |
+
<!-- Khối chat -->
|
| 100 |
+
<div id="chat-box" class="card">
|
| 101 |
+
<span id="roomPill" class="pill"></span>
|
| 102 |
+
<div class="chat-wrap">
|
| 103 |
+
<div class="ov-top"></div>
|
| 104 |
+
<div class="ov-right"></div>
|
| 105 |
+
<div class="ov-bottom"></div>
|
| 106 |
+
<iframe id="chatFrame" title="tlk.io chat"></iframe>
|
| 107 |
+
</div>
|
| 108 |
+
</div>
|
| 109 |
+
|
| 110 |
+
<footer>
|
| 111 |
+
Nguồn: Sản phẩm thử nghiệm của Team CVNSS4.0 • Đóng tab là xóa hết dữ liệu ✅
|
| 112 |
+
</footer>
|
| 113 |
+
|
| 114 |
+
<script>
|
| 115 |
+
// Lấy room từ URL (mặc định: cvnss4-0)
|
| 116 |
+
const qs = new URLSearchParams(location.search);
|
| 117 |
+
let room = (qs.get("room") || "cvnss4-0").trim().toLowerCase();
|
| 118 |
+
const base = `${location.origin}${location.pathname}`;
|
| 119 |
+
|
| 120 |
+
document.getElementById("roomPill").textContent = "Phòng: " + room;
|
| 121 |
+
|
| 122 |
+
// Bấm "Vào Chat": nạp iframe tlk.io (form join bên trong luôn bị che)
|
| 123 |
+
document.getElementById("joinBtn").onclick = () => {
|
| 124 |
+
const name = (document.getElementById("nickname").value || "").trim() || "Guest";
|
| 125 |
+
document.getElementById("login").style.display = "none";
|
| 126 |
+
document.getElementById("chat-box").style.display = "block";
|
| 127 |
+
const url = `https://tlk.io/${encodeURIComponent(room)}?nickname=${encodeURIComponent(name)}`;
|
| 128 |
+
document.getElementById("chatFrame").src = url;
|
| 129 |
+
};
|
| 130 |
+
|
| 131 |
+
// Tạo phòng bí mật (random ID) + hiển thị/copy 1 link duy nhất
|
| 132 |
+
document.getElementById("newRoomBtn").onclick = () => {
|
| 133 |
+
const rnd = Math.random().toString(36).slice(2,8);
|
| 134 |
+
room = `cvnss4-0-${rnd}`;
|
| 135 |
+
const link = `${base}?room=${room}`;
|
| 136 |
+
|
| 137 |
+
// Cập nhật pill + link
|
| 138 |
+
document.getElementById("roomPill").textContent = "Phòng: " + room;
|
| 139 |
+
document.getElementById("roomUrl").textContent = link;
|
| 140 |
+
document.getElementById("linkArea").style.display = "flex";
|
| 141 |
+
|
| 142 |
+
// Copy
|
| 143 |
+
const copyBtn = document.getElementById("copyBtn");
|
| 144 |
+
copyBtn.onclick = () => navigator.clipboard.writeText(link).then(() => alert("✅ Đã copy link phòng!"));
|
| 145 |
+
};
|
| 146 |
+
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
</body>
|
| 148 |
</html>
|