From f6603aadaeaa2edc7d981acb16f5f91846a86ce0 Mon Sep 17 00:00:00 2001 From: Michael Q Larson Date: Sun, 18 Jan 2015 13:34:45 -0800 Subject: [PATCH] work with @brndnb to improve usability of completion modals and write client-side jquery to prevent post if user isn't authenticated, which fixes a javascript error we were experiencing on serverside --- app.js | 2 +- public/css/main.less | 5 ++++- public/js/main.js | 18 ++++++++++-------- views/challenges/show.jade | 8 ++++---- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/app.js b/app.js index 3226a912d5..39e8730450 100644 --- a/app.js +++ b/app.js @@ -271,7 +271,7 @@ app.get('/account/unlink/:provider', userController.getOauthUnlink); * and updates user.challengesHash & user.challengesCompleted * */ -app.post('/completed_challenge', function (req, res) { +app.post('/completed-challenge', function (req, res) { req.user.challengesHash[parseInt(req.body.challengeNumber)] = Math.round(+new Date() / 1000); var ch = req.user.challengesHash; diff --git a/public/css/main.less b/public/css/main.less index b08506fd15..2265e963a5 100644 --- a/public/css/main.less +++ b/public/css/main.less @@ -5,6 +5,7 @@ @import url(http://fonts.googleapis.com/css?family=Lato:300); @import url(http://fonts.googleapis.com/css?family=Lato:400); +@import url(http://fonts.googleapis.com/css?family=Inconsolata); html,body,div,span,a,li,td,th { font-family: 'Lato', sans-serif; @@ -525,8 +526,10 @@ thead { } } -form.code { +.codeMirrorView { font-size: 22px; + font-family: 'Inconsolata', monospace; + font-weight: 300; } //uncomment this to see the dimensions of all elements outlined in red diff --git a/public/js/main.js b/public/js/main.js index 056b7f1ad8..ced2575987 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -21,14 +21,16 @@ $(document).ready(function() { $('.completed-challenge').on('click', function() { $('#complete-dialog').modal('show'); - - l = location.pathname.split('/'); - cn = l[l.length - 1]; - $.ajax({ - type: 'POST', - data: {challengeNumber: cn}, - url: '/completed_challenge/' - }); + // Only post to server if there is an authenticated user + if ($('.signup-btn-nav').length < 1) { + l = location.pathname.split('/'); + cn = l[l.length - 1]; + $.ajax({ + type: 'POST', + data: {challengeNumber: cn}, + url: '/completed-challenge/' + }); + } }); $('.all-challenges').on('click', function() { diff --git a/views/challenges/show.jade b/views/challenges/show.jade index 9e8e567d28..36d9dc8e0d 100644 --- a/views/challenges/show.jade +++ b/views/challenges/show.jade @@ -23,16 +23,16 @@ block content a.close.closing-x(href='#', data-dismiss='modal', aria-hidden='true') × .modal-body .text-center - .animated.zoomInUp.delay-half + .animated.zoomInDown.delay-half span.landing-icon.ion-checkmark-circled.text-primary - if (cc) - a.animated.fadeIn.delay-1.btn.btn-lg.btn-primary.btn-block.next-button(name='_csrf', value=_csrf, aria-hidden='true') Take me to my next challenge + a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-button(name='_csrf', value=_csrf, aria-hidden='true') Take me to my next challenge - if (points && points > 2) - a.animated.fadeIn.delay-1.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20Free%20Code%20Camp%20Challenge%20%23#{number}:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{number}&hashtags=learntocode, javascript" target="_blank") + a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20Free%20Code%20Camp%20Challenge%20%23#{number}:%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{number}&hashtags=learntocode, javascript" target="_blank") i.fa.fa-twitter   = phrase - else - a.animated.fadeIn.delay-1.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress + a.animated.fadeIn.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress #all-challenges-dialog.modal(tabindex='-1') .modal-dialog.animated.fadeInUp.fast-animation .modal-content