Add .editorconfig to enforce certain automatic behavior on all editors,
Add logic for ziplines and basejumps completion.
This commit is contained in:
15
.editorconfig
Normal file
15
.editorconfig
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[package.json]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
2
app.js
2
app.js
@ -438,6 +438,8 @@ app.get(
|
|||||||
coursewareController.returnIndividualCourseware
|
coursewareController.returnIndividualCourseware
|
||||||
);
|
);
|
||||||
app.post('/completed-courseware/', coursewareController.completedCourseware);
|
app.post('/completed-courseware/', coursewareController.completedCourseware);
|
||||||
|
app.post('/completed-zipline-or-basejump',
|
||||||
|
coursewareController.completedZiplineOrBasejump);
|
||||||
|
|
||||||
// Unique Check API route
|
// Unique Check API route
|
||||||
app.get('/api/checkUniqueUsername/:username', userController.checkUniqueUsername);
|
app.get('/api/checkUniqueUsername/:username', userController.checkUniqueUsername);
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
var _ = require('lodash'),
|
var _ = require('lodash'),
|
||||||
<<<<<<< HEAD
|
|
||||||
debug = require('debug')('freecc:cntr:bonfires'),
|
debug = require('debug')('freecc:cntr:bonfires'),
|
||||||
Bonfire = require('./../models/Bonfire'),
|
Bonfire = require('./../models/Bonfire'),
|
||||||
User = require('./../models/User'),
|
User = require('./../models/User'),
|
||||||
resources = require('./resources'),
|
resources = require('./resources'),
|
||||||
R = require('ramda');
|
MDNlinks = require('./../seed_data/bonfireMDNlinks');
|
||||||
=======
|
|
||||||
debug = require('debug')('freecc:cntr:bonfires'),
|
|
||||||
Bonfire = require('./../models/Bonfire'),
|
|
||||||
User = require('./../models/User'),
|
|
||||||
resources = require('./resources'),
|
|
||||||
MDNlinks = require('./../seed_data/bonfireMDNlinks');
|
|
||||||
>>>>>>> upstream/master
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bonfire controller
|
* Bonfire controller
|
||||||
@ -103,34 +95,11 @@ exports.returnIndividualBonfire = function(req, res, next) {
|
|||||||
return res.redirect('/bonfires');
|
return res.redirect('/bonfires');
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
bonfire = bonfire.pop();
|
bonfire = bonfire.pop();
|
||||||
var dashedNameFull = bonfire.name.toLowerCase().replace(/\s/g, '-');
|
var dashedNameFull = bonfire.name.toLowerCase().replace(/\s/g, '-');
|
||||||
if (dashedNameFull != dashedName) {
|
if (dashedNameFull != dashedName) {
|
||||||
return res.redirect('../bonfires/' + dashedNameFull);
|
return res.redirect('../bonfires/' + dashedNameFull);
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
res.render('bonfire/show', {
|
|
||||||
completedWith: null,
|
|
||||||
title: bonfire.name,
|
|
||||||
dashedName: dashedName,
|
|
||||||
name: bonfire.name,
|
|
||||||
difficulty: Math.floor(+bonfire.difficulty),
|
|
||||||
brief: bonfire.description[0],
|
|
||||||
details: bonfire.description.slice(1),
|
|
||||||
tests: bonfire.tests,
|
|
||||||
challengeSeed: bonfire.challengeSeed,
|
|
||||||
cc: !!req.user,
|
|
||||||
points: req.user ? req.user.points : undefined,
|
|
||||||
verb: resources.randomVerb(),
|
|
||||||
phrase: resources.randomPhrase(),
|
|
||||||
compliment: resources.randomCompliment(),
|
|
||||||
bonfires: bonfire,
|
|
||||||
bonfireHash: bonfire._id,
|
|
||||||
MDNkeys: bonfire.MDNlinks,
|
|
||||||
MDNlinks: getMDNlinks(bonfire.MDNlinks)
|
|
||||||
>>>>>>> upstream/master
|
|
||||||
|
|
||||||
res.render('bonfire/show', {
|
res.render('bonfire/show', {
|
||||||
completedWith: null,
|
completedWith: null,
|
||||||
title: bonfire.name,
|
title: bonfire.name,
|
||||||
@ -142,12 +111,14 @@ exports.returnIndividualBonfire = function(req, res, next) {
|
|||||||
tests: bonfire.tests,
|
tests: bonfire.tests,
|
||||||
challengeSeed: bonfire.challengeSeed,
|
challengeSeed: bonfire.challengeSeed,
|
||||||
cc: !!req.user,
|
cc: !!req.user,
|
||||||
progressTimestamps: req.user ? req.user.progressTimestamps : undefined,
|
points: req.user ? req.user.points : undefined,
|
||||||
verb: resources.randomVerb(),
|
verb: resources.randomVerb(),
|
||||||
phrase: resources.randomPhrase(),
|
phrase: resources.randomPhrase(),
|
||||||
compliment: resources.randomCompliment(),
|
compliment: resources.randomCompliment(),
|
||||||
bonfires: bonfire,
|
bonfires: bonfire,
|
||||||
bonfireHash: bonfire._id
|
bonfireHash: bonfire._id,
|
||||||
|
MDNkeys: bonfire.MDNlinks,
|
||||||
|
MDNlinks: getMDNlinks(bonfire.MDNlinks)
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -189,18 +160,18 @@ function randomString() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to populate the MDN links array.
|
* Helper function to populate the MDN links array.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getMDNlinks(links) {
|
function getMDNlinks(links) {
|
||||||
// takes in an array of links, which are strings
|
// takes in an array of links, which are strings
|
||||||
var populatedLinks = [];
|
var populatedLinks = [];
|
||||||
|
|
||||||
// for each key value, push the corresponding link from the MDNlinks object into a new array
|
// for each key value, push the corresponding link from the MDNlinks object into a new array
|
||||||
links.forEach(function(value, index) {
|
links.forEach(function(value, index) {
|
||||||
populatedLinks.push(MDNlinks[value]);
|
populatedLinks.push(MDNlinks[value]);
|
||||||
});
|
});
|
||||||
|
|
||||||
return populatedLinks;
|
return populatedLinks;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -210,15 +181,15 @@ function getMDNlinks(links) {
|
|||||||
|
|
||||||
exports.testBonfire = function(req, res) {
|
exports.testBonfire = function(req, res) {
|
||||||
var bonfireName = req.body.name,
|
var bonfireName = req.body.name,
|
||||||
bonfireTests = req.body.tests,
|
bonfireTests = req.body.tests,
|
||||||
bonfireDifficulty = req.body.difficulty,
|
bonfireDifficulty = req.body.difficulty,
|
||||||
bonfireDescription = req.body.description,
|
bonfireDescription = req.body.description,
|
||||||
bonfireChallengeSeed = req.body.challengeSeed;
|
bonfireChallengeSeed = req.body.challengeSeed;
|
||||||
bonfireTests = bonfireTests.split('\r\n');
|
bonfireTests = bonfireTests.split('\r\n');
|
||||||
bonfireDescription = bonfireDescription.split('\r\n');
|
bonfireDescription = bonfireDescription.split('\r\n');
|
||||||
bonfireTests.filter(getRidOfEmpties);
|
bonfireTests.filter(getRidOfEmpties);
|
||||||
bonfireDescription.filter(getRidOfEmpties);
|
bonfireDescription.filter(getRidOfEmpties);
|
||||||
bonfireChallengeSeed = bonfireChallengeSeed.replace('\r', '');
|
bonfireChallengeSeed = bonfireChallengeSeed.replace('\r', '');
|
||||||
|
|
||||||
res.render('bonfire/show', {
|
res.render('bonfire/show', {
|
||||||
completedWith: null,
|
completedWith: null,
|
||||||
@ -251,15 +222,15 @@ exports.publicGenerator = function(req, res) {
|
|||||||
|
|
||||||
exports.generateChallenge = function(req, res) {
|
exports.generateChallenge = function(req, res) {
|
||||||
var bonfireName = req.body.name,
|
var bonfireName = req.body.name,
|
||||||
bonfireTests = req.body.tests,
|
bonfireTests = req.body.tests,
|
||||||
bonfireDifficulty = req.body.difficulty,
|
bonfireDifficulty = req.body.difficulty,
|
||||||
bonfireDescription = req.body.description,
|
bonfireDescription = req.body.description,
|
||||||
bonfireChallengeSeed = req.body.challengeSeed;
|
bonfireChallengeSeed = req.body.challengeSeed;
|
||||||
bonfireTests = bonfireTests.split('\r\n');
|
bonfireTests = bonfireTests.split('\r\n');
|
||||||
bonfireDescription = bonfireDescription.split('\r\n');
|
bonfireDescription = bonfireDescription.split('\r\n');
|
||||||
bonfireTests.filter(getRidOfEmpties);
|
bonfireTests.filter(getRidOfEmpties);
|
||||||
bonfireDescription.filter(getRidOfEmpties);
|
bonfireDescription.filter(getRidOfEmpties);
|
||||||
bonfireChallengeSeed = bonfireChallengeSeed.replace('\r', '');
|
bonfireChallengeSeed = bonfireChallengeSeed.replace('\r', '');
|
||||||
|
|
||||||
|
|
||||||
var response = {
|
var response = {
|
||||||
|
@ -100,7 +100,8 @@ exports.returnIndividualCourseware = function(req, res, next) {
|
|||||||
phrase: resources.randomPhrase(),
|
phrase: resources.randomPhrase(),
|
||||||
compliment: resources.randomCompliment(),
|
compliment: resources.randomCompliment(),
|
||||||
coursewareHash: courseware._id,
|
coursewareHash: courseware._id,
|
||||||
environment: resources.whichEnvironment()
|
environment: resources.whichEnvironment(),
|
||||||
|
challengeType: courseware.challengeType
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ exports.returnIndividualCourseware = function(req, res, next) {
|
|||||||
phrase: resources.randomPhrase(),
|
phrase: resources.randomPhrase(),
|
||||||
compliment: resources.randomCompliment(),
|
compliment: resources.randomCompliment(),
|
||||||
coursewareHash: courseware._id,
|
coursewareHash: courseware._id,
|
||||||
|
challengeType: courseware.challengeType
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -133,7 +134,7 @@ exports.returnIndividualCourseware = function(req, res, next) {
|
|||||||
phrase: resources.randomPhrase(),
|
phrase: resources.randomPhrase(),
|
||||||
compliment: resources.randomCompliment(),
|
compliment: resources.randomCompliment(),
|
||||||
coursewareHash: courseware._id,
|
coursewareHash: courseware._id,
|
||||||
challengeType: 'video'
|
challengeType: courseware.challengeType
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -160,16 +161,16 @@ exports.returnIndividualCourseware = function(req, res, next) {
|
|||||||
|
|
||||||
exports.testCourseware = function(req, res) {
|
exports.testCourseware = function(req, res) {
|
||||||
var coursewareName = req.body.name,
|
var coursewareName = req.body.name,
|
||||||
coursewareTests = req.body.tests,
|
coursewareTests = req.body.tests,
|
||||||
coursewareDifficulty = req.body.difficulty,
|
coursewareDifficulty = req.body.difficulty,
|
||||||
coursewareDescription = req.body.description,
|
coursewareDescription = req.body.description,
|
||||||
coursewareEntryPoint = req.body.challengeEntryPoint,
|
coursewareEntryPoint = req.body.challengeEntryPoint,
|
||||||
coursewareChallengeSeed = req.body.challengeSeed;
|
coursewareChallengeSeed = req.body.challengeSeed;
|
||||||
coursewareTests = coursewareTests.split('\r\n');
|
coursewareTests = coursewareTests.split('\r\n');
|
||||||
coursewareDescription = coursewareDescription.split('\r\n');
|
coursewareDescription = coursewareDescription.split('\r\n');
|
||||||
coursewareTests.filter(getRidOfEmpties);
|
coursewareTests.filter(getRidOfEmpties);
|
||||||
coursewareDescription.filter(getRidOfEmpties);
|
coursewareDescription.filter(getRidOfEmpties);
|
||||||
coursewareChallengeSeed = coursewareChallengeSeed.replace('\r', '');
|
coursewareChallengeSeed = coursewareChallengeSeed.replace('\r', '');
|
||||||
res.render('courseware/show', {
|
res.render('courseware/show', {
|
||||||
completedWith: null,
|
completedWith: null,
|
||||||
title: coursewareName,
|
title: coursewareName,
|
||||||
@ -233,7 +234,9 @@ exports.completedCourseware = function (req, res, next) {
|
|||||||
req.user.completedCoursewares.push({
|
req.user.completedCoursewares.push({
|
||||||
_id: coursewareHash,
|
_id: coursewareHash,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
name: req.body.coursewareInfo.coursewareName
|
name: req.body.coursewareInfo.coursewareName,
|
||||||
|
solution: null,
|
||||||
|
githubLink: null
|
||||||
});
|
});
|
||||||
var index = req.user.completedCoursewares.indexOf(coursewareHash);
|
var index = req.user.completedCoursewares.indexOf(coursewareHash);
|
||||||
|
|
||||||
@ -247,19 +250,26 @@ exports.completedCourseware = function (req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
if (user) {
|
if (user) {
|
||||||
res.send(true);
|
res.sendStatus(200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.completedZiplineOrBasejump = function (req, res, next) {
|
exports.completedZiplineOrBasejump = function (req, res, next) {
|
||||||
var isCompletedWith = req.body.bonfireInfo.completedWith || false;
|
debug('Inside controller for completed zipline or basejump with data %s',
|
||||||
|
req.body.coursewareInfo);
|
||||||
|
var isCompletedWith = req.body.coursewareInfo.completedWith || false;
|
||||||
var isCompletedDate = Math.round(+new Date());
|
var isCompletedDate = Math.round(+new Date());
|
||||||
var coursewareHash = req.body.coursewareInfo.coursewareHash;
|
var coursewareHash = req.body.coursewareInfo.coursewareHash;
|
||||||
var solutionLink = req.body.coursewareInfo.solutionLink;
|
var solutionLink = req.body.coursewareInfo.publicURL;
|
||||||
if (!solutionLink) {
|
var githubLink = req.body.coursewareInfo.challengeType === 4
|
||||||
// flash error and redirect
|
? req.body.coursewareInfo.githubURL : true;
|
||||||
return next(new Error('No solution provided'));
|
if (!solutionLink || !githubLink) {
|
||||||
|
req.flash('errors', {
|
||||||
|
msg: 'You haven\'t supplied the necessary URLs for us to inspect ' +
|
||||||
|
'your work.'
|
||||||
|
});
|
||||||
|
return res.sendStatus(403);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isCompletedWith) {
|
if (isCompletedWith) {
|
||||||
@ -286,14 +296,16 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
_id: coursewareHash,
|
_id: coursewareHash,
|
||||||
completedWith: req.user._id,
|
completedWith: req.user._id,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink
|
solution: solutionLink,
|
||||||
|
githubLink: githubLink
|
||||||
});
|
});
|
||||||
|
|
||||||
req.user.completedCoursewares.push({
|
req.user.completedCoursewares.push({
|
||||||
_id: coursewareHash,
|
_id: coursewareHash,
|
||||||
completedWith: pairedWith._id,
|
completedWith: pairedWith._id,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink
|
solution: solutionLink,
|
||||||
|
githubLink: githubLink
|
||||||
});
|
});
|
||||||
|
|
||||||
req.user.save(function (err, user) {
|
req.user.save(function (err, user) {
|
||||||
@ -305,7 +317,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
if (user && paired) {
|
if (user && paired) {
|
||||||
return res.send(true);
|
return res.sendStatus(200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -317,10 +329,11 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
_id: coursewareHash,
|
_id: coursewareHash,
|
||||||
completedWith: null,
|
completedWith: null,
|
||||||
completedDate: isCompletedDate,
|
completedDate: isCompletedDate,
|
||||||
solution: solutionLink
|
solution: solutionLink,
|
||||||
|
githubLink: githubLink
|
||||||
});
|
});
|
||||||
|
|
||||||
var index = req.user.uncompletedCourse.indexOf(coursewareHash);
|
var index = req.user.uncompletedCoursewares.indexOf(coursewareHash);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
req.user.progressTimestamps.push(Date.now() || 0);
|
req.user.progressTimestamps.push(Date.now() || 0);
|
||||||
req.user.uncompletedCoursewares.splice(index, 1);
|
req.user.uncompletedCoursewares.splice(index, 1);
|
||||||
@ -331,8 +344,7 @@ exports.completedZiplineOrBasejump = function (req, res, next) {
|
|||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
if (user) {
|
if (user) {
|
||||||
debug('Saving user');
|
return res.sendStatus(200);
|
||||||
return res.send(true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,10 @@ var userSchema = new mongoose.Schema({
|
|||||||
{
|
{
|
||||||
completedDate: Long,
|
completedDate: Long,
|
||||||
_id: String,
|
_id: String,
|
||||||
name: String
|
name: String,
|
||||||
|
completedWith: String,
|
||||||
|
solution: String,
|
||||||
|
githubLink: String
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
currentStreak: {
|
currentStreak: {
|
||||||
|
@ -1,377 +1,432 @@
|
|||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
var challengeName = typeof challengeName !== undefined ? challengeName : 'Untitled';
|
var challengeName = typeof challengeName !== undefined ? challengeName : 'Untitled';
|
||||||
if (challengeName) {
|
if (challengeName) {
|
||||||
ga('send', 'event', 'Challenge', 'load', challengeName);
|
ga('send', 'event', 'Challenge', 'load', challengeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When introducing a new announcement, change the localStorage attribute
|
// When introducing a new announcement, change the localStorage attribute
|
||||||
// and the HTML located in the footer
|
// and the HTML located in the footer
|
||||||
if (!localStorage || !localStorage.nodeSchoolAnnouncement) {
|
if (!localStorage || !localStorage.nodeSchoolAnnouncement) {
|
||||||
$('#announcementModal').modal('show');
|
$('#announcementModal').modal('show');
|
||||||
localStorage.fccShowAnnouncement = "true";
|
localStorage.fccShowAnnouncement = "true";
|
||||||
}
|
}
|
||||||
|
|
||||||
var CSRF_HEADER = 'X-CSRF-Token';
|
var CSRF_HEADER = 'X-CSRF-Token';
|
||||||
|
|
||||||
var setCSRFToken = function(securityToken) {
|
var setCSRFToken = function(securityToken) {
|
||||||
jQuery.ajaxPrefilter(function(options, _, xhr) {
|
jQuery.ajaxPrefilter(function(options, _, xhr) {
|
||||||
if (!xhr.crossDomain) {
|
if (!xhr.crossDomain) {
|
||||||
xhr.setRequestHeader(CSRF_HEADER, securityToken);
|
xhr.setRequestHeader(CSRF_HEADER, securityToken);
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
setCSRFToken($('meta[name="csrf-token"]').attr('content'));
|
|
||||||
|
|
||||||
$('.start-challenge').on('click', function() {
|
|
||||||
$(this).parent().remove();
|
|
||||||
$('.challenge-content')
|
|
||||||
.removeClass('hidden-element')
|
|
||||||
.addClass('animated fadeInDown');
|
|
||||||
});
|
|
||||||
|
|
||||||
//$('.completed-challenge').on('click', function() {
|
|
||||||
// $('#complete-challenge-dialog').modal('show');
|
|
||||||
// // 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/'
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//});
|
|
||||||
|
|
||||||
|
|
||||||
function completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash) {
|
|
||||||
$('#complete-bonfire-dialog').modal('show');
|
|
||||||
// Only post to server if there is an authenticated user
|
|
||||||
if ($('.signup-btn-nav').length < 1) {
|
|
||||||
|
|
||||||
$.post(
|
|
||||||
'/completed-bonfire',
|
|
||||||
{
|
|
||||||
bonfireInfo: {
|
|
||||||
completedWith : didCompleteWith,
|
|
||||||
solution: bonfireSolution,
|
|
||||||
bonfireHash: thisBonfireHash
|
|
||||||
}
|
|
||||||
},
|
|
||||||
function(res) {
|
|
||||||
if (res) {
|
|
||||||
window.location.href = '/bonfires'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.next-bonfire-button').on('click', function() {
|
|
||||||
var bonfireSolution = myCodeMirror.getValue();
|
|
||||||
var thisBonfireHash = passedBonfireHash || null;
|
|
||||||
var didCompleteWith = $('#completed-with').val() || null;
|
|
||||||
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#completed-courseware').on('click', function() {
|
|
||||||
$('#complete-courseware-dialog').modal('show');
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#complete-courseware-dialog').on('keypress', function(e) {
|
|
||||||
if (e.ctrlKey && e.keyCode == 13) {
|
|
||||||
$('#next-courseware-button').click();
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
$('#complete-bonfire-dialog').on('hidden.bs.modal', function() {
|
setCSRFToken($('meta[name="csrf-token"]').attr('content'));
|
||||||
editor.focus();
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#all-bonfires-dialog').on('hidden.bs.modal', function() {
|
$('.start-challenge').on('click', function() {
|
||||||
editor.focus();
|
$(this).parent().remove();
|
||||||
});
|
$('.challenge-content')
|
||||||
|
.removeClass('hidden-element')
|
||||||
|
.addClass('animated fadeInDown');
|
||||||
|
});
|
||||||
|
|
||||||
$('#showAllCoursewares').on('click', function() {
|
//$('.completed-challenge').on('click', function() {
|
||||||
$('#all-coursewares-dialog').modal('show');
|
// $('#complete-challenge-dialog').modal('show');
|
||||||
});
|
// // Only post to server if there is an authenticated user
|
||||||
|
// if ($('.signup-btn-nav').length < 1) {
|
||||||
$('#all-coursewares-dialog').on('hidden.bs.modal', function() {
|
// l = location.pathname.split('/');
|
||||||
editor.focus();
|
// cn = l[l.length - 1];
|
||||||
});
|
// $.ajax({
|
||||||
|
// type: 'POST',
|
||||||
|
// data: {challengeNumber: cn},
|
||||||
|
// url: '/completed-challenge/'
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
|
||||||
|
|
||||||
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
|
function completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash) {
|
||||||
editor.focus();
|
$('#complete-bonfire-dialog').modal('show');
|
||||||
});
|
// Only post to server if there is an authenticated user
|
||||||
$('#next-courseware-button').on('click', function() {
|
if ($('.signup-btn-nav').length < 1) {
|
||||||
console.log(passedCoursewareHash);
|
|
||||||
if ($('.signup-btn-nav').length < 1) {
|
|
||||||
$.post(
|
|
||||||
'/completed-courseware/',
|
|
||||||
{
|
|
||||||
coursewareInfo: {
|
|
||||||
coursewareHash: passedCoursewareHash,
|
|
||||||
coursewareName: passedCoursewareName
|
|
||||||
}
|
|
||||||
}).success(
|
|
||||||
function(res) {
|
|
||||||
if (res) {
|
|
||||||
window.location.href = '/challenges';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
$.post(
|
||||||
});
|
'/completed-bonfire',
|
||||||
|
{
|
||||||
|
bonfireInfo: {
|
||||||
|
completedWith : didCompleteWith,
|
||||||
|
solution: bonfireSolution,
|
||||||
|
bonfireHash: thisBonfireHash
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function(res) {
|
||||||
|
if (res) {
|
||||||
|
window.location.href = '/bonfires'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$('.next-bonfire-button').on('click', function() {
|
||||||
|
var bonfireSolution = myCodeMirror.getValue();
|
||||||
|
var thisBonfireHash = passedBonfireHash || null;
|
||||||
|
var didCompleteWith = $('#completed-with').val() || null;
|
||||||
|
completedBonfire(didCompleteWith, bonfireSolution, thisBonfireHash);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#completed-courseware').on('click', function() {
|
||||||
|
$('#complete-courseware-dialog').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#completed-zipline-or-basejump').on('click', function() {
|
||||||
|
$('#complete-zipline-or-basejump-dialog').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
$('.all-challenges').on('click', function() {
|
$('#complete-courseware-dialog').on('keypress', function(e) {
|
||||||
$('#all-challenges-dialog').modal('show');
|
if (e.ctrlKey && e.keyCode === 13) {
|
||||||
});
|
$('#next-courseware-button').click();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$('#showAllButton').on('click', function() {
|
$('#complete-bonfire-dialog').on('hidden.bs.modal', function() {
|
||||||
$('#all-bonfires-dialog').modal('show');
|
editor.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.next-challenge-button').on('click', function() {
|
$('#all-bonfires-dialog').on('hidden.bs.modal', function() {
|
||||||
l = location.pathname.split('/');
|
editor.focus();
|
||||||
window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1);
|
});
|
||||||
});
|
|
||||||
|
$('#showAllCoursewares').on('click', function() {
|
||||||
|
$('#all-coursewares-dialog').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#all-coursewares-dialog').on('hidden.bs.modal', function() {
|
||||||
|
editor.focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Bonfire instructions functions
|
$('#complete-courseware-dialog').on('hidden.bs.modal', function() {
|
||||||
$('#more-info').on('click', function() {
|
editor.focus();
|
||||||
ga('send', 'event', 'Challenge', 'more-info', challengeName);
|
});
|
||||||
$('#brief-instructions').hide();
|
$('#next-courseware-button').on('click', function() {
|
||||||
$('#long-instructions').show().removeClass('hide');
|
console.log(passedCoursewareHash);
|
||||||
|
if ($('.signup-btn-nav').length < 1) {
|
||||||
});
|
switch (challengeType) {
|
||||||
$('#less-info').on('click', function() {
|
case 0:
|
||||||
$('#brief-instructions').show();
|
case 1:
|
||||||
$('#long-instructions').hide();
|
case 2:
|
||||||
});
|
$.post(
|
||||||
|
'/completed-courseware/',
|
||||||
var upvoteHandler = function () {
|
{
|
||||||
var _id = storyId;
|
coursewareInfo: {
|
||||||
$('#upvote').unbind('click');
|
coursewareHash: passedCoursewareHash,
|
||||||
var alreadyUpvoted = false;
|
coursewareName: passedCoursewareName
|
||||||
for (var i = 0; i < upVotes.length; i++) {
|
}
|
||||||
if (upVotes[i].upVotedBy === user._id) {
|
}).success(
|
||||||
alreadyUpvoted = true;
|
function(res) {
|
||||||
break;
|
if (res) {
|
||||||
|
window.location.href = '/challenges';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
if (!alreadyUpvoted) {
|
break;
|
||||||
$.post('/stories/upvote',
|
case 3:
|
||||||
{
|
var didCompleteWith = $('#completed-with').val() || null;
|
||||||
data: {
|
var publicURL = $('#public-url').val() || null;
|
||||||
id: _id,
|
$.post(
|
||||||
upVoter: user
|
'/completed-zipline-or-basejump/',
|
||||||
}
|
|
||||||
})
|
|
||||||
.fail(function (xhr, textStatus, errorThrown) {
|
|
||||||
$('#upvote').bind('click', upvoteHandler);
|
|
||||||
})
|
|
||||||
.done(function (data, textStatus, xhr) {
|
|
||||||
$('#upvote').text('Upvoted!').addClass('disabled');
|
|
||||||
|
|
||||||
$('#storyRank').text(data.rank + " points");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$('#upvote').on('click', upvoteHandler);
|
|
||||||
|
|
||||||
|
|
||||||
var storySubmitButtonHandler = function storySubmitButtonHandler() {
|
|
||||||
|
|
||||||
var link = $('#story-url').val();
|
|
||||||
var headline = $('#story-title').val();
|
|
||||||
var description = $('#description-box').val();
|
|
||||||
var userDataForUpvote = {
|
|
||||||
upVotedBy: user._id,
|
|
||||||
upVotedByUsername: user.profile.username
|
|
||||||
};
|
|
||||||
$('#story-submit').unbind('click');
|
|
||||||
$.post('/stories/',
|
|
||||||
{
|
{
|
||||||
data: {
|
coursewareInfo: {
|
||||||
link: link,
|
coursewareHash: passedCoursewareHash,
|
||||||
headline: headline,
|
coursewareName: passedCoursewareName,
|
||||||
timePosted: Date.now(),
|
completedWith: didCompleteWith,
|
||||||
description: description,
|
publicURL: publicURL,
|
||||||
storyMetaDescription: storyMetaDescription,
|
challengeType: challengeType
|
||||||
rank: 1,
|
}
|
||||||
upVotes: [userDataForUpvote],
|
}).success(
|
||||||
author: {
|
function() {
|
||||||
picture: user.profile.picture,
|
window.location.href = '/challenges';
|
||||||
userId: user._id,
|
}).fail(
|
||||||
username: user.profile.username
|
function() {
|
||||||
},
|
window.location.href = '/challenges';
|
||||||
comments: [],
|
|
||||||
image: storyImage
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.fail(function (xhr, textStatus, errorThrown) {
|
|
||||||
$('#story-submit').bind('click', storySubmitButtonHandler);
|
|
||||||
})
|
|
||||||
.done(function (data, textStatus, xhr) {
|
|
||||||
window.location = '/stories/' + JSON.parse(data).storyLink;
|
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
};
|
case 4:
|
||||||
|
var didCompleteWith = $('#completed-with').val() || null;
|
||||||
$('#story-submit').on('click', storySubmitButtonHandler);
|
var publicURL = $('#public-url').val() || null;
|
||||||
|
var githubURL = $('#github-url').val() || null;
|
||||||
var commentSubmitButtonHandler = function commentSubmitButtonHandler() {
|
$.post(
|
||||||
$('comment-button').unbind('click');
|
'/completed-zipline-or-basejump/',
|
||||||
var data = $('#comment-box').val();
|
|
||||||
|
|
||||||
$('#comment-button').attr('disabled', 'disabled');
|
|
||||||
$.post('/stories/comment/',
|
|
||||||
{
|
{
|
||||||
data: {
|
coursewareInfo: {
|
||||||
associatedPost: storyId,
|
coursewareHash: passedCoursewareHash,
|
||||||
body: data,
|
coursewareName: passedCoursewareName,
|
||||||
author: {
|
completedWith: didCompleteWith,
|
||||||
picture: user.profile.picture,
|
publicURL: publicURl,
|
||||||
userId: user._id,
|
githubURL: githubURL,
|
||||||
username: user.profile.username
|
challengeType: challengeType
|
||||||
}
|
}
|
||||||
}
|
}).success(function() {
|
||||||
})
|
window.location.href = '/challenges';
|
||||||
.fail(function (xhr, textStatus, errorThrown) {
|
}).fail(function() {
|
||||||
$('#comment-button').attr('disabled', false);
|
window.location.replace(window.location.href);
|
||||||
})
|
|
||||||
.done(function (data, textStatus, xhr) {
|
|
||||||
window.location.reload();
|
|
||||||
});
|
});
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$('.all-challenges').on('click', function() {
|
||||||
|
$('#all-challenges-dialog').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#showAllButton').on('click', function() {
|
||||||
|
$('#all-bonfires-dialog').modal('show');
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.next-challenge-button').on('click', function() {
|
||||||
|
l = location.pathname.split('/');
|
||||||
|
window.location = '/challenges/' + (parseInt(l[l.length - 1]) + 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Bonfire instructions functions
|
||||||
|
$('#more-info').on('click', function() {
|
||||||
|
ga('send', 'event', 'Challenge', 'more-info', challengeName);
|
||||||
|
$('#brief-instructions').hide();
|
||||||
|
$('#long-instructions').show().removeClass('hide');
|
||||||
|
|
||||||
|
});
|
||||||
|
$('#less-info').on('click', function() {
|
||||||
|
$('#brief-instructions').show();
|
||||||
|
$('#long-instructions').hide();
|
||||||
|
});
|
||||||
|
|
||||||
|
var upvoteHandler = function () {
|
||||||
|
var _id = storyId;
|
||||||
|
$('#upvote').unbind('click');
|
||||||
|
var alreadyUpvoted = false;
|
||||||
|
for (var i = 0; i < upVotes.length; i++) {
|
||||||
|
if (upVotes[i].upVotedBy === user._id) {
|
||||||
|
alreadyUpvoted = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!alreadyUpvoted) {
|
||||||
|
$.post('/stories/upvote',
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
id: _id,
|
||||||
|
upVoter: user
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail(function (xhr, textStatus, errorThrown) {
|
||||||
|
$('#upvote').bind('click', upvoteHandler);
|
||||||
|
})
|
||||||
|
.done(function (data, textStatus, xhr) {
|
||||||
|
$('#upvote').text('Upvoted!').addClass('disabled');
|
||||||
|
|
||||||
|
$('#storyRank').text(data.rank + " points");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
$('#upvote').on('click', upvoteHandler);
|
||||||
|
|
||||||
|
|
||||||
|
var storySubmitButtonHandler = function storySubmitButtonHandler() {
|
||||||
|
|
||||||
|
var link = $('#story-url').val();
|
||||||
|
var headline = $('#story-title').val();
|
||||||
|
var description = $('#description-box').val();
|
||||||
|
var userDataForUpvote = {
|
||||||
|
upVotedBy: user._id,
|
||||||
|
upVotedByUsername: user.profile.username
|
||||||
};
|
};
|
||||||
|
$('#story-submit').unbind('click');
|
||||||
|
$.post('/stories/',
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
link: link,
|
||||||
|
headline: headline,
|
||||||
|
timePosted: Date.now(),
|
||||||
|
description: description,
|
||||||
|
storyMetaDescription: storyMetaDescription,
|
||||||
|
rank: 1,
|
||||||
|
upVotes: [userDataForUpvote],
|
||||||
|
author: {
|
||||||
|
picture: user.profile.picture,
|
||||||
|
userId: user._id,
|
||||||
|
username: user.profile.username
|
||||||
|
},
|
||||||
|
comments: [],
|
||||||
|
image: storyImage
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail(function (xhr, textStatus, errorThrown) {
|
||||||
|
$('#story-submit').bind('click', storySubmitButtonHandler);
|
||||||
|
})
|
||||||
|
.done(function (data, textStatus, xhr) {
|
||||||
|
window.location = '/stories/' + JSON.parse(data).storyLink;
|
||||||
|
});
|
||||||
|
|
||||||
$('#comment-button').on('click', commentSubmitButtonHandler);
|
};
|
||||||
|
|
||||||
|
$('#story-submit').on('click', storySubmitButtonHandler);
|
||||||
|
|
||||||
|
var commentSubmitButtonHandler = function commentSubmitButtonHandler() {
|
||||||
|
$('comment-button').unbind('click');
|
||||||
|
var data = $('#comment-box').val();
|
||||||
|
|
||||||
|
$('#comment-button').attr('disabled', 'disabled');
|
||||||
|
$.post('/stories/comment/',
|
||||||
|
{
|
||||||
|
data: {
|
||||||
|
associatedPost: storyId,
|
||||||
|
body: data,
|
||||||
|
author: {
|
||||||
|
picture: user.profile.picture,
|
||||||
|
userId: user._id,
|
||||||
|
username: user.profile.username
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.fail(function (xhr, textStatus, errorThrown) {
|
||||||
|
$('#comment-button').attr('disabled', false);
|
||||||
|
})
|
||||||
|
.done(function (data, textStatus, xhr) {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
$('#comment-button').on('click', commentSubmitButtonHandler);
|
||||||
});
|
});
|
||||||
|
|
||||||
var profileValidation = angular.module('profileValidation',['ui.bootstrap']);
|
var profileValidation = angular.module('profileValidation',['ui.bootstrap']);
|
||||||
profileValidation.controller('profileValidationController', ['$scope', '$http',
|
profileValidation.controller('profileValidationController', ['$scope', '$http',
|
||||||
function($scope, $http) {
|
function($scope, $http) {
|
||||||
$http.get('/account/api').success(function(data) {
|
$http.get('/account/api').success(function(data) {
|
||||||
$scope.user = data.user;
|
$scope.user = data.user;
|
||||||
$scope.user.profile.username = $scope.user.profile.username ? $scope.user.profile.username.toLowerCase() : undefined;
|
$scope.user.profile.username = $scope.user.profile.username ? $scope.user.profile.username.toLowerCase() : undefined;
|
||||||
$scope.storedUsername = data.user.profile.username;
|
$scope.storedUsername = data.user.profile.username;
|
||||||
$scope.storedEmail = data.user.email;
|
$scope.storedEmail = data.user.email;
|
||||||
$scope.user.email = $scope.user.email ? $scope.user.email.toLowerCase() : undefined;
|
$scope.user.email = $scope.user.email ? $scope.user.email.toLowerCase() : undefined;
|
||||||
$scope.user.profile.twitterHandle = $scope.user.profile.twitterHandle ? $scope.user.profile.twitterHandle.toLowerCase() : undefined;
|
$scope.user.profile.twitterHandle = $scope.user.profile.twitterHandle ? $scope.user.profile.twitterHandle.toLowerCase() : undefined;
|
||||||
$scope.asyncComplete = true;
|
$scope.asyncComplete = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
profileValidation.controller('pairedWithController', ['$scope',
|
profileValidation.controller('pairedWithController', ['$scope',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
$scope.existingUser = null;
|
$scope.existingUser = null;
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
profileValidation.controller('emailSignUpController', ['$scope',
|
profileValidation.controller('emailSignUpController', ['$scope',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
profileValidation.controller('emailSignInController', ['$scope',
|
profileValidation.controller('emailSignInController', ['$scope',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
profileValidation.controller('URLSubmitController', ['$scope',
|
profileValidation.controller('URLSubmitController', ['$scope',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
profileValidation.controller('nonprofitFormController', ['$scope',
|
profileValidation.controller('nonprofitFormController', ['$scope',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
profileValidation.controller('doneWithFirst100HoursFormController', ['$scope',
|
profileValidation.controller('doneWithFirst100HoursFormController', ['$scope',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
profileValidation.controller('submitStoryController', ['$scope',
|
profileValidation.controller('submitStoryController', ['$scope',
|
||||||
function($scope) {
|
function($scope) {
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
profileValidation.directive('uniqueUsername',['$http',function($http) {
|
profileValidation.directive('uniqueUsername',['$http',function($http) {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function (scope, element, attrs, ngModel) {
|
link: function (scope, element, attrs, ngModel) {
|
||||||
element.bind("keyup", function (event) {
|
element.bind("keyup", function (event) {
|
||||||
ngModel.$setValidity('unique', true);
|
ngModel.$setValidity('unique', true);
|
||||||
if (element.val()) {
|
if (element.val()) {
|
||||||
$http.get("/api/checkUniqueUsername/" + element.val()).success(function (data) {
|
$http.get("/api/checkUniqueUsername/" + element.val()).success(function (data) {
|
||||||
if (element.val() == scope.storedUsername) {
|
if (element.val() == scope.storedUsername) {
|
||||||
ngModel.$setValidity('unique', true);
|
ngModel.$setValidity('unique', true);
|
||||||
} else if (data) {
|
} else if (data) {
|
||||||
ngModel.$setValidity('unique', false);
|
ngModel.$setValidity('unique', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
profileValidation.directive('existingUsername', ['$http', function($http) {
|
profileValidation.directive('existingUsername', ['$http', function($http) {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function (scope, element, attrs, ngModel) {
|
link: function (scope, element, attrs, ngModel) {
|
||||||
element.bind("keyup", function (event) {
|
element.bind("keyup", function (event) {
|
||||||
if (element.val().length > 0) {
|
if (element.val().length > 0) {
|
||||||
ngModel.$setValidity('exists', false);
|
ngModel.$setValidity('exists', false);
|
||||||
} else {
|
} else {
|
||||||
element.removeClass('ng-dirty');
|
element.removeClass('ng-dirty');
|
||||||
ngModel.$setPristine();
|
ngModel.$setPristine();
|
||||||
}
|
}
|
||||||
if (element.val()) {
|
if (element.val()) {
|
||||||
$http
|
$http
|
||||||
.get("/api/checkExistingUsername/" + element.val())
|
.get("/api/checkExistingUsername/" + element.val())
|
||||||
.success(function (data) {
|
.success(function (data) {
|
||||||
ngModel.$setValidity('exists', data);
|
ngModel.$setValidity('exists', data);
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}]);
|
}]);
|
||||||
|
|
||||||
profileValidation.directive('uniqueEmail', ['$http', function($http) {
|
profileValidation.directive('uniqueEmail', ['$http', function($http) {
|
||||||
return {
|
return {
|
||||||
restrict: 'A',
|
restrict: 'A',
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function getUnique (scope, element, attrs, ngModel) {
|
link: function getUnique (scope, element, attrs, ngModel) {
|
||||||
element.bind("keyup", function (event) {
|
element.bind("keyup", function (event) {
|
||||||
ngModel.$setValidity('unique', true);
|
ngModel.$setValidity('unique', true);
|
||||||
if (element.val()) {
|
if (element.val()) {
|
||||||
$http.get("/api/checkUniqueEmail/" + encodeURIComponent(element.val())).success(function (data) {
|
$http.get("/api/checkUniqueEmail/" + encodeURIComponent(element.val())).success(function (data) {
|
||||||
if (element.val() == scope.storedEmail) {
|
if (element.val() == scope.storedEmail) {
|
||||||
ngModel.$setValidity('unique', true);
|
ngModel.$setValidity('unique', true);
|
||||||
} else if (data) {
|
} else if (data) {
|
||||||
ngModel.$setValidity('unique', false);
|
ngModel.$setValidity('unique', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}]);
|
}]);
|
||||||
|
@ -148,16 +148,6 @@ block content
|
|||||||
include ../partials/bonfires
|
include ../partials/bonfires
|
||||||
|
|
||||||
script.
|
script.
|
||||||
$.ajax({
|
|
||||||
url: 'https://api-ssl.bitly.com/v3/shorten?access_token=75e7931a19befaafcf108021b6d597e554b2c5c3&longUrl=http%3A%2F%2Ffreecodecamp.com%2Fbonfires%2F' + dashed + '&format=txt'
|
|
||||||
})
|
|
||||||
.success(
|
|
||||||
function (data) {
|
|
||||||
console.log(data);
|
|
||||||
url = "https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20Bonfire:%20#{name}&url=" + data + "&hashtags=LearnToCode, JavaScript";
|
|
||||||
$('.btn-twitter').attr('href', url);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
var MDNlinks = !{JSON.stringify(MDNlinks)};
|
||||||
if (!MDNlinks.length) {
|
if (!MDNlinks.length) {
|
||||||
$('#MDN-links').addClass('collapse');
|
$('#MDN-links').addClass('collapse');
|
||||||
|
@ -60,6 +60,7 @@ block content
|
|||||||
var challengeName = !{JSON.stringify(name)};
|
var challengeName = !{JSON.stringify(name)};
|
||||||
var passedCoursewareName = challengeName;
|
var passedCoursewareName = challengeName;
|
||||||
var prodOrDev = !{JSON.stringify(environment)};
|
var prodOrDev = !{JSON.stringify(environment)};
|
||||||
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
var started = Math.floor(Date.now());
|
var started = Math.floor(Date.now());
|
||||||
.col-xs-12.col-sm-12.col-md-5.col-lg-6
|
.col-xs-12.col-sm-12.col-md-5.col-lg-6
|
||||||
#mainEditorPanel
|
#mainEditorPanel
|
||||||
@ -81,4 +82,4 @@ block content
|
|||||||
.animated.zoomInDown.delay-half
|
.animated.zoomInDown.delay-half
|
||||||
span.completion-icon.ion-checkmark-circled.text-primary
|
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
|
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")
|
script(src="/js/lib/coursewares/coursewaresHCJQFramework_v0.1.1.js")
|
||||||
|
@ -47,6 +47,7 @@ block content
|
|||||||
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
var challengeSeed = !{JSON.stringify(challengeSeed)};
|
||||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
||||||
var challengeName = !{JSON.stringify(name)};
|
var challengeName = !{JSON.stringify(name)};
|
||||||
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
var passedCoursewareName = challengeName;
|
var passedCoursewareName = challengeName;
|
||||||
var started = Math.floor(Date.now());
|
var started = Math.floor(Date.now());
|
||||||
|
|
||||||
@ -72,4 +73,4 @@ block content
|
|||||||
i.fa.fa-twitter  
|
i.fa.fa-twitter  
|
||||||
= phrase
|
= phrase
|
||||||
- else
|
- else
|
||||||
a.animated.fadeIn.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
|
||||||
|
@ -27,6 +27,7 @@ block content
|
|||||||
var challengeName = !{JSON.stringify(name)};
|
var challengeName = !{JSON.stringify(name)};
|
||||||
var passedCoursewareName = challengeName;
|
var passedCoursewareName = challengeName;
|
||||||
var started = Math.floor(Date.now());
|
var started = Math.floor(Date.now());
|
||||||
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
#complete-courseware-dialog.modal(tabindex='-1')
|
#complete-courseware-dialog.modal(tabindex='-1')
|
||||||
.modal-dialog.animated.zoomIn.fast-animation
|
.modal-dialog.animated.zoomIn.fast-animation
|
||||||
.modal-content
|
.modal-content
|
||||||
@ -46,10 +47,8 @@ block content
|
|||||||
a.animated.fadeIn.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
|
||||||
h1 #{name}
|
h1 #{name}
|
||||||
script.
|
script.
|
||||||
var challengeName = !{JSON.stringify(name)};
|
|
||||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
|
||||||
$('body').on('keypress', function(e) {
|
$('body').on('keypress', function(e) {
|
||||||
if (e.ctrlKey && e.keyCode == 13) {
|
if (e.ctrlKey && e.keyCode == 13) {
|
||||||
$('#complete-courseware-dialog').modal('show');
|
$('#complete-courseware-dialog').modal('show');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -13,7 +13,7 @@ block content
|
|||||||
iframe.embed-responsive-item(src='//player.vimeo.com/video/#{video}')
|
iframe.embed-responsive-item(src='//player.vimeo.com/video/#{video}')
|
||||||
br
|
br
|
||||||
- if (user)
|
- if (user)
|
||||||
a.btn.btn-primary.btn-lg.btn-block#completed-courseware I've completed this challenge (ctrl + enter)
|
a.btn.btn-primary.btn-lg.btn-block#completed-zipline-or-basejump I've completed this challenge (ctrl + enter)
|
||||||
script.
|
script.
|
||||||
var userLoggedIn = true;
|
var userLoggedIn = true;
|
||||||
- else
|
- else
|
||||||
@ -26,6 +26,7 @@ block content
|
|||||||
var challengeName = !{JSON.stringify(name)};
|
var challengeName = !{JSON.stringify(name)};
|
||||||
var passedCoursewareName = challengeName;
|
var passedCoursewareName = challengeName;
|
||||||
var started = Math.floor(Date.now());
|
var started = Math.floor(Date.now());
|
||||||
|
var challengeType = !{JSON.stringify(challengeType)};
|
||||||
#complete-zipline-or-basejump-dialog.modal(tabindex='-1')
|
#complete-zipline-or-basejump-dialog.modal(tabindex='-1')
|
||||||
.modal-dialog.animated.zoomIn.fast-animation
|
.modal-dialog.animated.zoomIn.fast-animation
|
||||||
.modal-content
|
.modal-content
|
||||||
@ -40,21 +41,21 @@ block content
|
|||||||
.form-group.text-center
|
.form-group.text-center
|
||||||
.col-xs-10.col-xs-offset-1.col-sm-8.col-sm-offset-2.col-md-8.col-md-offset-2.animated.fadeIn
|
.col-xs-10.col-xs-offset-1.col-sm-8.col-sm-offset-2.col-md-8.col-md-offset-2.animated.fadeIn
|
||||||
|
|
||||||
// extra field to distract password tools like lastpass from injecting css into our username field
|
// extra field to distract password tools like lastpass from injecting css into our username field
|
||||||
input.form-control(ng-show="false")
|
input.form-control(ng-show="false")
|
||||||
if (challengeType === 'zipline')
|
if (challengeType === 3)
|
||||||
input.form-control#public-url(name="codepenUrl", placeholder="http://codepen.io/your-pen-here", autofocus)
|
input.form-control#public-url(name="codepenUrl", placeholder="http://codepen.io/your-pen-here", autofocus)
|
||||||
else
|
else
|
||||||
input.form-control#public-url(name="depoloymentUrl", placeholder="http://yourapp.com", autofocus)
|
input.form-control#public-url(name="depoloymentUrl", placeholder="http://yourapp.com", autofocus)
|
||||||
input.form-control#github-url(name="githubUrl", placeholder="http://github.com/camper/project")
|
input.form-control#github-url(name="githubUrl", placeholder="http://github.com/camper/project")
|
||||||
|
|
||||||
input.form-control#completed-with(name="existingUser", placeholder="If you paired, enter your pair's username here", existing-username='', ng-model="existingUser")
|
input.form-control#completed-with(name="existingUser", placeholder="If you paired, enter your pair's username here", existing-username='', ng-model="existingUser")
|
||||||
.col-xs-10.col-xs-offset-1.col-sm-8.col-sm-offset-2.col-md-8.col-md-offset-2(ng-cloak, ng-show="completedWithForm.$error.exists && !completedWithForm.existingUser.$pristine && existingUser.length > 0")
|
.col-xs-10.col-xs-offset-1.col-sm-8.col-sm-offset-2.col-md-8.col-md-offset-2(ng-cloak, ng-show="completedWithForm.$error.exists && !completedWithForm.existingUser.$pristine && existingUser.length > 0")
|
||||||
alert(type='danger')
|
alert(type='danger')
|
||||||
span.ion-close-circled
|
span.ion-close-circled
|
||||||
| Username not found
|
| Username not found
|
||||||
|
|
||||||
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block.next-bonfire-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid && existingUser.length > 0') Go to my next bonfire (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 (user.progressTimestamps.length > 2)
|
- if (user.progressTimestamps.length > 2)
|
||||||
@ -64,10 +65,8 @@ block content
|
|||||||
- else
|
- else
|
||||||
a.animated.fadeIn.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
|
||||||
script.
|
script.
|
||||||
var challengeName = !{JSON.stringify(name)};
|
|
||||||
var passedCoursewareHash = !{JSON.stringify(coursewareHash)};
|
|
||||||
$('body').on('keypress', function(e) {
|
$('body').on('keypress', function(e) {
|
||||||
if (e.ctrlKey && e.keyCode == 13) {
|
if (e.ctrlKey && e.keyCode == 13) {
|
||||||
$('#complete-courseware-dialog').modal('show');
|
$('#complete-zipline-or-basejump-dialog').modal('show');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user