diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 9511ab33cc..6830f00dc5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -7,6 +7,6 @@ We welcome pull requests from Free Code Camp campers (our students) and seasoned
2. Pick an issue that nobody has claimed and start working on it. If your issue isn't on the board, open an issue. If you think you can fix it yourself, start working on it. Feel free to ask for help in our [Gitter](https://gitter.im/FreeCodeCamp/FreeCodeCamp).
3. Fork the project ([Need help with forking a project?](https://help.github.com/articles/fork-a-repo/)). You'll do all of your work on your forked copy.
4. Create a branch specific to the issue or feature you are working on. Push your work to that branch. ([Need help with branching?](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches))
-5. Name the branch something like `fix/xxx` or `feature/xxx` where `xxx` is a short description of the changes or feature you are attempting to add. For example `fix/email-login` whould be a branch where I fix something specific to email login.
-6. You should have [ESLint running in your editor](http://eslint.org/docs/user-guide/integrations.html), and it will highlight anything doesn't conform to [Free Code Camp's JavaScript Style Guide](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Free-Code-Camp-JavaScript-Style-Guide) (you can find a summory of those rules [here](https://github.com/FreeCodeCamp/FreeCodeCamp/blob/staging/.eslintrc). Please do not ignore any linting errors, as they are meant to **help** you and to ensure a clean and simple code base. Make sure none of your JavaScript is longer than 80 characters per line.
-7. Once your code is ready, submit a pull request from your branch to Free Code Camp's `staging` branch. We'll do a quick code review and give you feedback, then iterate from there. It may also be helpful to read about git [rebasing](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/git-rebase).
+5. Name the branch something like `fix/xxx` or `feature/xxx` where `xxx` is a short description of the changes or feature you are attempting to add. For example `fix/email-login` would be a branch where I fix something specific to email login.
+6. You should have [ESLint running in your editor](http://eslint.org/docs/user-guide/integrations.html), and it will highlight anything doesn't conform to [Free Code Camp's JavaScript Style Guide](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Free-Code-Camp-JavaScript-Style-Guide) (you can find a summary of those rules [here](https://github.com/FreeCodeCamp/FreeCodeCamp/blob/staging/.eslintrc). Please do not ignore any linting errors, as they are meant to **help** you and to ensure a clean and simple code base. Make sure none of your JavaScript is longer than 80 characters per line.
+7. Once your code is ready, submit a [pull request](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Pull-Request-Contribute) from your branch to Free Code Camp's `staging` branch. We'll do a quick code review and give you feedback, then iterate from there. It may also be helpful to read about git [rebasing](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/git-rebase).
diff --git a/README.md b/README.md
index 7590eccafe..9b0c87d631 100644
--- a/README.md
+++ b/README.md
@@ -7,7 +7,7 @@
Welcome to Free Code Camp's open source codebase!
=======================
-Free Code Camp is an open-source community of busy people who learn to code, then build projects for nonprofits.
+Free Code Camp is an open-source community of busy people who learn to code and build projects for nonprofits.
Our campers (students) start by working through our free, self-paced, browser-based curriculum. Next, they build several practice projects. Finally, we pair two campers together with a stakeholder from a nonprofit organization, and help them build the solution the nonprofit has requested.
@@ -24,7 +24,7 @@ This code is running live at [FreeCodeCamp.com](http://www.FreeCodeCamp.com). We
Wiki
------------
-We would love your help expanding our [wiki](https://github.com/freecodecamp/freecodecamp/wiki) with more information about learning to code and getting a coding job.
+We would love your help expanding our [wiki](https://github.com/freecodecamp/freecodecamp/wiki). Our goal is to become a great resource for people learning to code, building local coding communities, and applying for coding jobs.
Contributing
------------
@@ -35,9 +35,9 @@ We welcome pull requests from Free Code Camp campers (our students) and seasoned
2. Pick an issue that nobody has claimed and start working on it. If your issue isn't on the board, open an issue. If you think you can fix it yourself, start working on it. Feel free to ask for help in our [Gitter](https://gitter.im/FreeCodeCamp/FreeCodeCamp).
3. Fork the project ([Need help with forking a project?](https://help.github.com/articles/fork-a-repo/)). You'll do all of your work on your forked copy.
4. Create a branch specific to the issue or feature you are working on. Push your work to that branch. ([Need help with branching?](https://github.com/Kunena/Kunena-Forum/wiki/Create-a-new-branch-with-git-and-manage-branches))
-5. Name the branch something like `fix/xxx` or `feature/xxx` where `xxx` is a short description of the changes or feature you are attempting to add. For example `fix/email-login` whould be a branch where I fix something specific to email login.
-6. You should have [ESLint running in your editor](http://eslint.org/docs/user-guide/integrations.html), and it will highlight anything doesn't conform to [Free Code Camp's JavaScript Style Guide](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Free-Code-Camp-JavaScript-Style-Guide) (you can find a summory of those rules [here](https://github.com/FreeCodeCamp/FreeCodeCamp/blob/staging/.eslintrc). Please do not ignore any linting errors, as they are meant to **help** you and to ensure a clean and simple code base. Make sure none of your JavaScript is longer than 80 characters per line.
-7. Once your code is ready, submit a pull request from your branch to Free Code Camp's `staging` branch. We'll do a quick code review and give you feedback, then iterate from there. It may also be helpful to read about git [rebasing](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/git-rebase).
+5. Name the branch something like `fix/xxx` or `feature/xxx` where `xxx` is a short description of the changes or feature you are attempting to add. For example `fix/email-login` would be a branch where I fix something specific to email login.
+6. You should have [ESLint running in your editor](http://eslint.org/docs/user-guide/integrations.html), and it will highlight anything doesn't conform to [Free Code Camp's JavaScript Style Guide](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Free-Code-Camp-JavaScript-Style-Guide) (you can find a summary of those rules [here](https://github.com/FreeCodeCamp/FreeCodeCamp/blob/staging/.eslintrc). Please do not ignore any linting errors, as they are meant to **help** you and to ensure a clean and simple code base. Make sure none of your JavaScript is longer than 80 characters per line.
+7. Once your code is ready, submit a [pull request](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/Pull-Request-Contribute) from your branch to Free Code Camp's `staging` branch. We'll do a quick code review and give you feedback, then iterate from there. It may also be helpful to read about git [rebasing](https://github.com/FreeCodeCamp/FreeCodeCamp/wiki/git-rebase).
Prerequisites
-------------
@@ -110,8 +110,8 @@ DEBUG=true
# Start the mongo server
mongod
-# Create your mongo database.
-# Type "mongo" in your terminal to access the mongo shell
+# Create your mongo database.
+# Type "mongo" in your terminal to access the mongo shell
use freecodecamp
# Exit the mongo shell with control + d
diff --git a/bower.json b/bower.json
index cd8cfd5cf3..1f833167fc 100644
--- a/bower.json
+++ b/bower.json
@@ -26,6 +26,7 @@
"moment": "~2.10.2",
"angular-bootstrap": "~0.13.0",
"ramda": "~0.13.0",
- "jshint": "~2.7.0"
+ "jshint": "~2.7.0",
+ "lightbox2": "~2.8.1"
}
}
diff --git a/client/commonFramework.js b/client/commonFramework.js
index be5be4533c..3a8a0c808a 100644
--- a/client/commonFramework.js
+++ b/client/commonFramework.js
@@ -1,6 +1,23 @@
-/* globals jailed, CodeMirror, challenge_Id, challenge_Name, challengeType */
+// common namespace
+// all classes should be stored here
+var common = common || {
+ // init is an array of functions that are
+ // called at the beginning of dom ready
+ init: []
+};
+
+common.challengeName = common.challengeName || window.challenge_Name ?
+ window.challenge_Name :
+ '';
+
+common.challengeType = common.challengeType || window.challengeType ?
+ window.challengeType :
+ 0;
+
+common.challengeId = common.challengeId || window.challenge_Id;
+
// codeStorage
-var codeStorageFactory = (function($, localStorage) {
+common.codeStorageFactory = (function($, localStorage) {
var CodeStorageProps = {
version: 0.01,
@@ -68,8 +85,45 @@ var codeStorageFactory = (function($, localStorage) {
return codeStorageFactory;
}($, localStorage));
-var sandBox = (function() {
+common.codeOutput = (function(CodeMirror, document, challengeType) {
+ if (!CodeMirror) {
+ return {};
+ }
+ if (
+ challengeType === '0' ||
+ challengeType === '7'
+ ) {
+ return {};
+ }
+ var codeOutput = CodeMirror.fromTextArea(
+ document.getElementById('codeOutput'),
+ {
+ lineNumbers: false,
+ mode: 'text',
+ theme: 'monokai',
+ readOnly: 'nocursor',
+ lineWrapping: true
+ }
+ );
+ codeOutput.setValue(
+ '/**\n' +
+ ' * Your output will go here.\n' +
+ ' * Console.log() -type statements\n' +
+ ' * will appear in your browser\'s\n' +
+ ' * DevTools JavaScript console.\n' +
+ ' */'
+ );
+
+ codeOutput.setSize('100%', '100%');
+
+ return codeOutput;
+}(window.CodeMirror, window.document, common.challengeType || 0));
+
+var sandBox = (function(jailed, codeOutput) {
+ if (!jailed) {
+ return {};
+ }
var plugin = null;
var sandBox = {
@@ -150,7 +204,7 @@ var sandBox = (function() {
endLoading();
console.log('resetting on fatal plugin error');
- if (challengeType === 0) {
+ if (common.challengeType === 0) {
codeOutput.setValue(
'Sorry, your code is either too slow, has a fatal error, ' +
'or contains an infinite loop.'
@@ -163,7 +217,7 @@ var sandBox = (function() {
reset();
sandBox.submit = submit;
return sandBox;
-}());
+}(window.jailed, common.codeOutput));
function replaceSafeTags(value) {
return value
@@ -180,33 +234,105 @@ var BDDregex = new RegExp(
var isInitRun = false;
var initPreview = true;
-var editor;
-editor = CodeMirror.fromTextArea(document.getElementById('codeEditor'), {
- lineNumbers: true,
- mode: 'text',
- theme: 'monokai',
- runnable: true,
- matchBrackets: true,
- autoCloseBrackets: true,
- scrollbarStyle: 'null',
- lineWrapping: true,
- gutters: ['CodeMirror-lint-markers']
-});
+var editor = (function(CodeMirror, emmetCodeMirror, common) {
+ var codeStorageFactory = common.codeStorageFactory;
+ if (!CodeMirror) {
+ return {};
+ }
-var codeStorage = codeStorageFactory(editor, challenge_Name);
-var myCodeMirror = editor;
+ var editor = CodeMirror.fromTextArea(document.getElementById('codeEditor'), {
+ lineNumbers: true,
+ mode: 'text',
+ theme: 'monokai',
+ runnable: true,
+ matchBrackets: true,
+ autoCloseBrackets: true,
+ scrollbarStyle: 'null',
+ lineWrapping: true,
+ gutters: ['CodeMirror-lint-markers']
+ });
+
+ editor.setSize('100%', 'auto');
+
+ var codeStorage = common.codeStorage =
+ codeStorageFactory(editor, common.challengeName);
+
+ editor.on('keyup', function() {
+ clearTimeout(codeStorage.updateTimeoutId);
+ codeStorage.updateTimeoutId = setTimeout(
+ codeStorage.updateStorage.bind(codeStorage),
+ codeStorage.updateWait
+ );
+ });
+
+ // Initialize CodeMirror editor with a nice html5 canvas demo.
+ editor.on('keyup', function() {
+ clearTimeout(delay);
+ delay = setTimeout(updatePreview, 300);
+ });
+
+ editor.setOption('extraKeys', {
+ Tab: function(cm) {
+ if (cm.somethingSelected()) {
+ cm.indentSelection('add');
+ } else {
+ var spaces = Array(cm.getOption('indentUnit') + 1).join(' ');
+ cm.replaceSelection(spaces);
+ }
+ },
+ 'Shift-Tab': function(cm) {
+ if (cm.somethingSelected()) {
+ cm.indentSelection('subtract');
+ } else {
+ var spaces = Array(cm.getOption('indentUnit') + 1).join(' ');
+ cm.replaceSelection(spaces);
+ }
+ },
+ 'Ctrl-Enter': function() {
+ isInitRun = false;
+ bonfireExecute(true);
+ return false;
+ }
+ });
+
+
+ var info = editor.getScrollInfo();
+
+ var after = editor.charCoords({
+ line: editor.getCursor().line + 1,
+ ch: 0
+ }, 'local').top;
+
+ if (info.top + info.clientHeight < after) {
+ editor.scrollTo(null, after - info.clientHeight + 3);
+ }
+
+ if (emmetCodeMirror) {
+ emmetCodeMirror(
+ editor,
+ {
+ 'Cmd-E': 'emmet.expand_abbreviation',
+ Tab: 'emmet.expand_abbreviation_with_tab',
+ Enter: 'emmet.insert_formatted_line_break_only'
+ }
+ );
+ }
+ common.init.push(function() {
+ editorValue = codeStorage.isAlive() ?
+ codeStorage.getStoredValue() :
+ allSeeds;
+
+ editor.setValue(replaceSafeTags(editorValue));
+ editor.refresh();
+ });
+
+ return editor;
+}(window.CodeMirror, window.emmetCodeMirror, common));
-editor.on('keyup', function() {
- clearTimeout(codeStorage.updateTimeoutId);
- codeStorage.updateTimeoutId = setTimeout(
- codeStorage.updateStorage.bind(codeStorage),
- codeStorage.updateWait
- );
-});
var editorValue;
-var challengeSeed = challengeSeed || null;
+var challengeSeed = challengeSeed || [];
var tests = tests || [];
var allSeeds = '';
@@ -216,31 +342,6 @@ var allSeeds = '';
});
})();
-editor.setOption('extraKeys', {
- Tab: function(cm) {
- if (cm.somethingSelected()) {
- cm.indentSelection('add');
- } else {
- var spaces = Array(cm.getOption('indentUnit') + 1).join(' ');
- cm.replaceSelection(spaces);
- }
- },
- 'Shift-Tab': function(cm) {
- if (cm.somethingSelected()) {
- cm.indentSelection('subtract');
- } else {
- var spaces = Array(cm.getOption('indentUnit') + 1).join(' ');
- cm.replaceSelection(spaces);
- }
- },
- 'Ctrl-Enter': function() {
- bonfireExecute(true);
- return false;
- }
-});
-
-editor.setSize('100%', 'auto');
-
var libraryIncludes = "" +
"" +
"" +
@@ -283,7 +384,8 @@ function scopejQuery(str) {
}
function safeHTMLRun(test) {
- if (challengeType === '0') {
+ var codeStorage = common.codeStorage;
+ if (common.challengeType === '0') {
var previewFrame = document.getElementById('preview');
var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
if (editor.getValue().match(/\