Last active
February 13, 2018 15:27
-
-
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.
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( 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