Created
April 25, 2014 19:35
-
-
Save anunay/11300568 to your computer and use it in GitHub Desktop.
p80script
This file contains 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
jQuery(function(){ | |
/** | |
* Checking if cookie already exists, if so redirect to denied page. | |
*/ | |
if($.cookie("pro80denied")=="true"){ | |
location.href="denied/"; | |
} | |
jQuery('#make-my-app-btn').on('click',function(){ | |
/** | |
* Checking if all questions were anwered or not. | |
* If all question answered then the total number of answers must be 9. | |
*/ | |
if(jQuery(".css-checkbox:checked").size() != 9){ | |
jQuery('#error').fadeIn(); | |
jQuery("html, body").animate({ scrollTop: $('#error').offset().top }, 1000); | |
} | |
/** | |
* Iterate through the checkboxes and check for "no" values if any and | |
* drop a cookie if any answer set to "no" and redirect to denied page | |
*/ | |
jQuery(".css-checkbox:checked").each(function(){ | |
if(jQuery(this).val()=="no")){ | |
// droping cookie here | |
$.cookie("pro80denied", "true", { expires: 1000, path: '/' }); // expires in 1000 days :) | |
location.href = 'denied/'; | |
} | |
jQuery('.loader').fadeIn(); | |
jQuery.ajax({ | |
url: "handler/handler.php", | |
type: "POST", | |
data: { ten: ten }, // we only need to provide the textarea contents and no need to pass the answers. | |
success: function (res) { | |
location.href = 'invitation/0514'; | |
} | |
}); | |
}); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment