Skip to content

Instantly share code, notes, and snippets.

@deserat
Created December 2, 2010 21:26
Show Gist options
  • Save deserat/726102 to your computer and use it in GitHub Desktop.
Save deserat/726102 to your computer and use it in GitHub Desktop.
agegate code
$("div#submit").click( function(e) {
var today = new Date();
var now = today.getTime();
var age_limit = now - 410240038000;
var y = ( !isNaN(parseInt( $('#year_field').val() )) ) ? parseInt( $('#year_field').val() ) : 2010;
var m = ( !isNaN(parseInt( $('#month_field').val() )) ) ? parseInt( $('#month_field').val() ) -1 : 0 ;
var d = ( !isNaN(parseInt( $('#day_field').val() )) ) ? parseInt( $('#day_field').val() ) : 0;
var adate = new Date(y,m,d);
if( age_limit < adate.getTime() ) {
$.cookie("agegate_fail", "1", { expires: 1 });
$("#agegate_form").fadeOut('600', function() {$("#agegate_fail").fadeIn()});
} else {
$.cookie("agegate", "1");
var path = ("<?= $e->path ?>" != "" && "<?= $e->path ?>" != "/")? "/<?= $e->path ?>.html" : "<?= APP_URL ?>";
window.location.reload();
}
});
@deserat
Copy link
Author

deserat commented Dec 2, 2010

oh and for blocking them from reentering

        if ( $.cookie("agegate_fail") ) {
            $("div#agegate").fadeIn(600,function() {$("#agegate_fail").fadeIn(600)});
        } else {
            $("div#agegate").fadeIn(600,function() {$("div#agegate_form").fadeIn(600)});
        } 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment