Skip to content

Instantly share code, notes, and snippets.

@neodigm
Last active February 13, 2018 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neodigm/0650754cb277ffd306c8e025f9e18f24 to your computer and use it in GitHub Desktop.
Save neodigm/0650754cb277ffd306c8e025f9e18f24 to your computer and use it in GitHub Desktop.
A quick and simple way to limit the amount of time a gh-pages prototype can be viewed.
(function( doc, dNow ){
var bOk = false;
var urlParams = new URLSearchParams( window.location.search );
if( urlParams.has( "token" ) ){
var sToken = urlParams.get( "token" );
var nDiff = ( dNow.getTime() - Number( sToken ) ) / 1000;
if( nDiff >= 3000 || isNaN( nDiff ) ){
bOk = false;
}else{
bOk = true;
}
}
if( !bOk ){
document.body.style.display = "none";
alert("Token Timeout, Please request a new token.");
}
})( document, new Date() );
// Type this into console var dX = new Date();console.log( dX.getTime() );
// Send link with the following at the end ?token=number from above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment