Update index.html
Browse files- index.html +49 -31
index.html
CHANGED
|
@@ -6,16 +6,13 @@
|
|
| 6 |
<title>Chat CVNSS4.0</title>
|
| 7 |
<style>
|
| 8 |
:root{
|
| 9 |
-
--primary:#1a73e8;
|
| 10 |
-
--
|
| 11 |
-
--
|
| 12 |
-
--ov-top:72px; /* ← chiều cao overlay che HEADER tlk.io (không che khung Join) */
|
| 13 |
-
--ov-right:260px; /* ← bề rộng overlay che CỘT PHẢI */
|
| 14 |
}
|
| 15 |
-
|
| 16 |
*{ box-sizing:border-box }
|
| 17 |
body{
|
| 18 |
-
margin:0; font-family:
|
| 19 |
background:var(--bg); color:var(--text);
|
| 20 |
display:flex; flex-direction:column; min-height:100vh;
|
| 21 |
}
|
|
@@ -48,38 +45,33 @@
|
|
| 48 |
display:inline-block; background:#eef3fd; color:#174ea6;
|
| 49 |
padding:6px 10px; border-radius:999px; font-size:14px; margin-bottom:10px;
|
| 50 |
}
|
| 51 |
-
|
| 52 |
.chat-wrap{ position:relative; border:1px solid #e3e6ea; border-radius:10px; overflow:hidden }
|
| 53 |
iframe{ width:100%; height:72vh; min-height:520px; border:0; background:#fff }
|
| 54 |
|
| 55 |
-
/*
|
| 56 |
-
- ov-top: chỉ che HEADER tlk.io (đám mây/title). pointer-events:none để không chặn click.
|
| 57 |
-
- ov-right: che cột phải (online, branding, patron).
|
| 58 |
-
- KHÔNG có ov-bottom để giữ ô nhập tin nhắn.
|
| 59 |
-
*/
|
| 60 |
.ov-top{
|
| 61 |
position:absolute; left:0; right:0; top:0;
|
| 62 |
-
height:var(--ov-top);
|
| 63 |
-
background:#fff; z-index:3; pointer-events:none;
|
| 64 |
box-shadow:0 8px 10px -10px rgba(0,0,0,.12);
|
| 65 |
-
transition:height .15s ease;
|
| 66 |
}
|
| 67 |
.ov-right{
|
| 68 |
position:absolute; top:0; right:0; bottom:0;
|
| 69 |
width:var(--ov-right); background:#fff; z-index:2; pointer-events:none;
|
| 70 |
box-shadow:-8px 0 10px -10px rgba(0,0,0,.12);
|
| 71 |
}
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
:root{ --ov-top:56px; --ov-right:200px; }
|
| 76 |
-
}
|
| 77 |
|
| 78 |
-
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
}
|
| 81 |
-
.
|
| 82 |
-
|
| 83 |
</style>
|
| 84 |
</head>
|
| 85 |
<body>
|
|
@@ -97,7 +89,7 @@
|
|
| 97 |
<button class="ghost" id="newRoomBtn">✨ Tạo phòng bí mật</button>
|
| 98 |
</div>
|
| 99 |
|
| 100 |
-
<div id="linkArea" class="links"
|
| 101 |
<span>🔗 Link phòng:</span>
|
| 102 |
<span id="roomUrl" class="link-badge mono"></span>
|
| 103 |
<button class="secondary" id="copyBtn">📋 Copy</button>
|
|
@@ -114,6 +106,8 @@
|
|
| 114 |
</div>
|
| 115 |
</section>
|
| 116 |
|
|
|
|
|
|
|
| 117 |
<footer>
|
| 118 |
Nguồn: Sản phẩm thử nghiệm của Team CVNSS4.0 • Đóng tab là xóa hết dữ liệu ✅
|
| 119 |
</footer>
|
|
@@ -125,28 +119,52 @@
|
|
| 125 |
const base = `${location.origin}${location.pathname}`;
|
| 126 |
document.getElementById("roomPill").textContent = "Phòng: " + room;
|
| 127 |
|
| 128 |
-
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
document.getElementById("joinBtn").onclick = () => {
|
| 130 |
const name = (document.getElementById("nickname").value || "").trim() || "Guest";
|
| 131 |
document.getElementById("login").style.display = "none";
|
| 132 |
document.getElementById("chat-box").style.display = "block";
|
| 133 |
-
|
| 134 |
const url = `https://tlk.io/${encodeURIComponent(room)}?nickname=${encodeURIComponent(name)}`;
|
| 135 |
document.getElementById("chatFrame").src = url;
|
| 136 |
};
|
| 137 |
|
| 138 |
-
// Tạo phòng bí mật
|
| 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 |
document.getElementById("roomPill").textContent = "Phòng: " + room;
|
| 145 |
-
|
| 146 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 147 |
|
|
|
|
| 148 |
const copyBtn = document.getElementById("copyBtn");
|
| 149 |
-
copyBtn.onclick =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
};
|
| 151 |
</script>
|
| 152 |
</body>
|
|
|
|
| 6 |
<title>Chat CVNSS4.0</title>
|
| 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 |
}
|
|
|
|
| 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>
|
|
|
|
| 89 |
<button class="ghost" id="newRoomBtn">✨ Tạo phòng bí mật</button>
|
| 90 |
</div>
|
| 91 |
|
| 92 |
+
<div id="linkArea" class="links">
|
| 93 |
<span>🔗 Link phòng:</span>
|
| 94 |
<span id="roomUrl" class="link-badge mono"></span>
|
| 95 |
<button class="secondary" id="copyBtn">📋 Copy</button>
|
|
|
|
| 106 |
</div>
|
| 107 |
</section>
|
| 108 |
|
| 109 |
+
<div id="toast" class="toast">Đã copy link phòng!</div>
|
| 110 |
+
|
| 111 |
<footer>
|
| 112 |
Nguồn: Sản phẩm thử nghiệm của Team CVNSS4.0 • Đóng tab là xóa hết dữ liệu ✅
|
| 113 |
</footer>
|
|
|
|
| 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";
|
| 133 |
document.getElementById("chat-box").style.display = "block";
|
|
|
|
| 134 |
const url = `https://tlk.io/${encodeURIComponent(room)}?nickname=${encodeURIComponent(name)}`;
|
| 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>
|
| 170 |
</body>
|