diff --git a/package.json b/package.json
index 4863f4d47a..7fe7c38bd8 100644
--- a/package.json
+++ b/package.json
@@ -70,6 +70,7 @@
"node-slack": "0.0.7",
"node-uuid": "^1.4.3",
"nodemailer": "~1.3.0",
+ "object.assign": "^3.0.0",
"passport-facebook": "^2.0.0",
"passport-google-oauth2": "^0.1.6",
"passport-linkedin-oauth2": "^1.2.1",
diff --git a/public/js/calculator.js b/public/js/calculator.js
index 8786b78bea..9cd991a9e7 100644
--- a/public/js/calculator.js
+++ b/public/js/calculator.js
@@ -154,6 +154,10 @@ $(document).ready(function () {
}, 1000);
});
+ d3.selectAll("#chart").on("click", function () {
+ change();
+ });
+
function change() {
if ($("body").data("state") === "stacked") {
transitionGrouped();
diff --git a/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js
index 16073e2554..ae7237ef5d 100644
--- a/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js
+++ b/public/js/lib/coursewares/coursewaresJSFramework_0.0.6.js
@@ -1,3 +1,7 @@
+$(document).ready(function() {
+ $('#reset-button').on('click', resetEditor);
+});
+
var widgets = [];
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {
lineNumbers: true,
@@ -41,73 +45,90 @@ editor.setOption("extraKeys", {
/*
- Local Storage Update System By Andrew Cay(Resto)
- localBonfire: singleton object that contains properties and methods related to
- dealing with the localStorage system.
- The keys work off of the variable challenge_name to make unique identifiers per bonfire
+ Local Storage Update System By Andrew Cay(Resto)
+ codeStorage: singleton object that contains properties and methods related to
+ dealing with the localStorage system.
+ The keys work off of the variable challenge_name to make unique identifiers per bonfire
- Two extra functionalities:
- Added anonymous version checking system incase of future updates to the system
- Added keyup listener to editor(myCodeMirror) so the last update has been saved to storage
+ Two extra functionalities:
+ Added anonymous version checking system incase of future updates to the system
+ Added keyup listener to editor(myCodeMirror) so the last update has been saved to storage
*/
-var localBonfire = {
- version: 0.01,
- keyVersion:"saveVersion",
- keyStamp: challenge_Name + 'Stamp',
- keyValue: challenge_Name + 'Val',
- stampExpireTime: (1000 *60) *60 *24,
- updateWait: 1500,// 1.5 seconds
- updateTimeoutId: null
+var codeStorage = {
+ version: 0.01,
+ keyVersion:"saveVersion",
+ keyValue: null,//where the value of the editor is saved
+ updateWait: 2000,// 2 seconds
+ updateTimeoutId: null,
+ eventArray: []//for firing saves
};
-localBonfire.getEditorValue = function(){
- return localStorage.getItem(localBonfire.keyValue);
+// Returns true if the editor code was saved since last key press (use this if you want to make a "saved" notification somewhere")
+codeStorage.hasSaved = function(){
+ return ( updateTimeoutId === null );
};
-localBonfire.getStampTime = function(){
- //localstorage always saves as strings.
- return Number.parseInt( localStorage.getItem(localBonfire.keyStamp) );
+codeStorage.onSave = function(func){
+ codeStorage.eventArray.push(func);
};
-localBonfire.isAlive = function(){// returns true if IDE was edited within expire time
- return ( Date.now() - localBonfire.getStampTime() < localBonfire.stampExpireTime );
+codeStorage.setSaveKey = function(key){
+ codeStorage.keyValue = key + 'Val';
};
-localBonfire.updateStorage = function(){
- if(typeof(Storage) !== undefined) {
- var stamp = Date.now(),
- value = editor.getValue();
- localStorage.setItem(localBonfire.keyValue, value);
- localStorage.setItem(localBonfire.keyStamp, stamp);
- } else {
- if( debugging ){
- console.log('no web storage');
- }
- }
- localBonfire.updateTimeoutId = null;
+codeStorage.getEditorValue = function(){
+ return ('' + localStorage.getItem(codeStorage.keyValue));
};
-// ANONYMOUS 1 TIME UPDATE VERSION
+
+codeStorage.isAlive = function() {
+ var val = this.getEditorValue()
+ return val !== 'null' &&
+ val !== 'undefined' &&
+ (val && val.length > 0);
+}
+codeStorage.updateStorage = function(){
+ if(typeof(Storage) !== undefined) {
+ var value = editor.getValue();
+ localStorage.setItem(codeStorage.keyValue, value);
+ } else {
+ var debugging = false;
+ if( debugging ){
+ console.log('no web storage');
+ }
+ }
+ codeStorage.updateTimeoutId = null;
+ codeStorage.eventArray.forEach(function(func){
+ func();
+ });
+};
+//Update Version
(function(){
- var savedVersion = localStorage.getItem('saveVersion');
- if( savedVersion === null ){
- localStorage.setItem(localBonfire.keyVersion, localBonfire.version);//just write current version
- }else{
- //do checking if not current version
- if( savedVersion !== localBonfire.version ){
- //update version
- }
- }
+ var savedVersion = localStorage.getItem('saveVersion');
+ if( savedVersion === null ){
+ localStorage.setItem(codeStorage.keyVersion, codeStorage.version);//just write current version
+ }else{
+ if( savedVersion !== codeStorage.version ){
+ //Update version
+ }
+ }
})();
-editor.on('keyup', function(codMir, event){
- window.clearTimeout(localBonfire.updateTimeoutId);
- localBonfire.updateTimeoutId = window.setTimeout(localBonfire.updateStorage, localBonfire.updateWait);
+
+
+///Set everything up one page
+/// Update local save when editor has changed
+codeStorage.setSaveKey(challenge_Name);
+editor.on('keyup', function(){
+ window.clearTimeout(codeStorage.updateTimeoutId);
+ codeStorage.updateTimeoutId = window.setTimeout(codeStorage.updateStorage, codeStorage.updateWait);
});
+
var attempts = 0;
if (attempts) {
attempts = 0;
}
-var resetEditor = function() {
+var resetEditor = function resetEditor() {
editor.setValue(allSeeds);
- localBonfire.updateStorage();
+ codeStorage.updateStorage();
+
};
var codeOutput = CodeMirror.fromTextArea(document.getElementById("codeOutput"), {
@@ -141,11 +162,11 @@ var tests = tests || [];
var allSeeds = '';
(function() {
challengeSeed.forEach(function(elem) {
- allSeeds += elem + '\n';
+ allSeeds += elem + '\n';
});
})();
-editorValue = (localBonfire.isAlive())? localBonfire.getEditorValue() : allSeeds;
+editorValue = (codeStorage.isAlive())? codeStorage.getEditorValue() : allSeeds;
myCodeMirror.setValue(editorValue);
diff --git a/public/js/main_0.0.2.js b/public/js/main_0.0.2.js
index 7fce4bdaba..1b41b9066b 100644
--- a/public/js/main_0.0.2.js
+++ b/public/js/main_0.0.2.js
@@ -331,7 +331,6 @@ $(document).ready(function() {
$('#story-submit').on('click', storySubmitButtonHandler);
- $('#reset-button').on('click', resetEditor);
var commentSubmitButtonHandler = function commentSubmitButtonHandler() {
$('#comment-button').unbind('click');
diff --git a/seed/bonfireMDNlinks.js b/seed/bonfireMDNlinks.js
index 9a9ea86741..bedd51b2db 100644
--- a/seed/bonfireMDNlinks.js
+++ b/seed/bonfireMDNlinks.js
@@ -12,6 +12,7 @@ var links =
"Currying": "https://leanpub.com/javascript-allonge/read#pabc",
"Smallest Common Multiple": "https://www.mathsisfun.com/least-common-multiple.html",
"Permutations": "https://www.mathsisfun.com/combinatorics/combinations-permutations.html",
+ "HTML Entities": "http://dev.w3.org/html5/html-author/charref",
// ========= GLOBAL OBJECTS
"Global Array Object" : "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array",
diff --git a/seed/challenges/basic-bonfires.json b/seed/challenges/basic-bonfires.json
index 6c8952a980..ae9b0b571a 100644
--- a/seed/challenges/basic-bonfires.json
+++ b/seed/challenges/basic-bonfires.json
@@ -1097,7 +1097,7 @@
"dashedName": "bonfire-convert-html-entities",
"difficulty": "2.07",
"description": [
- "Convert the characters \"&\", \"<\", \">\", '\"', and \"'\", in a string to their corresponding HTML entities.",
+ "Convert the characters \"&\", \"<\", \">\", '\"' (double quote), and \"'\" (apostrophe), in a string to their corresponding HTML entities.",
"Remember to use RSAP if you get stuck. Try to pair program. Write your own code."
],
"challengeSeed": [
@@ -1114,10 +1114,12 @@
"assert.strictEqual(convert('Sixty > twelve'), 'Sixty > twelve', 'should escape characters');",
"assert.strictEqual(convert('Stuff in \"quotation marks\"'), 'Stuff in "quotation marks"', 'should escape characters');",
"assert.strictEqual(convert(\"Shindler's List\"), 'Shindler's List', 'should escape characters');",
+ "assert.strictEqual(convert('<>'), '<>', 'should escape characters');",
"assert.strictEqual(convert('abc'), 'abc', 'should handle strings with nothing to escape');"
],
"MDNlinks": [
- "RegExp"
+ "RegExp",
+ "HTML Entities"
],
"challengeType": 5,
"nameCn": "",
diff --git a/seed/challenges/basic-html5-and-css.json b/seed/challenges/basic-html5-and-css.json
index 52bd6f49b2..fb8c4aa952 100644
--- a/seed/challenges/basic-html5-and-css.json
+++ b/seed/challenges/basic-html5-and-css.json
@@ -1098,7 +1098,8 @@
"In addition to pixels, you can also specify a border-radius using a percentage."
],
"tests": [
- "assert(parseInt($('img').css('border-top-left-radius')) > 48, 'Your image should have a border radius of 50 percent, making it perfectly circular.')"
+ "assert(parseInt($('img').css('border-top-left-radius')) > 48, 'Your image should have a border radius of 50 percent, making it perfectly circular.')",
+ "assert(editor.match(/50%/g), 'Be sure to use a percentage instead of a pixel value.')"
],
"challengeSeed": [
"",
@@ -1756,7 +1757,7 @@
],
"tests": [
"assert($('input[placeholder]').length > 0, 'Add a placeholder attribute text input element.')",
- "assert($('input').attr('placeholder').match(/cat\\s+photo\\s+URL/gi), 'Set the value of your placeholder attribute to \"cat photo URL\".')"
+ "assert($('input') && $('input').attr('placeholder') && $('input').attr('placeholder').match(/cat\\s+photo\\s+URL/gi), 'Set the value of your placeholder attribute to \"cat photo URL\".')"
],
"challengeSeed": [
"",
@@ -1835,7 +1836,7 @@
"For example: <form action=\"/url-where-you-want-to-submit-form-data\"></form>."
],
"tests": [
- "assert($('form').length > 0, 'Wrap your text input element within a form element.')",
+ "assert($('form') && $('form').children('input') && $('form').children('input').length > 0, 'Wrap your text input element within a form element.')",
"assert($('form').attr('action'), 'Your form element should have an action attribute.')",
"assert(editor.match(/<\\/form>/g) && editor.match(/