-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.js
More file actions
84 lines (70 loc) · 2.66 KB
/
Copy pathscript.js
File metadata and controls
84 lines (70 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
window.onscroll = function () {
scrollBar();
};
function scrollBar() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
document.getElementById("scrollBar").style.width = scrolled + "%";
}
// window.onload = function() {
// document.getElementById('popupBox').classList.add('show');
// document.getElementById('overlay').classList.add('show');
// };
window.onload = function () {
const chatButton = document.getElementById('chatToggle');
chatButton.classList.add('bouncing');
setTimeout(() => {
chatButton.classList.remove('bouncing');
}, 5000);
}
function closePopup() {
const popupBox = document.getElementById('popupBox');
const overlay = document.getElementById('overlay');
popupBox.classList.add('fade-out');
overlay.classList.add('fade-out');
setTimeout(() => {
popupBox.remove();
overlay.remove();
}, 500);
}
const chatToggle = document.getElementById('chatToggle');
const chatPopup = document.getElementById('chatPopup');
const chatBody = document.getElementById('chatBody');
const chatInput = document.getElementById('chatInput');
chatToggle.addEventListener('click', () => {
chatPopup.classList.toggle('show');
});
function closeChat() {
chatPopup.classList.remove('show');
}
function sendMessage() {
const message = chatInput.value.trim();
if (message !== '') {
const messageDiv = document.createElement('div');
messageDiv.classList.add('chat-message', 'user');
messageDiv.textContent = message;
chatBody.appendChild(messageDiv);
chatBody.scrollTop = chatBody.scrollHeight;
chatInput.value = '';
setTimeout(() => {
const botReply = document.createElement('div');
botReply.classList.add('chat-message', 'bot');
botReply.innerHTML = 'Thanks for reaching out! Our chat is currently in development.<br><br> Please email support at <a href="mailto:tetrisfans@omgame.club" class="email-link">tetrisfans@omgame.club</a> 😊';
chatBody.appendChild(botReply);
chatBody.scrollTop = chatBody.scrollHeight;
}, 1000);
}
}
chatInput.addEventListener("keypress", function (e) {
if (e.key === "Enter") {
sendMessage();
}
});
document.addEventListener("DOMContentLoaded", function() {
const loggedInUser = localStorage.getItem("loggedInUser");
const loginBtn = document.getElementById("login-btn");
if (loggedInUser) {
loginBtn.textContent = `User: ${loggedInUser}`;
}
});