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
parent
1e427d723c
commit
f6603aadae
2
app.js
2
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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue