Created
November 23, 2011 16:47
-
-
Save jgwhite/1389180 to your computer and use it in GitHub Desktop.
Splash Page Logic
This file contains hidden or 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
| (function() { | |
| function isHome() { | |
| return window.location.pathname === '/'; | |
| } | |
| function isSplash() { | |
| return window.location.pathname === '/splash'; | |
| } | |
| function splashed() { | |
| return document.cookie.match(/splashed=yes/) !== null; | |
| } | |
| function notSplashed() { | |
| return !splashed(); | |
| } | |
| function splash() { | |
| window.location = '/splash'; | |
| } | |
| function saveSplashCookie() { | |
| var length = 28 * 24 * 60 * 60 * 1000, | |
| expiry = new Date(new Date().getTime() + length); | |
| document.cookie = [ | |
| 'splashed=yes', | |
| 'expires=' + expiry.toGMTString(), | |
| 'path=/' | |
| ].join('; '); | |
| } | |
| if (isHome() && notSplashed()) { | |
| splash(); | |
| } else { | |
| saveSplashCookie(); | |
| } | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment