Skip to content

Instantly share code, notes, and snippets.

@jgwhite
Created November 23, 2011 16:47
Show Gist options
  • Select an option

  • Save jgwhite/1389180 to your computer and use it in GitHub Desktop.

Select an option

Save jgwhite/1389180 to your computer and use it in GitHub Desktop.
Splash Page Logic
(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