diff --git a/controllers/courseware.js b/controllers/courseware.js index 94d651467c..2cf3390d46 100644 --- a/controllers/courseware.js +++ b/controllers/courseware.js @@ -44,12 +44,12 @@ exports.returnNextCourseware = function(req, res) { if (err) { next(err); } - debug('This is the courseware object returned from mongo', courseware); + courseware = courseware.pop(); if (courseware === undefined) { req.flash('errors', { msg: "It looks like you've completed all the courses we have available. Good job!" - }) + }); return res.redirect('../coursewares/start-our-challenges'); } nameString = courseware.name.toLowerCase().replace(/\s/g, '-'); diff --git a/public/js/main.js b/public/js/main.js index d9162a53c9..c8b4d39d7a 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -66,7 +66,7 @@ $(document).ready(function() { completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash); }); - $('#completed-courseware').on('click', function() { + $('#complete-courseware').on('click', function() { $('#complete-courseware-dialog').modal('show'); }); diff --git a/views/coursewares/showHTML.jade b/views/coursewares/showHTML.jade index b54649a318..cb884bf531 100644 --- a/views/coursewares/showHTML.jade +++ b/views/coursewares/showHTML.jade @@ -45,7 +45,7 @@ block content .btn.btn-info#showAllCoursewares - if (cc) - a.btn.btn-primary.btn-lg.btn-block#next-courseware-button + a.btn.btn-primary.btn-lg.btn-block#complete-courseware | Go to my next challenge br | (ctrl + enter) @@ -68,29 +68,40 @@ block content var challengeName = !{JSON.stringify(name)}; var prodOrDev = !{JSON.stringify(environment)}; var started = Math.floor(Date.now() / 1000); + var url = ''; + var dashed = !{JSON.stringify(dashedName)}; + console.log(dashed); + .col-xs-12.col-sm-12.col-md-5.col-lg-6 #mainEditorPanel form.code .form-group.codeMirrorView textarea#codeEditor(autofocus=true) + script(src='/js/lib/coursewares/coursewaresHCJQFramework_v0.1.1.js') .col-md-4.col-lg-3 .hidden-xs.hidden-sm img.iphone-position(src="https://s3.amazonaws.com/freecodecamp/iphone6-frame.png") iframe.iphone#preview + #complete-courseware-dialog.modal(tabindex='-1') + .modal-dialog.animated.zoomIn.fast-animation + .modal-content + .modal-header.challenge-list-header= compliment + a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × + .modal-body + .text-center + .animated.zoomInDown.delay-half + span.completion-icon.ion-checkmark-circled.text-primary + - if (cc) - #complete-courseware-dialog.modal(tabindex='-1') - .modal-dialog.animated.zoomIn.fast-animation - .modal-content - .modal-header.challenge-list-header - = compliment - a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × - .modal-body - .text-center - .animated.zoomInDown.delay-half - span.completion-icon.ion-checkmark-circled.text-primary - a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress - script(src="/js/lib/coursewares/coursewaresHCJQFramework_v0.1.1.js") + a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next challenge (ctrl + enter) + - if (points && points > 2) + a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank") + i.fa.fa-twitter   + = phrase + + - else + a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress #all-coursewares-dialog.modal(tabindex='-1') .modal-dialog.animated.fadeInUp.fast-animation @@ -99,3 +110,14 @@ block content a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × .modal-body include ../partials/coursewares + script. + $.ajax({ + url: 'https://api-ssl.bitly.com/v3/shorten?access_token=75e7931a19befaafcf108021b6d597e554b2c5c3&longUrl=http%3A%2F%2Ffreecodecamp.com%2Fchallenges%2F' + dashed + '&format=txt' + }) + .success( + function(data) { + console.log(data); + url = "https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Challenge:%20#{name}&url=" + data + "&hashtags=LearnToCode, JavaScript"; + $('.btn-twitter').attr('href', url); + } + ); diff --git a/views/coursewares/showVideo.jade b/views/coursewares/showVideo.jade index 88099ddc42..764d3b47de 100644 --- a/views/coursewares/showVideo.jade +++ b/views/coursewares/showVideo.jade @@ -13,7 +13,7 @@ block content iframe.embed-responsive-item(src='//player.vimeo.com/video/#{video}') br - if (cc) - a.btn.btn-primary.btn-lg.btn-block#next-courseware-button Go to my next challenge (ctrl + enter) + a.btn.btn-primary.btn-lg.btn-block#completed-courseware I've completed this challenge (ctrl + enter) script. var userLoggedIn = true; - else @@ -36,7 +36,7 @@ block content .animated.zoomInDown.delay-half span.completion-icon.ion-checkmark-circled.text-primary - if (cc) - a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next challenge (ctrl + enter) + a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next challenge (ctrl + enter) - if (points && points > 2) a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/bonfires/#{dashedName}&hashtags=LearnToCode, JavaScript" target="_blank") i.fa.fa-twitter   @@ -44,6 +44,6 @@ block content - else a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress h1 #{name} - script. - var challengeName = !{JSON.stringify(name)}; - var passedCoursewareHash = !{JSON.stringify(coursewareHash)}; \ No newline at end of file + script. + var challengeName = !{JSON.stringify(name)}; + var passedCoursewareHash = !{JSON.stringify(coursewareHash)}; \ No newline at end of file