closer to getting ajax to work

pull/2/head
Michael Q Larson 2014-11-06 17:38:47 -08:00
parent 944f4d6a1d
commit 86d433aaba
5 changed files with 71 additions and 56 deletions

10
app.js
View File

@ -165,6 +165,10 @@ app.post('/api/venmo', passportConf.isAuthenticated, passportConf.isAuthorized,
app.get('/api/linkedin', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getLinkedin);
app.get('/api/instagram', passportConf.isAuthenticated, passportConf.isAuthorized, apiController.getInstagram);
app.get('/api/yahoo', apiController.getYahoo);
app.post('/completed_challenge', function(req, res){
req.user.challengesCompleted.push(req)
console.log("pushed #{req} to user");
});
/**
* OAuth sign-in routes.
@ -212,9 +216,6 @@ app.get('/auth/venmo/callback', passport.authorize('venmo', { failureRedirect: '
res.redirect('/api/venmo');
});
/**
* 500 Error Handler.
*/
@ -229,4 +230,5 @@ app.listen(app.get('port'), function() {
console.log('Express server listening on port %d in %s mode', app.get('port'), app.get('env'));
});
module.exports = app;
module.exports = app;

View File

@ -142,8 +142,6 @@ exports.updateProgress = function(req, res) {
res.redirect('/account');
});
});
// challenge = req.params.challengeNumber;
// user.challengesCompleted
};

View File

@ -4,10 +4,27 @@ $(document).ready(function() {
$('.challenge-content').removeClass('hidden-element').addClass('animated fadeInDown');
});
$('.completed-challenge').on("click", function() {
// user.completedChallenges.push()
$('#complete-dialog').modal('show');
});
$('.skip-challenge').on("click", function() {
$('#skip-dialog').modal('show');
});
});
$('.complete-button').on("click", function() {
l = location.pathname.split('/');
$.ajax({
type: 'POST',
data: l,
url: '/completed_challenge',
success: function(data) {
console.log('success');
console.log(JSON.stringify(data));
}
});
window.location = "/challenge?=" + (parseInt(l[l.length-1]) + 1)
});
$('.skip-button').on("click", function() {
l = location.pathname.split;
window.location = "/challenges/" + (parseInt(l[l.length-1]) + 1)
});
});

View File

@ -1,47 +0,0 @@
.panel.panel-primary
.panel-heading Challenge: #{name}
.panel.panel-body
.challenge-brief
h3.text-center
span.ion-android-clock
span Takes about #{time}
.btn.btn-success.btn-large.btn-block.start-challenge Start the challenge
.challenge-content.hidden-element
.responsive-container
iframe(src='//player.vimeo.com/video/#{video}', frameborder='0', webkitallowfullscreen='', mozallowfullscreen='', allowfullscreen='')
h3 Steps:
h4
ol
for step in steps
li!= step
.btn.btn-success.btn-large.btn-block.completed-challenge I've completed this challenge
.ten-pixel-break
.btn.btn-primary.btn-large.btn-block.completed-challenge.skip-challenge I want to skip this challenge for now
.panel-footer.text-center
span Need a break?  
a(href="http://blog.freecodecamp.com", target="_blank") Check out our blog
|   and  
a(href="https://twitter.com/freecodecamp", target="_blank") our recent tweets
| .
#complete-dialog.modal
.modal-dialog.animated.zoomIn.fast-animation
.modal-content
.modal-header
a.close(href='#', data-dismiss='modal', aria-hidden='true') ×
.text-center
h1.animated.zoomInDown Nicely done!
.animated.zoomInUp.delay-1
span.landing-icon.ion-checkmark-circled.text-success
a.animated.fadeIn.delay-2.btn.btn-primary.btn-block(href=next, aria-hidden='true') Take me to my next challenge
#skip-dialog.modal
.modal-dialog.animated.zoomIn.fast-animation
.modal-content
.modal-header
a.close(href='#', data-dismiss='modal', aria-hidden='true') ×
.text-center
h1.animated.zoomInDown No problem.
h2.animated.zoomInDown You can retry this challenge any time.
.animated.zoomInUp.delay-1
span.landing-icon.ion-skip-forward.text-primary
a.animated.fadeIn.delay-2.btn.btn-primary.btn-block(href=next, aria-hidden='true') Take me to my next challenge

View File

@ -2,6 +2,51 @@ extends ../layout
block content
.row
.col-sm-12.col-md-8.col-xs-12
include partials/challenge
.panel.panel-primary
.panel-heading Challenge: #{name}
.panel.panel-body
.challenge-brief
h3.text-center
span.ion-android-clock
span Takes about #{time}
.btn.btn-success.btn-large.btn-block.start-challenge Start the challenge
.challenge-content.hidden-element
.responsive-container
iframe(src='//player.vimeo.com/video/#{video}', frameborder='0', webkitallowfullscreen='', mozallowfullscreen='', allowfullscreen='')
h3 Steps:
h4
ol
for step in steps
li!= step
.btn.btn-success.btn-large.btn-block.completed-challenge I've completed this challenge
.ten-pixel-break
.btn.btn-primary.btn-large.btn-block.completed-challenge.skip-challenge I want to skip this challenge for now
.panel-footer.text-center
span Need a break?  
a(href="http://blog.freecodecamp.com", target="_blank") Check out our blog
|   and  
a(href="https://twitter.com/freecodecamp", target="_blank") our recent tweets
| .
#complete-dialog.modal
.modal-dialog.animated.zoomIn.fast-animation
.modal-content
.modal-header
a.close(href='#', data-dismiss='modal', aria-hidden='true') ×
.text-center
h1.animated.zoomInDown Nicely done!
.animated.zoomInUp.delay-1
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
#skip-dialog.modal
.modal-dialog.animated.zoomIn.fast-animation
.modal-content
.modal-header
a.close(href='#', data-dismiss='modal', aria-hidden='true') ×
.text-center
h1.animated.zoomInDown No problem.
h2.animated.zoomInDown You can retry this challenge any time.
.animated.zoomInUp.delay-1
span.landing-icon.ion-skip-forward.text-primary
a.animated.fadeIn.delay-2.btn.btn-primary.btn-block.skip-button(aria-hidden='true') Take me to my next challenge
.col-sm-12.col-md-4.col-xs-12
include ../partials/challenges