diff --git a/app.js b/app.js index abd6f221d8..b3008507bd 100644 --- a/app.js +++ b/app.js @@ -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; \ No newline at end of file +module.exports = app; + diff --git a/controllers/user.js b/controllers/user.js index 3b2ff74a2e..e45bb041c4 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -142,8 +142,6 @@ exports.updateProgress = function(req, res) { res.redirect('/account'); }); }); -// challenge = req.params.challengeNumber; -// user.challengesCompleted }; diff --git a/public/js/main.js b/public/js/main.js index 898f8aa16b..f9842d3769 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -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'); }); -}); \ No newline at end of file + $('.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) + }); +}); + diff --git a/views/challenges/partials/challenge.jade b/views/challenges/partials/challenge.jade deleted file mode 100644 index 249ab6ca6b..0000000000 --- a/views/challenges/partials/challenge.jade +++ /dev/null @@ -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 \ No newline at end of file diff --git a/views/challenges/show.jade b/views/challenges/show.jade index 04b1fe2cd7..a77082833b 100644 --- a/views/challenges/show.jade +++ b/views/challenges/show.jade @@ -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 \ No newline at end of file