Skip to content

Commit

Permalink
add toggleUserInfoModal after 2 minutes on page
Browse files Browse the repository at this point in the history
  • Loading branch information
NUEXGUY committed Feb 20, 2024
1 parent 6291657 commit bff7dc6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<meta name="twitter:title" content="AgeWise - Chronic Pain Guide">
<meta name="twitter:description" content="AgeWise by Next Level PT: Empower your journey towards pain-free living with our AI-driven chatbot, offering personalized guidance and solutions for chronic pain management.">
<meta name="twitter:image" content="/favicon.svg">
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Kaushan+Script&family=Roboto+Condensed:wght@800&display=swap" rel="stylesheet">
Expand Down
20 changes: 12 additions & 8 deletions public/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const userInfoModal = document.querySelector('#userInfoModal')
const contactButton = document.querySelector('#contactButton')

// Toggle userInfoModal with overlay and disable/enable inputs
const toggleuserInfoModal = () => {
const toggleUserInfoModal = () => {
if (userInfoModal.style.visibility === 'hidden' || userInfoModal.style.visibility === '') {
userInfoModal.style.opacity = '1'
userInfoModal.style.visibility = 'visible'
Expand All @@ -36,7 +36,7 @@ const toggleuserInfoModal = () => {
}
}

contactButton.addEventListener('click', toggleuserInfoModal)
contactButton.addEventListener('click', toggleUserInfoModal)
document.addEventListener('click', (event) => {
const userInfoModalElement = document.querySelector('#userInfoModal')
if (!userInfoModalElement.contains(event.target) && userInfoModalIsOpen) {
Expand All @@ -49,27 +49,27 @@ let userInfoModalIsOpen = false
window.addEventListener('blur', () => {
if (!userInfoModalIsOpen) {
userInfoModalIsOpen = true
toggleuserInfoModal()
toggleUserInfoModal()
}
})

document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
if (!userInfoModalIsOpen) {
userInfoModalIsOpen = true
toggleuserInfoModal()
toggleUserInfoModal()
}
} else { /* empty */ }
})

document.querySelector('#cancelUserInfo').addEventListener('click', () => {
userInfoModalIsOpen = false
toggleuserInfoModal()
toggleUserInfoModal()
})

const closeuserInfoModal = () => {
userInfoModalIsOpen = false
toggleuserInfoModal()
toggleUserInfoModal()
}

// When user clicks #sendUserInfo create a new person object with collected information
Expand Down Expand Up @@ -240,7 +240,7 @@ document.addEventListener('mouseleave', () => {
setTimeout(() => {
mouseLeaveEnabled = true
}, 3 * 60 * 1000)
toggleuserInfoModal()
toggleUserInfoModal()
}
})

Expand All @@ -249,5 +249,9 @@ chatInput.addEventListener('focus', function () {
})

chatInput.addEventListener('blur', function () {
chatInput.placeholder = 'Start typing here...'
chatInput.placeholder = 'Type your message...'
})

document.addEventListener('DOMContentLoaded', function() {
setTimeout(toggleUserInfoModal, 120000);
});

0 comments on commit bff7dc6

Please sign in to comment.