mid finished linting commonFramework

This commit is contained in:
Berkeley Martinez
2015-08-27 00:15:13 -07:00
parent 8f54932cab
commit 384dec42ac

View File

@ -1,4 +1,4 @@
/* globals CodeMirror, challenge_Name */
/* globals CodeMirror, challenge_Name, challengeType */
// codeStorage
var codeStorageFactory = (function($, localStorage) {
@ -68,6 +68,12 @@ var codeStorageFactory = (function($, localStorage) {
return codeStorageFactory;
}($, localStorage));
function replaceSafeTags(value) {
return value
.replace(/fccss/gi, '<script>')
.replace(/fcces/gi, '</script>');
}
var isInitRun = false;
var initPreview = true;
var editor;
@ -106,30 +112,30 @@ var allSeeds = '';
});
})();
editor.setOption("extraKeys", {
editor.setOption('extraKeys', {
Tab: function(cm) {
if (cm.somethingSelected()) {
cm.indentSelection("add");
cm.indentSelection('add');
} else {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
var spaces = Array(cm.getOption('indentUnit') + 1).join(' ');
cm.replaceSelection(spaces);
}
},
"Shift-Tab": function(cm) {
'Shift-Tab': function(cm) {
if (cm.somethingSelected()) {
cm.indentSelection("subtract");
cm.indentSelection('subtract');
} else {
var spaces = Array(cm.getOption("indentUnit") + 1).join(" ");
var spaces = Array(cm.getOption('indentUnit') + 1).join(' ');
cm.replaceSelection(spaces);
}
},
"Ctrl-Enter": function() {
'Ctrl-Enter': function() {
bonfireExecute(true);
return false;
}
});
editor.setSize("100%", "auto");
editor.setSize('100%', 'auto');
var libraryIncludes = "<script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>" +
"<script src='/js/lib/chai/chai.js'></script>" +
@ -141,14 +147,12 @@ var libraryIncludes = "<script src='//ajax.googleapis.com/ajax/libs/jquery/2.1.3
"<style>body { padding: 0px 3px 0px 3px; }</style>" +
"<script>var expect = chai.expect; var should = chai.should(); var assert = chai.assert;</script>";
var editorValueForIFrame;
var iFrameScript = "<script src='/js/iFrameScripts.js'></script>";
var delay;
// Initialize CodeMirror editor with a nice html5 canvas demo.
editor.on("keyup", function () {
editor.on('keyup', function() {
clearTimeout(delay);
delay = setTimeout(updatePreview, 300);
});
@ -156,21 +160,28 @@ editor.on("keyup", function () {
function workerError(error) {
var display = $('.runTimeError');
var housing = $('#testSuite');
if(display.html() != error){
if (display.html() !== error) {
display.remove();
housing.prepend("<div class = \"runTimeError\" style= \"font-size: 18px;\"><code>" + error.replace(/j\$/gi, "$").replace(/jdocument/gi, "document").replace(/jjQuery/gi, "jQuery") + "</code></div>");
housing.prepend(
'<div class="runTimeError" style="font-size: 18px;"><code>' +
error.replace(/j\$/gi, '$').replace(/jdocument/gi, 'document').replace(/jjQuery/gi, 'jQuery') +
'</code></div>'
);
display.hide().fadeIn(function() {
setTimeout(function() {
display.fadeOut(function() {
display.remove();
});
}, 1000)
}, 1000);
});
}
}
function scopejQuery(s){
return(s.replace(/\$/gi, "j$").replace(/document/gi, "jdocument").replace(/jQuery/gi, "jjQuery"));
function scopejQuery(str) {
return str
.replace(/\$/gi, 'j$')
.replace(/document/gi, 'jdocument')
.replace(/jQuery/gi, 'jjQuery');
}
function safeHTMLRun(test) {
@ -328,7 +339,7 @@ function showCompletion() {
}
var resetEditor = function resetEditor() {
editor.setValue(allSeeds.replace((/fccss/gi), '<script>').replace((/fcces/gi), '</script>'));
editor.setValue(replaceSafeTags(allSeeds));
$('#testSuite').empty();
bonfireExecute(true);
codeStorage.updateStorage();
@ -339,14 +350,17 @@ if (attempts) {
attempts = 0;
}
if(challengeType !== "0") {
var codeOutput = CodeMirror.fromTextArea(document.getElementById("codeOutput"), {
if (challengeType !== '0') {
var codeOutput = CodeMirror.fromTextArea(
document.getElementById('codeOutput'),
{
lineNumbers: false,
mode: "text",
mode: 'text',
theme: 'monokai',
readOnly: 'nocursor',
lineWrapping: true
});
}
);
codeOutput.setValue('/**\n' +
' * Your output will go here.\n' + ' * Console.log() -type statements\n' +
@ -354,6 +368,7 @@ if(challengeType !== "0") {
' */');
codeOutput.setSize("100%", "100%");
}
var info = editor.getScrollInfo();
var after = editor.charCoords({
line: editor.getCursor().line + 1,
@ -591,7 +606,8 @@ $(document).ready(function() {
codeStorage.getStoredValue() :
allSeeds;
myCodeMirror.setValue(editorValue.replace(/fccss/gi, '<script>').replace(/fcces/gi, "</script>"));
myCodeMirror.setValue(replaceSafeTags(editorValue));
if (typeof $preview.html() !== 'undefined') {
$preview.load(function() {
if (initPreview) {