Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSL #319

Open
wants to merge 296 commits into
base: main
Choose a base branch
from
Open

MSL #319

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
296 commits
Select commit Hold shift + click to select a range
f2395ae
asd
MYSMARTLIFECA Nov 24, 2023
fffb4a7
asdad
MYSMARTLIFECA Nov 24, 2023
987df17
asd
MYSMARTLIFECA Nov 24, 2023
c2f57cf
asd
MYSMARTLIFECA Nov 24, 2023
aae6f5e
ASDDAD
MYSMARTLIFECA Nov 25, 2023
7a84a05
asd
MYSMARTLIFECA Nov 25, 2023
9770768
asdasd
MYSMARTLIFECA Nov 25, 2023
f20aadf
asd
MYSMARTLIFECA Nov 25, 2023
c02a4f1
asd
MYSMARTLIFECA Nov 25, 2023
7fcfa70
asd
MYSMARTLIFECA Nov 26, 2023
ace4e16
asd
MYSMARTLIFECA Nov 28, 2023
23fcf19
asd
MYSMARTLIFECA Dec 3, 2023
414fdfa
D
MYSMARTLIFECA Dec 3, 2023
88a6472
asd
MYSMARTLIFECA Dec 3, 2023
510c765
asdasd
MYSMARTLIFECA Dec 4, 2023
8519d08
asdad
MYSMARTLIFECA Dec 4, 2023
bdbaccb
qwd
MYSMARTLIFECA Dec 5, 2023
74cb4af
asd
MYSMARTLIFECA Dec 6, 2023
01be313
asd
MYSMARTLIFECA Dec 6, 2023
3733c8f
asd
MYSMARTLIFECA Dec 6, 2023
107ae54
asdasd
MYSMARTLIFECA Dec 6, 2023
3baf219
asd
MYSMARTLIFECA Dec 7, 2023
5585950
s
MYSMARTLIFECA Dec 7, 2023
d4c5f6b
asdasd
MYSMARTLIFECA Dec 7, 2023
7e6b50f
asd
MYSMARTLIFECA Dec 7, 2023
86e4abe
asd
MYSMARTLIFECA Dec 7, 2023
dc16145
sss
MYSMARTLIFECA Dec 7, 2023
3995d06
asd
MYSMARTLIFECA Dec 7, 2023
ec4d80a
asd
MYSMARTLIFECA Dec 7, 2023
e85ecbb
asd
MYSMARTLIFECA Dec 7, 2023
50e044c
sd
MYSMARTLIFECA Dec 7, 2023
a39fedf
ASD
MYSMARTLIFECA Dec 7, 2023
70cae8b
s
MYSMARTLIFECA Dec 7, 2023
d4c4847
asd
MYSMARTLIFECA Dec 7, 2023
4b487e9
set up action
MYSMARTLIFECA Dec 7, 2023
d6ac133
asd
MYSMARTLIFECA Dec 19, 2023
c1174b8
asd
MYSMARTLIFECA Dec 20, 2023
98cdc53
asd
MYSMARTLIFECA Dec 20, 2023
b6b296f
asd
MYSMARTLIFECA Dec 20, 2023
15c4615
asd
MYSMARTLIFECA Dec 20, 2023
7b8eb18
asdasd
MYSMARTLIFECA Dec 20, 2023
69525d5
asd
MYSMARTLIFECA Dec 20, 2023
604b8c7
asd
MYSMARTLIFECA Dec 20, 2023
d0cc182
asdasd
MYSMARTLIFECA Dec 20, 2023
44b3d99
d
MYSMARTLIFECA Dec 20, 2023
9827bce
qwd
MYSMARTLIFECA Dec 20, 2023
1e05972
qwd
MYSMARTLIFECA Dec 20, 2023
331245d
yew
MYSMARTLIFECA Dec 20, 2023
f376d4f
asd
MYSMARTLIFECA Dec 21, 2023
cc95638
asd
MYSMARTLIFECA Dec 21, 2023
e0c42bd
ASDASD
MYSMARTLIFECA Dec 21, 2023
333326e
asd
MYSMARTLIFECA Dec 22, 2023
1101ceb
asd
MYSMARTLIFECA Dec 23, 2023
af6b109
asd
MYSMARTLIFECA Dec 24, 2023
000ef56
asADSdsad
MYSMARTLIFECA Dec 25, 2023
559386d
asdasd
MYSMARTLIFECA Dec 25, 2023
b6d51a9
asd
MYSMARTLIFECA Dec 25, 2023
9a0d8f7
asdasd
MYSMARTLIFECA Dec 25, 2023
c1aeeb8
wd
MYSMARTLIFECA Dec 25, 2023
e20ab2c
sadads
MYSMARTLIFECA Dec 25, 2023
335472d
asdasd
MYSMARTLIFECA Dec 25, 2023
55b1c53
asdasd
MYSMARTLIFECA Dec 25, 2023
e588fdd
asdads
MYSMARTLIFECA Dec 25, 2023
1d68b7c
asd
MYSMARTLIFECA Dec 25, 2023
c9e8f35
asd
MYSMARTLIFECA Dec 27, 2023
dc5bddb
asd
MYSMARTLIFECA Dec 27, 2023
dbcfa76
wqd
MYSMARTLIFECA Dec 27, 2023
4d79498
vfv
MYSMARTLIFECA Dec 27, 2023
b5a41c9
vfvasd
MYSMARTLIFECA Dec 27, 2023
0c308dc
sd
MYSMARTLIFECA Dec 27, 2023
a48d90e
asdad
MYSMARTLIFECA Dec 27, 2023
37f4462
dsf
MYSMARTLIFECA Dec 27, 2023
78f4a2d
asd
MYSMARTLIFECA Dec 27, 2023
cd2aa65
ads
MYSMARTLIFECA Dec 27, 2023
84b3007
wef
MYSMARTLIFECA Dec 28, 2023
164bc1b
asd
MYSMARTLIFECA Dec 28, 2023
e027d99
asd
MYSMARTLIFECA Dec 28, 2023
2dc87d8
asd
MYSMARTLIFECA Dec 29, 2023
4d7f94f
asd
MYSMARTLIFECA Dec 29, 2023
3145fd2
d
MYSMARTLIFECA Dec 29, 2023
4798ebf
asd
MYSMARTLIFECA Dec 29, 2023
5d642a8
s
MYSMARTLIFECA Dec 29, 2023
11cac75
asd
MYSMARTLIFECA Dec 31, 2023
b9e4f42
asd
MYSMARTLIFECA Jan 1, 2024
97134c6
asd
MYSMARTLIFECA Jan 1, 2024
883bdac
asd
MYSMARTLIFECA Jan 3, 2024
fa807cf
asdasd
MYSMARTLIFECA Jan 3, 2024
b006172
asd
MYSMARTLIFECA Jan 3, 2024
246c4bb
asdasd
MYSMARTLIFECA Jan 3, 2024
d0c1a61
asdad
MYSMARTLIFECA Jan 3, 2024
1fe452d
macos
MYSMARTLIFECA Jan 6, 2024
b1bf235
MSL
MYSMARTLIFECA Jan 6, 2024
94ea029
MSK
MYSMARTLIFECA Jan 6, 2024
adadd71
wedf
MYSMARTLIFECA Jan 6, 2024
b62e3d0
wd
MYSMARTLIFECA Jan 7, 2024
eb2a2ac
asd
MYSMARTLIFECA Jan 7, 2024
39e536b
e
MYSMARTLIFECA Jan 7, 2024
501f73e
e
MYSMARTLIFECA Jan 7, 2024
b5993ff
ewd
MYSMARTLIFECA Jan 7, 2024
4da2768
e
MYSMARTLIFECA Jan 7, 2024
00b9567
sc
MYSMARTLIFECA Jan 8, 2024
bc1f025
ef
MYSMARTLIFECA Jan 8, 2024
23ffafd
dsf
MYSMARTLIFECA Jan 8, 2024
90a3f5d
d
MYSMARTLIFECA Jan 9, 2024
1ecef8f
d
MYSMARTLIFECA Jan 9, 2024
53aad75
dd
MYSMARTLIFECA Jan 9, 2024
57517b0
ddd
MYSMARTLIFECA Jan 9, 2024
b8fe1b5
wqd
MYSMARTLIFECA Jan 9, 2024
b13fd1f
df
MYSMARTLIFECA Jan 9, 2024
bf44dbb
ewd
MYSMARTLIFECA Jan 9, 2024
887fda7
ed
MYSMARTLIFECA Jan 9, 2024
38289b7
f
MYSMARTLIFECA Jan 9, 2024
70653c8
e
MYSMARTLIFECA Jan 9, 2024
df954fa
s
MYSMARTLIFECA Jan 9, 2024
610f50d
dw
MYSMARTLIFECA Jan 9, 2024
d8d469e
wed
MYSMARTLIFECA Jan 9, 2024
2ccb1ea
ff
MYSMARTLIFECA Jan 9, 2024
55b382e
s
MYSMARTLIFECA Jan 9, 2024
79fd356
ws
MYSMARTLIFECA Jan 9, 2024
f9c3ad1
wd
MYSMARTLIFECA Jan 9, 2024
6db3321
sd
MYSMARTLIFECA Jan 9, 2024
4548f35
qwd
MYSMARTLIFECA Jan 9, 2024
bbc9849
asd
MYSMARTLIFECA Jan 9, 2024
337fcc6
sx
MYSMARTLIFECA Jan 9, 2024
46769ad
wqd
MYSMARTLIFECA Jan 9, 2024
e96ea55
s
MYSMARTLIFECA Jan 9, 2024
0695fd2
dqw
MYSMARTLIFECA Jan 9, 2024
96fd00c
wd
MYSMARTLIFECA Jan 9, 2024
8ce54d8
asd
MYSMARTLIFECA Jan 9, 2024
22a2ed3
dqd
MYSMARTLIFECA Jan 9, 2024
2ea511b
ss
MYSMARTLIFECA Jan 9, 2024
8eb9270
sd
MYSMARTLIFECA Jan 10, 2024
3d5b650
d
MYSMARTLIFECA Jan 10, 2024
ace0dc1
asd
MYSMARTLIFECA Jan 11, 2024
debce56
sd
MYSMARTLIFECA Jan 14, 2024
5e9d2ec
qwe
MYSMARTLIFECA Jan 14, 2024
a1e48f1
csd
MYSMARTLIFECA Jan 14, 2024
28c9e60
dd
MYSMARTLIFECA Jan 14, 2024
ee30215
sad
MYSMARTLIFECA Jan 14, 2024
293f95c
dwd
MYSMARTLIFECA Jan 14, 2024
6d44d78
asd
MYSMARTLIFECA Jan 14, 2024
38bc37c
sd
MYSMARTLIFECA Jan 14, 2024
d27d2bb
sc
MYSMARTLIFECA Jan 14, 2024
181ee61
s
MYSMARTLIFECA Jan 14, 2024
0d2a52a
wd
MYSMARTLIFECA Jan 14, 2024
271495c
asd
MYSMARTLIFECA Jan 14, 2024
f363370
asd
MYSMARTLIFECA Jan 14, 2024
37b1fd4
dd
MYSMARTLIFECA Mar 20, 2024
f3f9d9d
wd
MYSMARTLIFECA Apr 2, 2024
1f3c6f5
qwd
MYSMARTLIFECA Apr 8, 2024
9e937f3
wedwd
MYSMARTLIFECA Apr 9, 2024
bbf02cc
df
MYSMARTLIFECA Apr 9, 2024
7a75165
asd
MYSMARTLIFECA Apr 9, 2024
5d2849a
asd
MYSMARTLIFECA Apr 9, 2024
b6b18b2
wdwd
MYSMARTLIFECA Apr 10, 2024
0551bb0
ssd
MYSMARTLIFECA Apr 10, 2024
a46c9a0
wdwqd
MYSMARTLIFECA Apr 10, 2024
27055ff
wd
MYSMARTLIFECA Apr 12, 2024
525580a
we
MYSMARTLIFECA Apr 12, 2024
dad3a8d
qwdqd
MYSMARTLIFECA Apr 12, 2024
650fadc
asda
MYSMARTLIFECA Apr 12, 2024
6987a30
asd
MYSMARTLIFECA Apr 12, 2024
03f6e99
asd
MYSMARTLIFECA Apr 12, 2024
647f419
asd
MYSMARTLIFECA Apr 21, 2024
d6e9774
asd
MYSMARTLIFECA Apr 21, 2024
4c9eba1
qwd
MYSMARTLIFECA Apr 22, 2024
3876f4f
asd
MYSMARTLIFECA May 17, 2024
51e326a
ASD
MYSMARTLIFECA May 17, 2024
24c560e
asd
MYSMARTLIFECA May 17, 2024
2fbffdb
ASD
MYSMARTLIFECA May 17, 2024
19c6916
qwd
MYSMARTLIFECA May 21, 2024
2d3346a
asdasd
MYSMARTLIFECA May 22, 2024
e46ce2f
asd
MYSMARTLIFECA May 22, 2024
318d9e0
asd
MYSMARTLIFECA May 22, 2024
ff5f294
ASD
MYSMARTLIFECA May 24, 2024
236f2da
asd
MYSMARTLIFECA May 25, 2024
0531999
asd
MYSMARTLIFECA May 25, 2024
782d794
sd
MYSMARTLIFECA May 25, 2024
a757e13
asd
MYSMARTLIFECA May 25, 2024
591ee5f
aasd
MYSMARTLIFECA May 25, 2024
df393f9
asd
MYSMARTLIFECA May 25, 2024
bd731b1
ad
MYSMARTLIFECA May 27, 2024
0a65331
asdasd
MYSMARTLIFECA May 27, 2024
44c4fc2
asd
MYSMARTLIFECA May 31, 2024
d298c7e
asd
MYSMARTLIFECA May 31, 2024
191ec87
sdf
MYSMARTLIFECA Jun 1, 2024
ae2c0d5
asd
MYSMARTLIFECA Jun 1, 2024
134b5f0
dasd
MYSMARTLIFECA Jun 1, 2024
06bae9a
qwed
MYSMARTLIFECA Jun 1, 2024
ee3f495
asd
MYSMARTLIFECA Jun 2, 2024
8918b82
asdasd
MYSMARTLIFECA Jun 2, 2024
717f53c
asd
MYSMARTLIFECA Jun 2, 2024
15ba1e0
dsa
MYSMARTLIFECA Jun 5, 2024
2200578
asdd
MYSMARTLIFECA Jun 5, 2024
d0ce5eb
asd
MYSMARTLIFECA Jun 8, 2024
9d5ac67
asd
MYSMARTLIFECA Jun 8, 2024
31c48a0
asdasd
MYSMARTLIFECA Jun 8, 2024
fdb7fad
asdasd
MYSMARTLIFECA Jun 8, 2024
45658fa
asd
MYSMARTLIFECA Jun 8, 2024
674e6f7
asd
MYSMARTLIFECA Jun 8, 2024
a89bda0
asd
MYSMARTLIFECA Jun 8, 2024
404d0d9
asd
MYSMARTLIFECA Jun 11, 2024
1aa6852
asdasd
MYSMARTLIFECA Jun 12, 2024
b4ea378
adasd
MYSMARTLIFECA Jun 13, 2024
eb2af52
asd
MYSMARTLIFECA Jun 14, 2024
ed97e1b
asdasd
MYSMARTLIFECA Jun 14, 2024
d157524
dasd
MYSMARTLIFECA Jun 15, 2024
5242c58
adsd
MYSMARTLIFECA Jun 15, 2024
7e1c533
asd
MYSMARTLIFECA Jun 15, 2024
d849c1c
sad
MYSMARTLIFECA Jun 18, 2024
ec67a01
sdsd
MYSMARTLIFECA Jun 18, 2024
be53f70
d
MYSMARTLIFECA Jun 18, 2024
ccee80a
sada
MYSMARTLIFECA Jun 20, 2024
efb737a
asd
MYSMARTLIFECA Jun 20, 2024
466e1dd
ss
MYSMARTLIFECA Jun 20, 2024
d0a44db
sd
MYSMARTLIFECA Jun 20, 2024
6058d62
asdds
MYSMARTLIFECA Jun 21, 2024
a6712ad
saddas
MYSMARTLIFECA Jun 21, 2024
e1d6ea6
asd
MYSMARTLIFECA Jun 21, 2024
996de32
asdasd
MYSMARTLIFECA Jun 21, 2024
37c2f2d
sadsad
MYSMARTLIFECA Jun 21, 2024
116f4d8
sax
MYSMARTLIFECA Jun 23, 2024
584a05d
sad
MYSMARTLIFECA Jun 23, 2024
e324e02
asdasdasd
MYSMARTLIFECA Jun 23, 2024
02ebbab
asdasd
MYSMARTLIFECA Jun 24, 2024
002f82e
dsdd
MYSMARTLIFECA Jun 27, 2024
11a15f4
sad
MYSMARTLIFECA Jun 27, 2024
268e477
faasdasd
MYSMARTLIFECA Jun 30, 2024
2153573
sadasd
MYSMARTLIFECA Jun 30, 2024
b7ba708
asda
MYSMARTLIFECA Jun 30, 2024
d358592
asdasd
MYSMARTLIFECA Jun 30, 2024
596e40d
ASD
MYSMARTLIFECA Jul 1, 2024
706e3b0
asd
MYSMARTLIFECA Jul 1, 2024
238f3e5
asdf
MYSMARTLIFECA Jul 2, 2024
00e3945
asd
MYSMARTLIFECA Jul 3, 2024
294a3d0
asdf
MYSMARTLIFECA Jul 3, 2024
17b4d40
asdf
MYSMARTLIFECA Jul 3, 2024
7df0a3e
ad
MYSMARTLIFECA Jul 4, 2024
8286449
asd
MYSMARTLIFECA Jul 4, 2024
c928442
a
MYSMARTLIFECA Jul 4, 2024
e7f5de2
a
MYSMARTLIFECA Jul 4, 2024
3462166
a
MYSMARTLIFECA Jul 4, 2024
fe31775
a
MYSMARTLIFECA Jul 4, 2024
ac12756
s
MYSMARTLIFECA Jul 4, 2024
362e153
a
MYSMARTLIFECA Jul 4, 2024
34f5984
s
MYSMARTLIFECA Jul 4, 2024
2a9fd70
s
MYSMARTLIFECA Jul 4, 2024
8fb9438
dsa
MYSMARTLIFECA Jul 4, 2024
b985088
as
MYSMARTLIFECA Jul 4, 2024
51eef9d
ds
MYSMARTLIFECA Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"main"
]
}
214 changes: 214 additions & 0 deletions MSL-WIDGET.JS
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
let isChatOpen = false;

function toggleChatContainer() {
const chatContainer = document.getElementById("chat-container");
chatContainer.style.display = isChatOpen ? "none" : "block";
isChatOpen = !isChatOpen;
}

function sendMessage() {
const userInput = document.getElementById("user-input").value.trim();
if (userInput === "") {
return;
}

displayMessage(userInput, "user");

// Simulate a delay before the chatbot responds (adjust the delay time if needed)
setTimeout(() => {
simulateBotTyping();
setTimeout(() => {
const response = generateResponse(userInput);
displayMessage(response, "bot");
hideBotTypingIndicator();
document.getElementById("user-input").value = ""; // Clear the input field

// Scroll to the bottom after a short delay
setTimeout(() => {
const chatMessages = document.getElementById("chat-messages");
chatMessages.scrollTop = chatMessages.scrollHeight;
}, 100); // Adjust the delay time if needed

}, 300); // Adjust the delay time for the typing effect
}, 300); // 1000 milliseconds (1 second) delay before the bot starts typing
}

function simulateBotTyping() {
const botTypingIndicator = document.createElement("div");
botTypingIndicator.textContent = "Bot is typing...";
botTypingIndicator.classList.add("bot", "typing-indicator");
const chatMessages = document.getElementById("chat-messages");
chatMessages.appendChild(botTypingIndicator);
chatMessages.scrollTop = chatMessages.scrollHeight;
}

function hideBotTypingIndicator() {
const botTypingIndicator = document.querySelector(".bot.typing-indicator");
if (botTypingIndicator) {
botTypingIndicator.remove();
}
}

function generateResponse(userQuery) {
const helpContent = {
'Privacy': { href: '/Privacy', answer: 'Your data will not be sold, exchanged, or disclosed to third parties unless it is required for order processing, shipping, or legal compliance.' },
'Affirm': { href: '/affirm', answer: 'Shop smarter with Affirm! Break down your purchase into four easy, interest-free payments. Enjoy flexibility, affordability, and freedom—all on minimum buys. Elevate your shopping game now!' },
'Eva': { answer: 'Yes! that\'s me' },
'art wall': { href: '/category/art-wall', answer: 'Our art wall category includes a variety of beautiful artworks. Check it out!' },
'security': { href: '/category/security', answer: 'Explore our security category for advanced security solutions.' },
'headphones': { href: '/category/headphones', answer: 'Discover high-quality headphones for an immersive audio experience.' },
'self care': { href: '/category/self-care', answer: 'Take care of yourself with our self-care products. Browse the collection!' },
'electronics': { href: '/category/electronics', answer: 'Explore the latest electronics and gadgets in our electronics category.' },
'gaming': { href: '/category/gaming', answer: 'Level up your gaming experience with our gaming products. Check them out!' },
'all products': { href: '/products', answer: 'View all our products in one place. Find what you need!' },
'faq': { href: '/faq', answer: 'Visit our FAQ page for answers to commonly asked questions.' },
'shipping information': { href: '/shipping-infor', answer: 'Find detailed information about shipping on our shipping information page.' },
'refund & returns': { href: '/refund-policy', answer: 'Learn about our refund and returns policy. Your satisfaction is our priority!' },
'contact us': { href: '/contact', answer: 'Reach out to us! Contact our customer support for assistance.' },
'payment options': { href: '/payment-options', answer: 'Check out our flexible payment options for a convenient shopping experience.' },
'same day delivery': { href: '/same-day-delivery', answer: 'Experience same-day delivery on select products. Terms and conditions apply.' },
'track order': { href: '/track-shipment', answer: 'Track the status of your order with our easy-to-use tracking system.' },
'about us': { href: '/about-us', answer: 'Learn more about us and our commitment to providing quality products and services.' },
'privacy policy': { href: '/privacy', answer: 'Your privacy matters. Read our privacy policy for details on how we handle your information.' },
'cyber week': { answer: 'Celebrate Cyber Week with us! Enjoy special discounts on selected items and take advantage of free shipping on your order. Don’t miss out on these fantastic deals!' },
'up to 60% off': { answer: 'Enjoy discounts of up to 60% on selected items! This special offer is part of our Cyber Week celebration. Shop now and save big!' },
'free shipping': { answer: 'Exciting news! We\'re offering free shipping on all orders as part of our Cyber Week promotion. Don’t miss out – shop now!' },
'best sellers': { href: '/electronics', answer: 'Explore our best-selling products and find the most popular items among our customers.' },
'new arrivals': { href: '/products', answer: 'Discover the latest additions to our product catalog. Check out our new arrivals and stay updated with the trends.' },
'how to return an item': { href: '/refund-policy', answer: 'Need to return an item? Follow our simple return process to ensure a hassle-free return.' },
'order status': { href: '/track-shipement', answer: 'Check the current status of your order by visiting our order status page. Stay updated on your purchase!' },
'how to contact customer support': { href: '/contact', answer: 'Have a question or need assistance? Contact our customer support team, and we’ll be happy to help.' },
// Add more relevant keywords and their responses
// ...
'change shipping address': { href: '/shipping-infor', answer: 'To change your shipping address after placing an order, please contact our customer support at support@mysmartlife.ca as soon as possible. Changes may not be possible once the order is processed.' },
'international shipping': { answer: 'Yes, we offer international shipping to many countries. During the checkout process, you can select your country to see if we deliver to your location. Keep in mind that international shipping may have additional fees and longer delivery times.' },
'lost package': { answer: 'If you believe your package is lost or missing, please contact our customer support at support@mysmartlife.ca with your order details. We will initiate an investigation with the shipping carrier to locate your package and provide a resolution.' },
'delivery delays': { answer: 'Delivery delays may occur due to factors such as weather conditions, customs processing, or other unforeseen circumstances. If you experience a significant delay, please contact our customer support for assistance.' },
'order late': { answer: "We understand the anticipation of tracking your order. Some tracking numbers may take a bit of time to update due to logistical processes. We want to assure you that everything is under control. Kindly be patient during this process. Your order is safe with us, and we're working diligently to provide accurate updates." },
'tracking delay': { answer: "If your order tracking is delayed, don't worry! Tracking numbers may take some time to update due to logistical processes. We assure you that your order is safe, and we're working diligently to provide accurate updates. Thank you for your patience." },
'hey': { answer: 'Hello! How can I assist you today?' },
'hi': { answer: 'Hi there! How can I help you?' },
'hello': { answer: 'Hello! Welcome, how may I assist you?' },
'need help': { answer: "Absolutely! I'm here to help. What do you need assistance with?" },
'by': { answer: 'Goodbye! If you have any more questions, feel free to ask.' },
'see you': { answer: 'See you later! If you need further assistance, don’t hesitate to reach out.' },
'later': { answer: 'Goodbye for now! If you have more questions later, feel free to come back.' },
'thank you': { answer: "You're welcome! If you need anything else, feel free to ask." },
};

let bestMatch = null;
let bestScore = 0;

for (const [keyword, data] of Object.entries(helpContent)) {
// Check if the keyword is a non-empty string
if (typeof keyword === 'string' && keyword.trim() !== '') {
const score = getScore(userQuery, keyword);
if (score > bestScore) {
bestMatch = { keyword, data, score };
bestScore = score;
}
}
}

if (bestMatch) {
// Add a threshold to ensure the match is relevant enough
if (bestScore >= 0.5) {
const { data } = bestMatch;
const { href, answer } = data;
let linkMessage = '';

if (href) {
linkMessage = `Please follow this <a style="color:red;" href="${href}" target="_blank">link</a>.`;
}

return `${answer} ${linkMessage}`;
} else {
// If the score is below a certain threshold, consider it not relevant enough
return "I'm sorry, I couldn't find information related to your query. Please try asking in a different way or check our FAQ for more assistance.";
}
} else {
return "I'm sorry, I couldn't find information related to your query. Please try asking in a different way or check our FAQ for more assistance.";
}
}

function getScore(userInput, keyword) {
const queryWords = userInput.split(/\s+/);
const matchCount = queryWords.filter(word => new RegExp(`\\b${word}\\b`, 'i').test(keyword)).length;
return matchCount;
}

function displayMessage(message, sender) {
const chatContainer = document.getElementById("chat-container");
const chatMessages = chatContainer.querySelector("#chat-messages");

const messageContainer = document.createElement("div");
messageContainer.classList.add("message-container", sender);

const messageDiv = document.createElement("div");
const timestamp = getTimestamp();
messageDiv.innerHTML = `<p>${message}</p><span class="message-time">${timestamp}</span>`;
messageDiv.classList.add("message");
messageContainer.appendChild(messageDiv);

chatMessages.appendChild(messageContainer);

// Use a short delay before scrolling to the bottom
setTimeout(() => {
const isTouchDevice = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;

if (isTouchDevice) {
chatContainer.scrollTo({
top: chatContainer.scrollHeight,
behavior: 'smooth'
});
} else {
chatContainer.scrollTop = chatContainer.scrollHeight;
}
}, 50); // Adjust the delay time if needed
}


// Add an event listener for the "keydown" event on the input field
document.getElementById("user-input").addEventListener("keydown", function (event) {
if (event.key === "Enter") {
sendMessage();
}
});

function getTimestamp() {
const now = new Date();
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
return `${hours}:${minutes}`;
}
// Function to show the welcome message
function showWelcomeMessage() {
const welcomeMessage = document.getElementById("welcome-message");
welcomeMessage.style.display = "block";
}

// Function to hide the welcome message
function hideWelcomeMessage() {
const welcomeMessage = document.getElementById("welcome-message");
welcomeMessage.style.display = "none";
}

// Initial check and show the welcome message if no messages are present
window.addEventListener("load", function () {
const chatMessages = document.getElementById("chat-messages");
if (chatMessages.children.length === 0) {
showWelcomeMessage();
}
});
// Add the handleButtonClick function
function handleButtonClick(keyword) {
const response = generateResponse(keyword);
displayMessage(response, "bot");
hideBotTypingIndicator();

// Scroll to the bottom after a short delay
setTimeout(() => {
const chatMessages = document.getElementById("chat-messages");
chatMessages.scrollTop = chatMessages.scrollHeight;
}, 100); // Adjust the delay time if needed
}
Loading