2014-10-18 02:23:53 +00:00
|
|
|
$(document).ready(function() {
|
2014-11-07 06:47:35 +00:00
|
|
|
|
2014-12-23 16:48:28 +00:00
|
|
|
var CSRF_HEADER = 'X-CSRF-Token';
|
2014-11-07 06:47:35 +00:00
|
|
|
|
2014-12-23 16:48:28 +00:00
|
|
|
var setCSRFToken = function(securityToken) {
|
|
|
|
jQuery.ajaxPrefilter(function(options, _, xhr) {
|
|
|
|
if (!xhr.crossDomain) {
|
|
|
|
xhr.setRequestHeader(CSRF_HEADER, securityToken);
|
|
|
|
}
|
2014-11-07 01:38:47 +00:00
|
|
|
});
|
2014-12-23 16:48:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
setCSRFToken($('meta[name="csrf-token"]').attr('content'));
|
|
|
|
|
|
|
|
$('.start-challenge').on('click', function() {
|
|
|
|
$(this).parent().remove();
|
|
|
|
$('.challenge-content')
|
|
|
|
.removeClass('hidden-element')
|
|
|
|
.addClass('animated fadeInDown');
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.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);
|
|
|
|
});
|
2014-11-07 01:38:47 +00:00
|
|
|
});
|
|
|
|
|
2015-01-06 03:01:58 +00:00
|
|
|
var profileValidation = angular.module('profileValidation',[]);
|
2015-01-06 04:09:23 +00:00
|
|
|
profileValidation.controller('profileValidationController', ['$scope', '$http',
|
|
|
|
function($scope, $http) {
|
2015-01-06 05:52:30 +00:00
|
|
|
$http.get('/account/api').success(function(data) {
|
2015-01-06 04:09:23 +00:00
|
|
|
$scope.user = data.user;
|
2015-01-06 05:52:30 +00:00
|
|
|
console.log($scope.user);
|
2015-01-06 04:09:23 +00:00
|
|
|
});
|
2015-01-06 03:01:58 +00:00
|
|
|
}
|
|
|
|
]);
|