make bonfire view consistent with other challenge views and make codemirror height larger and result code mirror pane read only with no cursor
This commit is contained in:
@@ -1,8 +1,19 @@
|
|||||||
|
var _ = require('lodash'),
|
||||||
|
debug = require('debug')('freecc:cntr:challenges'),
|
||||||
|
Challenge = require('./../models/Challenge');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bonfire controller
|
* Bonfire controller
|
||||||
*/
|
*/
|
||||||
module.exports = {
|
exports.index = function(req, res) {
|
||||||
index : function(req,res) {
|
Challenge.find({}, null, { sort: { challengeNumber: 1 } }, function(err, c) {
|
||||||
res.render('bonfire/bonfire.jade');
|
if (err) {
|
||||||
}
|
debug('Challenge err: ', err);
|
||||||
};
|
next(err);
|
||||||
|
}
|
||||||
|
res.render('bonfire/bonfire.jade', {
|
||||||
|
challenges: c,
|
||||||
|
cc: req.user ? req.user.challengesHash : undefined
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
@@ -53,5 +53,4 @@ exports.returnChallenge = function(req, res, next) {
|
|||||||
challenges: c
|
challenges: c
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -5,31 +5,46 @@ block content
|
|||||||
link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css')
|
link(rel='stylesheet', href='/js/lib/codemirror/theme/monokai.css')
|
||||||
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
script(src='/js/lib/codemirror/mode/javascript/javascript.js')
|
||||||
|
|
||||||
.col-sm-12
|
.row
|
||||||
.col-sm-4.panel.
|
.col-sm-12.col-md-8.col-xs-12
|
||||||
Challenge text goes here
|
.panel.panel-primary
|
||||||
.col-sm-8
|
.panel-heading Title
|
||||||
form.code
|
.panel.panel-body
|
||||||
.form-group.code
|
form.code
|
||||||
textarea(id='code')
|
.form-group.codeMirrorView
|
||||||
#submitButton.btn.btn-primary
|
textarea#codeEditor
|
||||||
.col-sm-4.jumbotron
|
form.code
|
||||||
#codeOutput
|
.form-group.codeMirrorView
|
||||||
|
textarea#codeOutput(enabled=false)
|
||||||
|
#submitButton.btn.btn-primary.btn-big.btn-block Run my code
|
||||||
|
#hintButton.btn.btn-info.btn-big.btn-block Show me hints
|
||||||
|
script.
|
||||||
|
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {
|
||||||
|
lineNumbers: true,
|
||||||
|
mode: "javascript",
|
||||||
|
theme: 'monokai',
|
||||||
|
runnable: true
|
||||||
|
});
|
||||||
|
myCodeMirror.setValue('2*2');
|
||||||
|
myCodeMirror.setSize("100%", 500);
|
||||||
|
$('#submitButton').on('click', function () {
|
||||||
|
$('#codeOutput').empty();
|
||||||
|
var js = myCodeMirror.getValue();
|
||||||
|
var s = document.createElement('script');
|
||||||
|
s.textContent = js;
|
||||||
|
try {
|
||||||
|
$('#codeOutput').append(eval(s.textContent));
|
||||||
|
} catch (e) {
|
||||||
|
$('#codeOutput').append(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var codeOutput = CodeMirror.fromTextArea(document.getElementById("codeOutput"), {
|
||||||
|
lineNumbers: false,
|
||||||
script.
|
mode: "javascript",
|
||||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("code"), {
|
theme: 'monokai',
|
||||||
lineNumbers: true,
|
readOnly: 'nocursor'
|
||||||
mode: "javascript",
|
});
|
||||||
theme: 'monokai',
|
codeOutput.setSize("100%", 30);
|
||||||
runnable: true
|
.col-sm-12.col-md-4.col-xs-12
|
||||||
});
|
include ../partials/challenges
|
||||||
myCodeMirror.setValue('2*2');
|
|
||||||
$('#submitButton').on('click', function() {
|
|
||||||
$('#codeOutput').empty();
|
|
||||||
var js = myCodeMirror.getValue();
|
|
||||||
var s = document.createElement('script');
|
|
||||||
s.textContent = js;
|
|
||||||
$('#codeOutput').append(eval(s.textContent));
|
|
||||||
});
|
|
Reference in New Issue
Block a user