ajax seems to work and we now seem to track completion of challenges
This commit is contained in:
4
app.js
4
app.js
@ -166,8 +166,8 @@ app.get('/api/linkedin', passportConf.isAuthenticated, passportConf.isAuthorized
|
|||||||
app.get('/api/instagram', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getInstagram);
|
app.get('/api/instagram', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getInstagram);
|
||||||
app.get('/api/yahoo', apiController.getYahoo);
|
app.get('/api/yahoo', apiController.getYahoo);
|
||||||
app.post('/completed_challenge', function(req, res){
|
app.post('/completed_challenge', function(req, res){
|
||||||
req.user.challengesCompleted.push(req)
|
req.user.challengesCompleted.push(parseInt(req.body.cn));
|
||||||
console.log("pushed #{req} to user");
|
req.user.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,29 +1,46 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
|
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() {
|
$('.start-challenge').on("click", function() {
|
||||||
$(this).parent().remove();
|
$(this).parent().remove();
|
||||||
$('.challenge-content').removeClass('hidden-element').addClass('animated fadeInDown');
|
$('.challenge-content').removeClass('hidden-element').addClass('animated fadeInDown');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.completed-challenge').on("click", function() {
|
$('.completed-challenge').on("click", function() {
|
||||||
$('#complete-dialog').modal('show');
|
$('#complete-dialog').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.skip-challenge').on("click", function() {
|
$('.skip-challenge').on("click", function() {
|
||||||
$('#skip-dialog').modal('show');
|
$('#skip-dialog').modal('show');
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.complete-button').on("click", function() {
|
$('.complete-button').on("click", function() {
|
||||||
l = location.pathname.split('/');
|
l = location.pathname.split('/');
|
||||||
|
cn = l[l.length - 1]
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: l,
|
data: {cn: cn},
|
||||||
url: '/completed_challenge',
|
url: '/completed_challenge/',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
console.log('success');
|
console.log('success');
|
||||||
console.log(JSON.stringify(data));
|
console.log(JSON.stringify(data));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
window.location = "/challenge?=" + (parseInt(l[l.length-1]) + 1)
|
window.location = "/challenges/" + (parseInt(l[l.length-1]) + 1)
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.skip-button').on("click", function() {
|
$('.skip-button').on("click", function() {
|
||||||
l = location.pathname.split;
|
l = location.pathname.split('/');
|
||||||
window.location = "/challenges/" + (parseInt(l[l.length-1]) + 1)
|
window.location = "/challenges/" + (parseInt(l[l.length-1]) + 1)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -36,7 +36,7 @@ block content
|
|||||||
h1.animated.zoomInDown Nicely done!
|
h1.animated.zoomInDown Nicely done!
|
||||||
.animated.zoomInUp.delay-1
|
.animated.zoomInUp.delay-1
|
||||||
span.landing-icon.ion-checkmark-circled.text-success
|
span.landing-icon.ion-checkmark-circled.text-success
|
||||||
a.animated.fadeIn.delay-2.btn.btn-primary.btn-block.complete-button(aria-hidden='true') Take me to my next challenge
|
a.animated.fadeIn.delay-2.btn.btn-primary.btn-block.complete-button(name='_csrf', value=_csrf, aria-hidden='true') Take me to my next challenge
|
||||||
#skip-dialog.modal
|
#skip-dialog.modal
|
||||||
.modal-dialog.animated.zoomIn.fast-animation
|
.modal-dialog.animated.zoomIn.fast-animation
|
||||||
.modal-content
|
.modal-content
|
||||||
|
Reference in New Issue
Block a user