Last active
March 9, 2023 20:09
-
-
Save mattvaru/e8ce2e90cd6bc46abf1a7e0166c93d93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script> | |
<script> | |
var Webflow = Webflow || []; | |
Webflow.push(function () { | |
let now; | |
let expire; | |
let permission = localStorage.getItem('wfPermission'); | |
let visitStamp = moment().format('YYYY-MM-DD'); | |
let getExpiry = localStorage.getItem('expiration'); | |
let comparison = moment(visitStamp).isBefore(getExpiry); | |
if (permission == 'TRUE' && comparison == true) { | |
$("#modal").hide(); | |
} | |
else { | |
$("#modal").show(); | |
} | |
$("#btnYes").click(function () { | |
now = moment().format('YYYY-MM-DD'); | |
expire = moment().add(30, 'days').calendar(); | |
expire = moment(expire).format('YYYY-MM-DD'); | |
localStorage.setItem('wfPermission', 'TRUE'); | |
localStorage.setItem('timestamp', now); | |
localStorage.setItem('expiration', expire); | |
}); | |
$("#btnNo").click(function () { | |
now = moment().format('YYYY-MM-DD'); | |
localStorage.setItem('wfPermission', 'FALSE'); | |
localStorage.setItem('timestamp', now); | |
$("#ageInfo").hide(); | |
$("#ageRestrict").show(); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment