Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
Adding popup script
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsalesdeandrade committed Feb 12, 2024
1 parent 28105ff commit 419e6e7
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions layout/_layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,73 @@
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
</script>


<script src="https://form.jotform.com/static/feedback2.js" type="text/javascript"></script>
<script type="text/javascript">
checkCookie();
//Set cookie
function setCookie(cname, cvalue) {
document.cookie = cname + "=" + cvalue + "; ";
}
//Get cookie
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
//Check cookie is existing
function checkCookie() {
var user = getCookie("username");
if (user == "visited") {
/* What to do is the visitor is just returning (cookie already existing) */
} else {
// Function to call when the form is closed
function onFormClosed() {
// Set a flag in sessionStorage indicating the form has been closed
sessionStorage.setItem('formClosed', 'true');
}
setTimeout(function() {
// Check if the form was previously closed in the same session
if (sessionStorage.getItem('formClosed')) {
console.log('Form has been closed in this session. Not showing again.');
return; // Do not initialize or show the form
}
var JFL_240365058705355 = new JotformFeedback({
formId: '240365058705355',
base: 'https://form.jotform.com/',
windowTitle: 'Survey Example - Test',
backgroundColor: '#FFFFFF',
fontColor: '#FFFFFF',
type: 'false',
height: 800,
width: 700,
openOnLoad: true
// Assuming there's a way to hook into the form's close event
// onClose: onFormClosed // Hypothetical example; adjust based on actual API
});
// You would need to find a way to call onFormClosed when the form is actually closed.
// This might involve JotForm-specific callbacks or event listeners.
}, 8000); // Delay in milliseconds
setCookie("username", "visited");
}
}
</script>

</head>

<body itemscope itemtype="http://schema.org/WebPage"{% if theme.motion.enable %} class="use-motion"{% endif %}>
Expand Down

0 comments on commit 419e6e7

Please sign in to comment.