Merge branch 'Lemony-Andrew-master' into staging

Conflicts:
	server/views/coursewares/showBonfire.jade
This commit is contained in:
Quincy Larson
2015-06-19 16:17:59 -07:00
3 changed files with 67 additions and 6 deletions

View File

@ -40,6 +40,66 @@ 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
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
};
localBonfire.getEditorValue = function(){
return localStorage.getItem(localBonfire.keyValue);
};
localBonfire.getStampTime = function(){
//localstorage always saves as strings.
return Number.parseInt( localStorage.getItem(localBonfire.keyStamp) );
};
localBonfire.isAlive = function(){// returns true if IDE was edited within expire time
return ( Date.now() - localBonfire.getStampTime() < localBonfire.stampExpireTime );
};
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;
console.log('updated!');
};
// ANONYMOUS 1 TIME 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
}
}
})();
editor.on('keyup', function(codMir, event){
window.clearTimeout(localBonfire.updateTimeoutId);
localBonfire.updateTimeoutId = window.setTimeout(localBonfire.updateStorage, localBonfire.updateWait);
});
var attempts = 0;
if (attempts) {
@ -71,15 +131,15 @@ var editorValue;
var challengeSeed = challengeSeed || null;
var tests = tests || [];
var allSeeds = '';
(function() {
challengeSeed.forEach(function(elem) {
allSeeds += elem + '\n';
allSeeds += elem + '\n';
});
})();
editorValue = allSeeds;
editorValue = (localBonfire.isAlive())? localBonfire.getEditorValue() : allSeeds;
myCodeMirror.setValue(editorValue);

View File

@ -853,7 +853,7 @@
"difficulty": "2.03",
"description": [
"Perform a search and replace on the sentence using the arguments provided and return the new sentence.",
"First argument is the sentence the perform the search and replace on.",
"First argument is the sentence to perform the search and replace on.",
"Second argument is the word that you will be replacing (before).",
"Third argument is what you will be replacing the second argument with (after).",
"NOTE: Preserve the case of the original word when you are replacing it. For example if you mean to replace the word 'Book' with the word 'dog', it should be replaced as 'Dog'",
@ -990,7 +990,8 @@
"expect(fearNotLetter('yz')).to.be.undefined;"
],
"MDNlinks": [
"String.charCodeAt()"
"String.charCodeAt()",
"String.fromCharCode()"
],
"challengeType": 5,
"nameCn": "",

View File

@ -84,7 +84,7 @@ block content
label.negative-10.btn.btn-primary.btn-block#submitButton
i.fa.fa-play
| &nbsp; Run code (ctrl + enter)
#resetButton.btn.btn-danger.btn-big.btn-block(data-toggle='modal', data-target='#reset-modal', data-backdrop='true') Reset Code
if (user && user.sentSlackInvite)
.button-spacer
.btn-group.input-group.btn-group-justified