28 lines
939 B
JavaScript
28 lines
939 B
JavaScript
// Check for saved session on page load
|
|
window.addEventListener("DOMContentLoaded", function () {
|
|
const savedToken = localStorage.getItem("chatToken");
|
|
const savedUsername = localStorage.getItem("chatUsername");
|
|
const savedPhone = localStorage.getItem("chatUserPhone");
|
|
|
|
if (savedToken && savedUsername) {
|
|
currentUserPhone = savedPhone;
|
|
validateToken(savedToken, savedUsername);
|
|
}
|
|
|
|
// Auto-resize textarea
|
|
const messageInput = document.getElementById("messageInput");
|
|
messageInput.addEventListener("input", function () {
|
|
this.style.height = "auto";
|
|
this.style.height = Math.min(this.scrollHeight, 100) + "px";
|
|
});
|
|
|
|
// Update mobile detection on resize
|
|
window.addEventListener("resize", function () {
|
|
isMobile = window.innerWidth <= 768;
|
|
if (!isMobile) {
|
|
// On desktop, ensure chats panel is visible
|
|
document.getElementById("chatsPanel").classList.remove("active");
|
|
}
|
|
});
|
|
});
|