2015-11-13 19:10:23 +00:00
|
|
|
window.common = (function(global) {
|
|
|
|
const {
|
|
|
|
CodeMirror,
|
|
|
|
document: doc,
|
|
|
|
common = { init: [] }
|
|
|
|
} = global;
|
|
|
|
|
2015-11-23 03:42:53 +00:00
|
|
|
const { challengeTypes, challengeType = '0' } = common;
|
2015-11-13 19:10:23 +00:00
|
|
|
|
|
|
|
if (
|
2015-11-18 05:25:16 +00:00
|
|
|
!CodeMirror ||
|
2015-11-24 23:01:22 +00:00
|
|
|
challengeType !== challengeTypes.JS &&
|
2015-11-23 03:42:53 +00:00
|
|
|
challengeType !== challengeTypes.BONFIRE
|
2015-11-13 19:10:23 +00:00
|
|
|
) {
|
2015-11-18 05:25:16 +00:00
|
|
|
common.updateOutputDisplay = () => {};
|
|
|
|
common.appendToOutputDisplay = () => {};
|
|
|
|
return common;
|
2015-11-13 19:10:23 +00:00
|
|
|
}
|
|
|
|
|
2015-11-18 05:25:16 +00:00
|
|
|
var codeOutput = CodeMirror.fromTextArea(
|
2015-11-13 19:10:23 +00:00
|
|
|
doc.getElementById('codeOutput'),
|
|
|
|
{
|
|
|
|
lineNumbers: false,
|
|
|
|
mode: 'text',
|
|
|
|
theme: 'monokai',
|
|
|
|
readOnly: 'nocursor',
|
|
|
|
lineWrapping: true
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2015-11-20 05:51:38 +00:00
|
|
|
codeOutput.setValue(`/**
|
|
|
|
* Your output will go here.
|
2016-02-26 06:11:38 +00:00
|
|
|
* Any console.log() -type
|
|
|
|
* statements will appear in
|
|
|
|
* your browser\'s DevTools
|
|
|
|
* JavaScript console.
|
2015-11-22 03:48:24 +00:00
|
|
|
*/`);
|
2015-11-13 19:10:23 +00:00
|
|
|
|
2015-11-18 05:25:16 +00:00
|
|
|
codeOutput.setSize('100%', '100%');
|
|
|
|
|
2015-11-20 05:51:38 +00:00
|
|
|
common.updateOutputDisplay = function updateOutputDisplay(str = '') {
|
2016-01-13 09:17:30 +00:00
|
|
|
if (typeof str !== 'string') {
|
|
|
|
str = JSON.stringify(str);
|
|
|
|
}
|
2015-11-18 05:25:16 +00:00
|
|
|
codeOutput.setValue(str);
|
|
|
|
return str;
|
|
|
|
};
|
|
|
|
|
2015-11-20 05:51:38 +00:00
|
|
|
common.appendToOutputDisplay = function appendToOutputDisplay(str = '') {
|
2015-11-18 05:25:16 +00:00
|
|
|
codeOutput.setValue(codeOutput.getValue() + str);
|
|
|
|
return str;
|
|
|
|
};
|
2015-11-13 19:10:23 +00:00
|
|
|
|
|
|
|
return common;
|
|
|
|
}(window));
|