Major refactor. Add error handlers everywhere.

This commit is contained in:
Berkeley Martinez
2014-12-23 08:48:28 -08:00
parent e921b637cc
commit 86fcfe8296
18 changed files with 1431 additions and 1529 deletions

View File

@@ -1,40 +1,44 @@
$(document).ready(function() {
var CSRF_HEADER = 'X-CSRF-Token';
var CSRF_HEADER = 'X-CSRF-Token';
var setCSRFToken = function(securityToken) {
jQuery.ajaxPrefilter(function(options, _, xhr) {
if ( !xhr.crossDomain )
xhr.setRequestHeader(CSRF_HEADER, securityToken);
});
};
setCSRFToken($('meta[name="csrf-token"]').attr('content'));
$('.start-challenge').on("click", function() {
$(this).parent().remove();
$('.challenge-content').removeClass('hidden-element').addClass('animated fadeInDown');
var setCSRFToken = function(securityToken) {
jQuery.ajaxPrefilter(function(options, _, xhr) {
if (!xhr.crossDomain) {
xhr.setRequestHeader(CSRF_HEADER, securityToken);
}
});
};
$('.completed-challenge').on("click", function() {
$('#complete-dialog').modal('show');
l = location.pathname.split('/');
cn = l[l.length - 1]
console.log(cn);
$.ajax({
type: 'POST',
data: {challengeNumber: cn},
url: '/completed_challenge/'
});
});
setCSRFToken($('meta[name="csrf-token"]').attr('content'));
$('.skip-challenge').on("click", function() {
$('#skip-dialog').modal('show');
});
$('.start-challenge').on('click', function() {
$(this).parent().remove();
$('.challenge-content')
.removeClass('hidden-element')
.addClass('animated fadeInDown');
});
$('.next-button').on("click", function() {
l = location.pathname.split('/');
window.location = "/challenges/" + (parseInt(l[l.length-1]) + 1)
});
$('.completed-challenge').on('click', function() {
$('#complete-dialog').modal('show');
l = location.pathname.split('/');
cn = l[l.length - 1];
console.log(cn);
$.ajax({
type: 'POST',
data: {challengeNumber: cn},
url: '/completed_challenge/'
});
});
$('.skip-challenge').on('click', function() {
$('#skip-dialog').modal('show');
});
$('.next-button').on('click', function() {
l = location.pathname.split('/');
window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1);
});
});