Working on codemirror display issue in html coursewares

This commit is contained in:
Nathan Leniz
2015-03-21 16:34:06 +09:00
parent a2e2e6bfa2
commit 6ad7c22313
4 changed files with 32 additions and 33 deletions

View File

@ -21,6 +21,17 @@ var async = require('async'),
* Resources.
*/
Array.zip = function(left, right, combinerFunction) {
var counter,
results = [];
for (counter = 0; counter < Math.min(left.length, right.length); counter++) {
results.push(combinerFunction(left[counter],right[counter]));
}
return results;
};
module.exports = {
privacy: function privacy(req, res) {
res.render('resources/privacy', {
@ -195,6 +206,25 @@ module.exports = {
req.user.progressTimestamps.push(challengesHash[key]);
}
}
var timeStamps = [];
R.keys(req.user.challengesHash).forEach(function(key) {
"use strict";
timeStamps.push({timeStamp: challengesHash[key]});
});
req.user.completedCoursewares = Array.zip(timeStamps, coursewares,
function(left, right) {
"use strict";
return ({
completedDate: left.timeStamp,
_id: right._id,
name: right.name
});
}).filter(function(elem) {
"use strict";
return elem.completedDate !== 0;
});
req.user.pointsNeedMigration = false;
req.user.save();
}

View File

@ -240,30 +240,6 @@ var userSchema = new mongoose.Schema({
53: {
type: Number,
default: 0
},
54: {
type: Number,
default: 0
},
55: {
type: Number,
default: 0
},
56: {
type: Number,
default: 0
},
57: {
type: Number,
default: 0
},
58: {
type: Number,
default: 0
},
59: {
type: Number,
default: 0
}
},
profile: {

View File

@ -3,12 +3,11 @@
*/
var widgets = [];
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {
var editor = CodeMirror.fromTextArea(document.getElementById("codeEditor"), {
lineNumbers: true,
mode: "text/html",
theme: 'monokai',
runnable: true,
//lint: true,
matchBrackets: true,
autoCloseBrackets: true,
scrollbarStyle: 'null',
@ -16,7 +15,6 @@ var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("codeEditor")
gutters: ["CodeMirror-lint-markers"],
onKeyEvent: doLinting
});
var editor = myCodeMirror;
// Hijack tab key to insert two spaces instead
@ -117,7 +115,7 @@ var allSeeds = '';
});
})();
myCodeMirror.setValue(allSeeds);
editor.setValue('test');
function doLinting () {
editor.operation(function () {

View File

@ -95,11 +95,6 @@ block content
a.btn.btn-lg.btn-block.btn-info(href=website3Link, target='_blank')
i.fa.icon-beaker
| Try it out
//
html.
<script type="text/javascript" src="//d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.min.js"></script>
<link rel="stylesheet" href="//cdn.jsdelivr.net/cal-heatmap/3.3.10/cal-heatmap.css" />
.hidden-xs.col-sm-12
#cal-heatmap