Merge branch 'staging' into feature/ctrl-enter-submit

Conflicts:
	server/views/coursewares/showBonfire.jade
	server/views/coursewares/showHTML.jade
This commit is contained in:
Quincy Larson
2015-09-09 18:32:31 -07:00
15 changed files with 188 additions and 196 deletions

View File

@ -216,6 +216,16 @@ var allSeeds = '';
}); });
})(); })();
if (typeof emmetCodeMirror !== 'undefined') {
var defaultKeymap = {
'Cmd-E': 'emmet.expand_abbreviation',
'Tab': 'emmet.expand_abbreviation_with_tab',
'Enter': 'emmet.insert_formatted_line_break_only'
};
emmetCodeMirror(editor, defaultKeymap);
}
editor.setOption('extraKeys', { editor.setOption('extraKeys', {
Tab: function(cm) { Tab: function(cm) {
if (cm.somethingSelected()) { if (cm.somethingSelected()) {
@ -401,9 +411,13 @@ var postError = function(data) {
var goodTests = 0; var goodTests = 0;
var testSuccess = function() { var testSuccess = function() {
goodTests++; goodTests++;
// test successful run show completion
if (goodTests === tests.length) { if (goodTests === tests.length) {
showCompletion(); return showCompletion();
} }
// test unsuccessful, make sure initRun is set to false
isInitRun = false;
}; };
function showCompletion() { function showCompletion() {
@ -465,7 +479,7 @@ function showCompletion() {
}, },
function(res) { function(res) {
if (res) { if (res) {
window.location = '/challenges/next-challenge'; window.location = '/challenges/next-challenge?id=' + challenge_Id;
} }
} }
); );
@ -632,7 +646,9 @@ var runTests = function(err, data) {
) { ) {
try { try {
if (chaiTestFromJSON) { if (chaiTestFromJSON) {
/* eslint-disable no-eval */
var output = eval(reassembleTest(chaiTestFromJSON, data)); var output = eval(reassembleTest(chaiTestFromJSON, data));
/* eslint-enable no-eval */
} }
} catch (error) { } catch (error) {
allTestsPassed = false; allTestsPassed = false;
@ -647,8 +663,7 @@ var runTests = function(err, data) {
if (allTestsPassed) { if (allTestsPassed) {
allTestsPassed = false; allTestsPassed = false;
showCompletion(); showCompletion();
} } else {
else{
isInitRun = false; isInitRun = false;
} }
} }

View File

@ -141,7 +141,7 @@ $(document).ready(function() {
}).success( }).success(
function(res) { function(res) {
if (res) { if (res) {
window.location.href = '/challenges/next-challenge'; window.location.href = '/challenges/next-challenge?id=' + challenge_Id;
} }
}).fail( }).fail(
function() { function() {
@ -164,7 +164,7 @@ $(document).ready(function() {
} }
}).success( }).success(
function() { function() {
window.location.href = '/challenges/next-challenge'; window.location.href = '/challenges/next-challenge?id=' + challenge_Id;
}).fail( }).fail(
function() { function() {
window.location.href = '/challenges'; window.location.href = '/challenges';
@ -187,13 +187,13 @@ $(document).ready(function() {
verified: false verified: false
} }
}).success(function() { }).success(function() {
window.location.href = '/challenges/next-challenge'; window.location.href = '/challenges/next-challenge?id=' + challenge_Id;
}).fail(function() { }).fail(function() {
window.location.replace(window.location.href); window.location.replace(window.location.href);
}); });
break; break;
case challengeTypes.BONFIRE: case challengeTypes.BONFIRE:
window.location.href = '/challenges/next-challenge'; window.location.href = '/challenges/next-challenge?id=' + challenge_Id;
default: default:
break; break;
} }

View File

@ -1,13 +1,13 @@
// MDN Links /**
* MDN Links
*
* These links are for Bonfires. Each key/value pair is used to render a Bonfire with appropriate links.
* The text of the key is what the link text will be, e.g. <a href="https://developer ...">Global Array Object</a>
* General convention is to use the page title of the MDN reference page.
*
**/
/* These links are for Bonfires. Each key/value pair is used to render a Bonfire with appropriate links. var links = {
The text of the key is what the link text will be, e.g. <a href="https://developer ...">Global Array Object</a>
General convention is to use the page title of the MDN reference page.
*/
var links =
{
// ========= NON MDN REFS // ========= NON MDN REFS
"Currying": "https://leanpub.com/javascript-allonge/read#pabc", "Currying": "https://leanpub.com/javascript-allonge/read#pabc",
"Smallest Common Multiple": "https://www.mathsisfun.com/least-common-multiple.html", "Smallest Common Multiple": "https://www.mathsisfun.com/least-common-multiple.html",
@ -15,80 +15,81 @@ var links =
"HTML Entities": "http://dev.w3.org/html5/html-author/charref", "HTML Entities": "http://dev.w3.org/html5/html-author/charref",
"Symmetric Difference": "https://www.youtube.com/watch?v=PxffSUQRkG4", "Symmetric Difference": "https://www.youtube.com/watch?v=PxffSUQRkG4",
"Roman Numerals": "http://www.mathsisfun.com/roman-numerals.html", "Roman Numerals": "http://www.mathsisfun.com/roman-numerals.html",
// ========= GLOBAL OBJECTS // ========= GLOBAL OBJECTS
"Global Array Object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array", "Global Array Object": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array",
"Global Object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object", "Global Object": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object",
"Global String Object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String", "Global String Object": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String",
"Boolean Objects" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean", "Boolean Objects": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean",
"RegExp" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp", "RegExp": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp",
"Global Function Object": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function", "Global Function Object": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function",
"Arguments object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments", "Arguments object": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments",
"Closures": "https://developer.mozilla.org/en-US/docs/" + "Closures": "https://developer.mozilla.org/en-US/docs/" +
"Web/JavaScript/Closures", "Web/JavaScript/Closures",
// ========= GLOBAL OBJECT METHODS // ========= GLOBAL OBJECT METHODS
"parseInt()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt", "parseInt()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt",
// ========= PROPERTIES/MISC // ========= PROPERTIES/MISC
"String.length" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length", "String.length": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length",
// ========== OBJECT METHODS // ========== OBJECT METHODS
"Object.getOwnPropertyNames()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames", "Object.getOwnPropertyNames()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames",
"Object.keys()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys", "Object.keys()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys",
"Object.hasOwnProperty()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty", "Object.hasOwnProperty()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty",
// ======== STRING METHODS // ======== STRING METHODS
"String.charAt()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt", "String.charAt()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charAt",
"String.charCodeAt()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt", "String.charCodeAt()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/charCodeAt",
"String.concat()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat", "String.concat()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/concat",
"String.indexOf()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf", "String.indexOf()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf",
"String.fromCharCode()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode", "String.fromCharCode()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode",
"String.lastIndexOf()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf", "String.lastIndexOf()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf",
"String.match()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match", "String.match()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match",
"String.replace()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace", "String.replace()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace",
"String.slice()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice", "String.slice()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/slice",
"String.split()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split", "String.split()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split",
"String.substring()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring", "String.substring()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring",
"String.substr()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr", "String.substr()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr",
"String.toLowerCase()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase", "String.toLowerCase()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLowerCase",
"String.toString()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString", "String.toString()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toString",
"String.toUpperCase()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase", "String.toUpperCase()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toUpperCase",
// ======== ARRAY METHODS
"Array.concat()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat",
"Array.every()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every",
"Array.filter()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter",
"Array.forEach()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach",
"Array.indexOf()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf",
"Array.isArray()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray",
"Array.join()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join",
"Array.lastIndexOf()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf",
"Array.map()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map",
"Array.pop()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop",
"Array.push()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push",
"Array.reduce()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce",
"Array.reverse()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse",
"Array.shift()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift",
"Array.slice()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice",
"Array.some()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some",
"Array.sort()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort",
"Array.splice()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice",
"Array.toString()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString",
// ======== MATH METHODS // ======== ARRAY METHODS
"Math.max()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max", "Array.concat()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/concat",
"Math.min()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min", "Array.every()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every",
"Math.pow()" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow", "Array.filter()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter",
"Remainder" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder_(.25)", "Array.forEach()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach",
"Array.indexOf()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf",
"Array.isArray()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray",
"Array.join()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join",
"Array.lastIndexOf()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf",
"Array.map()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map",
"Array.pop()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop",
"Array.push()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push",
"Array.reduce()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce",
"Array.reverse()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse",
"Array.shift()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift",
"Array.slice()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice",
"Array.some()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some",
"Array.sort()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort",
"Array.splice()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice",
"Array.toString()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString",
// ======== GENERAL JAVASCRIPT REFERENCES // ======== MATH METHODS
"Arithmetic Operators" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators", "Math.max()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max",
"Comparison Operators" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators", "Math.min()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/min",
"Details of the Object Model" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model", "Math.pow()": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow",
"Remainder": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators#Remainder_(.25)",
// ======== GENERAL JAVASCRIPT REFERENCES
"Arithmetic Operators": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Arithmetic_Operators",
"Comparison Operators": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comparison_Operators",
"Details of the Object Model": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Details_of_the_Object_Model",
"For Loops": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for" "For Loops": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for"
}; };
module.exports = links; module.exports = links;

View File

@ -136,17 +136,18 @@
"Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code." "Remember to use <a href='//github.com/FreeCodeCamp/freecodecamp/wiki/How-to-get-help-when-you-get-stuck' target='_blank'>Read-Search-Ask</a> if you get stuck. Write your own code."
], ],
"tests": [ "tests": [
"expect(palindrome(\"eye\")).to.be.a(\"boolean\");", "assert.isBoolean(palindrome(\"\"), \"palindrome() function returns a Boolean value\");",
"assert.deepEqual(palindrome(\"eye\"), true);", "assert.strictEqual(palindrome(\"eye\"), true, \"\\\"eye\\\" is a palindrome\");",
"assert.deepEqual(palindrome(\"race car\"), true);", "assert.strictEqual(palindrome(\"Race Car\"), true, \"\\\"Race Car\\\" is a palindrome\");",
"assert.deepEqual(palindrome(\"not a palindrome\"), false);", "assert.strictEqual(palindrome(\"not a palindrome\"), false, \"\\\"not a palindrome\\\" is not a palindrome\");",
"assert.deepEqual(palindrome(\"A man, a plan, a canal. Panama\"), true);", "assert.strictEqual(palindrome(\"A man, a plan, a canal. Panama\"), true, \"\\\"A man, a plan, a canal. Panama\\\" is a palindrome\");",
"assert.deepEqual(palindrome(\"never odd or even\"), true);", "assert.strictEqual(palindrome(\"Never odd OR even\"), true, \"\\\"Never odd OR even\\\" is a palindrome\");",
"assert.deepEqual(palindrome(\"nope\"), false);", "assert.strictEqual(palindrome(\"Nope\"), false, \"\\\"Nope\\\" is not a palindrome\");",
"assert.deepEqual(palindrome(\"almostomla\"), false);", "assert.strictEqual(palindrome(\"almostomla\"), false, \"\\\"almostomla\\\" is not a palindrome\");",
"assert.deepEqual(palindrome(\"My age is 0, 0 si ega ym.\"), true);", "assert.strictEqual(palindrome(\"My age is 0, 0 si ega ym.\"), true, \"\\\"My age is 0, 0 si ega ym.\\\" is a palindrome\");",
"assert.deepEqual(palindrome(\"I'm 23 non 32 m'I?\"), true);", "assert.strictEqual(palindrome(\"I'm 23 non 32 m'I?\"), true, \"\\\"I'm 23 non 32 m'I?\\\" is a palindrome\");",
"assert.deepEqual(palindrome(\"1 eye for of 1 eye.\"), false);" "assert.strictEqual(palindrome(\"1 eye for of 1 eye.\"), false, \"\\\"1 eye for of 1 eye.\\\" is not a palindrome\");",
"assert.strictEqual(palindrome(\"0_0 (: /-\\ :) 0-0\"), true, \"\\\"0_0 (: /-\\\\ :) 0-0\\\" is a palindrome\");"
], ],
"challengeSeed": [ "challengeSeed": [
"function palindrome(str) {", "function palindrome(str) {",

View File

@ -1722,7 +1722,7 @@
"Create two <code>div</code> elements within your row, both with the class <code>col-xs-6</code>." "Create two <code>div</code> elements within your row, both with the class <code>col-xs-6</code>."
], ],
"tests": [ "tests": [
"assert($(\"div.row\").children(\"div.col-xs-6\").length > 1, 'Nest two <code>div class=\"col-xs-6\"</code> elements within your <code>div class=\"row\"</code> element.')", "assert($(\"div.row > div.col-xs-6\").length > 1, 'Nest two <code>div class=\"col-xs-6\"</code> elements within your <code>div class=\"row\"</code> element.')",
"assert(editor.match(/<\\/div>/g) && editor.match(/<div/g) && editor.match(/<\\/div>/g).length === editor.match(/<div/g).length, 'Make sure all your <code>div</code> elements have closing tags.')" "assert(editor.match(/<\\/div>/g) && editor.match(/<div/g) && editor.match(/<\\/div>/g).length === editor.match(/<div/g).length, 'Make sure all your <code>div</code> elements have closing tags.')"
], ],
"challengeSeed": [ "challengeSeed": [
@ -1756,8 +1756,8 @@
"Nest one <code>div</code> element with the class <code>well</code> within each of your <code>col-xs-6</code> <code>div</code> elements." "Nest one <code>div</code> element with the class <code>well</code> within each of your <code>col-xs-6</code> <code>div</code> elements."
], ],
"tests": [ "tests": [
"assert($(\"div\").length > 4, 'Add a <code>div</code> element with the class <code>well</code> inside each of your <code>div class=\"col-xs-6\" elements</code>')", "assert($(\"div.col-xs-6\").not(\":has(>div.well)\").length < 1, 'Add a <code>div</code> element with the class <code>well</code> inside each of your <code>div class=\"col-xs-6\" elements</code>')",
"assert($(\"div.col-xs-6 div.well\").length > 1, 'Nest both of your <code>div class=\"col-xs-6\"</code> elements within your <code>div class=\"row\"</code> element.')", "assert($(\"div.row > div.col-xs-6\").length > 1, 'Nest both of your <code>div class=\"col-xs-6\"</code> elements within your <code>div class=\"row\"</code> element.')",
"assert(editor.match(/<\\/div>/g) && editor.match(/<div/g) && editor.match(/<\\/div>/g).length === editor.match(/<div/g).length, 'Make sure all your <code>div</code> elements have closing tags.')" "assert(editor.match(/<\\/div>/g) && editor.match(/<div/g) && editor.match(/<\\/div>/g).length === editor.match(/<div/g).length, 'Make sure all your <code>div</code> elements have closing tags.')"
], ],
"challengeSeed": [ "challengeSeed": [

View File

@ -16,8 +16,8 @@
"tests": [ "tests": [
"assert(editor.match(/<script>/g), 'Create a <code>script</code> element.')", "assert(editor.match(/<script>/g), 'Create a <code>script</code> element.')",
"assert(editor.match(/<\\/script>/g) && editor.match(/<script/g) && editor.match(/<\\/script>/g).length === editor.match(/<script/g).length, 'Make sure your <code>script</code> element has a closing tag.')", "assert(editor.match(/<\\/script>/g) && editor.match(/<script/g) && editor.match(/<\\/script>/g).length === editor.match(/<script/g).length, 'Make sure your <code>script</code> element has a closing tag.')",
"assert(editor.match(/\\$\\s*?\\(\\s*?document\\)\\.ready\\s*?\\(\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/g), 'Add <code>$(document).ready(function() {</code> to the beginning of your <code>script</code> element.')", "assert(editor.match(/\\$\\s*?\\(\\s*?document\\)\\.ready\\s*?\\(\\s*?function\\s*?\\(\\s*?\\)\\s*?\\{/g), 'You should add <code>$&#40;document&#41;.ready&#40;function&#40;&#41; {</code> to the beginning of your <code>script</code> element.')",
"assert(editor.match(/\\n*?\\s*?\\}\\s*?\\);/g), 'Close your <code>$(document).ready(function() {</code> function with <code>});</code>.')" "assert(editor.match(/\\n*?\\s*?\\}\\s*?\\);/g), 'Close your <code>$&#40;document&#41;.ready&#40;function&#40;&#41; {</code> function with <code>}&#41;;</code>.')"
], ],
"challengeSeed": [ "challengeSeed": [
"", "",

View File

@ -20,9 +20,9 @@
"Give your <code>motorBike</code> object a <code>wheels</code>, <code>engines</code> and <code>seats</code> attribute and set them to numbers." "Give your <code>motorBike</code> object a <code>wheels</code>, <code>engines</code> and <code>seats</code> attribute and set them to numbers."
], ],
"tests":[ "tests":[
"assert(typeof(motorBike.engines) === 'number', '<code>engines</code> should be have a <code>engines</code> attribute set to a number.');", "assert(typeof(motorBike.engines) === 'number', '<code>motorBike</code> should have a <code>engines</code> attribute set to a number.');",
"assert(typeof(motorBike.wheels) === 'number', '<code>wheels</code> should be have a <code>engines</code> attribute set to a number.');", "assert(typeof(motorBike.wheels) === 'number', '<code>motorBike</code> should have a <code>wheels</code> attribute set to a number.');",
"assert(typeof(motorBike.seats) === 'number', '<code>seats</code> should be have a <code>engines</code> attribute set to a number.');" "assert(typeof(motorBike.seats) === 'number', '<code>motorBike</code> should have a <code>seats</code> attribute set to a number.');"
], ],
"challengeSeed":[ "challengeSeed":[
"//Here is a sample Object", "//Here is a sample Object",
@ -54,12 +54,12 @@
"difficulty":0, "difficulty":0,
"description":[ "description":[
"We are also able to create objects using <code>constructor</code> functions.", "We are also able to create objects using <code>constructor</code> functions.",
"Give your <code>motorBike</code> object a <code>wheels</code>, <code>engines</code> and <code>seats</code> attribute and set them to numbers." "Give your <code>myMotorBike</code> object a <code>wheels</code>, <code>engines</code> and <code>seats</code> attribute and set them to numbers."
], ],
"tests":[ "tests":[
"assert(typeof((new MotorBike()).engines) === 'number', '<code>engines</code> should be have a <code>engines</code> attribute set to a number.');", "assert(typeof((new MotorBike()).engines) === 'number', '<code>myMotorBike</code> should have a <code>engines</code> attribute set to a number.');",
"assert(typeof((new MotorBike()).wheels) === 'number', '<code>wheels</code> should be have a <code>engines</code> attribute set to a number.');", "assert(typeof((new MotorBike()).wheels) === 'number', '<code>myMotorBike</code> should have a <code>wheels</code> attribute set to a number.');",
"assert(typeof((new MotorBike()).seats) === 'number', '<code>seats</code> should be have a <code>engines</code> attribute set to a number.');" "assert(typeof((new MotorBike()).seats) === 'number', '<code>myMotorBike</code> should have a <code>seats</code> attribute set to a number.');"
], ],
"challengeSeed":[ "challengeSeed":[
"// Let's add the properties engines and seats to the car in the same way that the property wheels has been added below. They should both be numbers.", "// Let's add the properties engines and seats to the car in the same way that the property wheels has been added below. They should both be numbers.",

View File

@ -14,7 +14,6 @@ import {
import { import {
userMigration, userMigration,
ifNoUserRedirectTo,
ifNoUserSend ifNoUserSend
} from '../utils/middleware'; } from '../utils/middleware';
@ -100,9 +99,6 @@ module.exports = function(app) {
const userCount$ = observeMethod(User, 'count'); const userCount$ = observeMethod(User, 'count');
const send200toNonUser = ifNoUserSend(true); const send200toNonUser = ifNoUserSend(true);
const redirectNonUser = ifNoUserRedirectTo(
'/challenges/learn-how-free-code-camp-works'
);
router.post( router.post(
'/completed-challenge/', '/completed-challenge/',
@ -125,26 +121,17 @@ module.exports = function(app) {
router.get('/map', challengeMap); router.get('/map', challengeMap);
router.get( router.get(
'/challenges/next-challenge', '/challenges/next-challenge',
redirectNonUser,
returnNextChallenge returnNextChallenge
); );
router.get('/challenges/:challengeName', returnIndividualChallenge); router.get('/challenges/:challengeName', returnIndividualChallenge);
router.get(
'/challenges/',
redirectNonUser,
returnCurrentChallenge
);
app.use(router); app.use(router);
function returnNextChallenge(req, res, next) { function returnNextChallenge(req, res, next) {
let nextChallengeName = firstChallenge; let nextChallengeName = firstChallenge;
const challengeId = req.user.currentChallenge ? const challengeId = req.query.id;
req.user.currentChallenge.challengeId :
'bd7123c8c441eddfaeb5bdef';
// find challenge // find challenge
return challenge$ return challenge$
@ -199,16 +186,13 @@ module.exports = function(app) {
nextChallengeName = nextChallenge.dashedName; nextChallengeName = nextChallenge.dashedName;
return nextChallengeName; return nextChallengeName;
}) })
.flatMap(() => {
return saveUser(req.user);
})
.subscribe( .subscribe(
function() {}, function() {},
next, next,
function() { function() {
debug('next challengeName', nextChallengeName); debug('next challengeName', nextChallengeName);
if (!nextChallengeName || nextChallengeName === firstChallenge) { if (!nextChallengeName || nextChallengeName === firstChallenge) {
req.flash('errors', { req.flash('info', {
msg: dedent` msg: dedent`
Once you have completed all of our challenges, you should Once you have completed all of our challenges, you should
join our <a href=\"//gitter.im/freecodecamp/HalfWayClub\" join our <a href=\"//gitter.im/freecodecamp/HalfWayClub\"
@ -223,34 +207,6 @@ module.exports = function(app) {
); );
} }
function returnCurrentChallenge(req, res, next) {
Observable.just(req.user)
.flatMap(user => {
if (!req.user.currentChallenge) {
return challenge$
.first()
.flatMap(challenge => {
user.currentChallenge = {
challengeId: challenge.id,
challengeName: challenge.name,
dashedName: challenge.dashedName
};
return saveUser(user);
});
}
return Observable.just(user);
})
.map(user => user.currentChallenge.dashedName)
.subscribe(
function(challengeName) {
res.redirect('/challenges/' + challengeName);
},
next,
function() {
}
);
}
function returnIndividualChallenge(req, res, next) { function returnIndividualChallenge(req, res, next) {
const origChallengeName = req.params.challengeName; const origChallengeName = req.params.challengeName;
const unDashedName = unDasherize(origChallengeName); const unDashedName = unDasherize(origChallengeName);
@ -285,40 +241,29 @@ module.exports = function(app) {
return Observable.just('/challenges/' + dasherize(challenge.name)); return Observable.just('/challenges/' + dasherize(challenge.name));
} }
if (challenge) { // save user does nothing if user does not exist
if (req.user) { return Observable.just({
req.user.currentChallenge = { title: challenge.name,
challengeId: challenge.id, dashedName: origChallengeName,
challengeName: challenge.name, name: challenge.name,
dashedName: challenge.dashedName details: challenge.description,
}; tests: challenge.tests,
} challengeSeed: challenge.challengeSeed,
verb: utils.randomVerb(),
// save user does nothing if user does not exist phrase: utils.randomPhrase(),
return saveUser(req.user) compliment: utils.randomCompliment(),
.map(() => ({ challengeId: challenge.id,
title: challenge.name, challengeType: challenge.challengeType,
dashedName: origChallengeName, // video challenges
name: challenge.name, video: challenge.challengeSeed[0],
details: challenge.description, // bonfires specific
tests: challenge.tests, difficulty: Math.floor(+challenge.difficulty),
challengeSeed: challenge.challengeSeed, bonfires: challenge,
verb: utils.randomVerb(), MDNkeys: challenge.MDNlinks,
phrase: utils.randomPhrase(), MDNlinks: getMDNLinks(challenge.MDNlinks),
compliment: utils.randomCompliment(), // htmls specific
challengeId: challenge.id, environment: utils.whichEnvironment()
challengeType: challenge.challengeType, });
// video challenges
video: challenge.challengeSeed[0],
// bonfires specific
difficulty: Math.floor(+challenge.difficulty),
bonfires: challenge,
MDNkeys: challenge.MDNlinks,
MDNlinks: getMDNLinks(challenge.MDNlinks),
// htmls specific
environment: utils.whichEnvironment()
}));
}
}) })
.subscribe( .subscribe(
function(data) { function(data) {

View File

@ -114,6 +114,7 @@ block content
var challenge_Name = !{JSON.stringify(name)}; var challenge_Name = !{JSON.stringify(name)};
var started = Math.floor(Date.now()); var started = Math.floor(Date.now());
var challengeType = !{JSON.stringify(challengeType)}; var challengeType = !{JSON.stringify(challengeType)};
var dashedName = !{JSON.stringify(dashedName)};
var _ = R; var _ = R;
var dashed = !{JSON.stringify(dashedName)}; var dashed = !{JSON.stringify(dashedName)};
@ -140,14 +141,14 @@ block content
.spacer .spacer
.row .row
if (user) if (user)
#submit-challenge.animated.fadeIn.btn.btn-lg.btn-primary.btn-block Submit and go to next challenge (Ctrl + enter) #submit-challenge.animated.fadeIn.btn.btn-lg.btn-primary.btn-block Submit and go to my next challenge (ctrl + enter)
if (user.progressTimestamps.length > 2) if (user.progressTimestamps.length > 2)
a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript") a.animated.fadeIn.btn.btn-lg.btn-block.btn-twitter(target="_blank", href="https://twitter.com/intent/tweet?text=I%20just%20#{verb}%20%40FreeCodeCamp%20#{name}&url=http%3A%2F%2Ffreecodecamp.com/challenges/#{dashedName}&hashtags=LearnToCode, JavaScript")
i.fa.fa-twitter &thinsp; i.fa.fa-twitter &thinsp;
= 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.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
#reset-modal.modal(tabindex='-1') #reset-modal.modal(tabindex='-1')
.modal-dialog.animated.fadeInUp.fast-animation .modal-dialog.animated.fadeInUp.fast-animation
.modal-content .modal-content

View File

@ -62,6 +62,7 @@ block content
var challenge_Id = !{JSON.stringify(challengeId)}; var challenge_Id = !{JSON.stringify(challengeId)};
var challenge_Name = !{JSON.stringify(name)}; var challenge_Name = !{JSON.stringify(name)};
var prodOrDev = !{JSON.stringify(environment)}; var prodOrDev = !{JSON.stringify(environment)};
var dashedName = !{JSON.stringify(dashedName)};
var challengeType = !{JSON.stringify(challengeType)}; 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
@ -91,7 +92,7 @@ block content
span.completion-icon.ion-checkmark-circled.text-primary span.completion-icon.ion-checkmark-circled.text-primary
.spacer .spacer
if(user) if(user)
#submit-challenge.animated.fadeIn.btn.btn-lg.btn-primary.btn-block Submit and go to next challenge (Ctrl + enter) #submit-challenge.animated.fadeIn.btn.btn-lg.btn-primary.btn-block Submit and go to my next challenge (ctrl + enter)
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.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
include ../partials/challenge-modals include ../partials/challenge-modals

View File

@ -61,6 +61,7 @@ block content
var challengeSeed = !{JSON.stringify(challengeSeed)}; var challengeSeed = !{JSON.stringify(challengeSeed)};
var challenge_Id = !{JSON.stringify(challengeId)}; var challenge_Id = !{JSON.stringify(challengeId)};
var challenge_Name = !{JSON.stringify(name)}; var challenge_Name = !{JSON.stringify(name)};
var dashedName = !{JSON.stringify(dashedName)};
var started = Math.floor(Date.now()); var started = Math.floor(Date.now());
var challengeType = !{JSON.stringify(challengeType)}; var challengeType = !{JSON.stringify(challengeType)};
var _ = R; var _ = R;
@ -93,7 +94,7 @@ block content
i.fa.fa-twitter &thinsp; i.fa.fa-twitter &thinsp;
= 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.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
include ../partials/challenge-modals include ../partials/challenge-modals
script. script.
var MDNlinks = !{JSON.stringify(MDNlinks)}; var MDNlinks = !{JSON.stringify(MDNlinks)};

View File

@ -17,7 +17,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-big.btn-block#completed-courseware-editorless I've completed this challenge (ctrl + enter) a.btn.btn-primary.btn-big.btn-block#completed-courseware-editorless I've completed this challenge (ctrl + enter)
script. script.
var userLoggedIn = true; var userLoggedIn = true;
.button-spacer .button-spacer
@ -30,6 +30,8 @@ block content
| &nbsp; Report a bug | &nbsp; Report a bug
.button-spacer .button-spacer
else else
a.animated.fadeIn.btn.btn-big.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge (ctrl + enter)
.button-spacer
a.btn.btn-big.signup-btn.btn-block(href='/login') Sign in so you can save your progress a.btn.btn-big.signup-btn.btn-block(href='/login') Sign in so you can save your progress
script. script.
var userLoggedIn = false; var userLoggedIn = false;
@ -64,7 +66,7 @@ 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
if (user) if (user)
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf) On to my next challenge (ctrl + enter) a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf) Go to my next challenge
script. script.
$('#complete-courseware-editorless-dialog').bind('keypress', modalControlEnterHandler); $('#complete-courseware-editorless-dialog').bind('keypress', modalControlEnterHandler);
@ -74,12 +76,12 @@ block content
i.fa.fa-twitter &thinsp; i.fa.fa-twitter &thinsp;
= 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.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
h1 #{name}
script. script.
$('body').bind('keypress', controlEnterHandler); $('body').bind('keypress', controlEnterHandler);
script. script.
var challenge_Id = !{JSON.stringify(challengeId)}; var challenge_Id = !{JSON.stringify(challengeId)};
var challenge_Name = !{JSON.stringify(name)}; var challenge_Name = !{JSON.stringify(name)};
var challengeType = !{JSON.stringify(challengeType)}; var challengeType = !{JSON.stringify(challengeType)};
var dashedName = !{JSON.stringify(dashedName)};
include ../partials/challenge-modals include ../partials/challenge-modals

View File

@ -17,7 +17,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-big.btn-block#completed-zipline-or-basejump I've completed this challenge (ctrl + enter) a.btn.btn-primary.btn-big.btn-block#completed-zipline-or-basejump I've completed this challenge (ctrl + enter)
.button-spacer .button-spacer
.btn-group.input-group.btn-group-justified .btn-group.input-group.btn-group-justified
.btn.btn-success.btn-big#trigger-help-modal .btn.btn-success.btn-big#trigger-help-modal
@ -33,7 +33,8 @@ block content
script. script.
var userLoggedIn = true; var userLoggedIn = true;
else else
a.btn.btn-lg.signup-btn.btn-block(href='/login') Sign in so you can save your progress a.animated.fadeIn.btn.btn-big.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge (ctrl + enter)
a.btn.btn-big.signup-btn.btn-block(href='/login') Sign in so you can save your progress
script. script.
var userLoggedIn = false; var userLoggedIn = false;
br br
@ -41,6 +42,7 @@ block content
var challenge_Id = !{JSON.stringify(challengeId)}; var challenge_Id = !{JSON.stringify(challengeId)};
var challenge_Name = !{JSON.stringify(name)}; var challenge_Name = !{JSON.stringify(name)};
var started = Math.floor(Date.now()); var started = Math.floor(Date.now());
var dashedName = !{JSON.stringify(dashedName)};
var challengeType = !{JSON.stringify(challengeType)}; var challengeType = !{JSON.stringify(challengeType)};
var controlEnterHandler = function (e) { var controlEnterHandler = function (e) {
$('body').unbind('keypress'); $('body').unbind('keypress');
@ -87,11 +89,12 @@ block content
| Username not found | Username not found
if (user) if (user)
a.animated.fadeIn.btn.btn-lg.btn-primary.btn-block#next-courseware-button(name='_csrf', value=_csrf, ng-disabled='completedWithForm.$invalid') 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') Go to my next challenge
.button-spacer
script. script.
$('#complete-zipline-or-basejump-dialog').on('keypress', modalControlEnterHandler); $('#complete-zipline-or-basejump-dialog').on('keypress', modalControlEnterHandler);
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.btn-primary.btn-block(href='/challenges/next-challenge?id=' + challengeId) Go to my next challenge
script. script.
$('body').on('keypress', controlEnterHandler); $('body').on('keypress', controlEnterHandler);
include ../partials/challenge-modals include ../partials/challenge-modals

View File

@ -47,3 +47,7 @@
h3 This will restore your code editor to its original state. h3 This will restore your code editor to its original state.
a.btn.btn-lg.btn-info.btn-block#reset-button(href='#', data-dismiss='modal', aria-hidden='true') Clear my code a.btn.btn-lg.btn-info.btn-block#reset-button(href='#', data-dismiss='modal', aria-hidden='true') Clear my code
a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel a.btn.btn-lg.btn-primary.btn-block(href='#', data-dismiss='modal', aria-hidden='true') Cancel
script.
if (typeof localStorage !== 'undefined') {
localStorage.setItem('currentDashedName', dashedName);
}

View File

@ -7,6 +7,8 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
img.img-responsive.nav-logo(src='https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg', alt='learn to code javascript at Free Code Camp logo') img.img-responsive.nav-logo(src='https://s3.amazonaws.com/freecodecamp/freecodecamp_logo.svg', alt='learn to code javascript at Free Code Camp logo')
.collapse.navbar-collapse .collapse.navbar-collapse
ul.nav.navbar-nav.navbar-right.hamburger-dropdown ul.nav.navbar-nav.navbar-right.hamburger-dropdown
li
a.learn-btn(href='#') Learn
li li
a(href='/map') Map a(href='/map') Map
li li
@ -32,3 +34,19 @@ nav.navbar.navbar-default.navbar-fixed-top.nav-height
.hidden-xs.hidden-sm .hidden-xs.hidden-sm
a(href='/account') a(href='/account')
img.profile-picture.float-right(src='#{user.picture}') img.profile-picture.float-right(src='#{user.picture}')
script.
$(document).ready(function() {
$('.learn-btn').click(function(e) {
var challengeDashedName = null;
e.preventDefault();
if (typeof dashedName === "string") {
return location.reload();
}
if (typeof localStorage !== 'undefined') {
challengeDashedName = localStorage.getItem('currentDashedName');
}
window.location = challengeDashedName ?
'/challenges/' + challengeDashedName :
'/map';
});
});