freeCodeCamp/client/commonFramework/output-display.js

54 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-11-13 19:10:23 +00:00
window.common = (function(global) {
const {
CodeMirror,
document: doc,
common = { init: [] }
} = global;
const { challengeType = '0' } = common;
if (
2015-11-18 05:25:16 +00:00
!CodeMirror ||
2015-11-13 19:10:23 +00:00
challengeType === '0' ||
challengeType === '7'
) {
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-18 05:25:16 +00:00
codeOutput.setValue(`
2015-11-13 19:10:23 +00:00
/**
* Your output will go here.
* Console.log() -type statements
* will appear in your browser\'s
* DevTools JavaScript console.
*/'
`);
2015-11-18 05:25:16 +00:00
codeOutput.setSize('100%', '100%');
common.updateOutputDisplay = function updateOutputDisplay(str) {
codeOutput.setValue(str);
return str;
};
common.appendToOutputDisplay = function appendToOutputDisplay(str) {
codeOutput.setValue(codeOutput.getValue() + str);
return str;
};
2015-11-13 19:10:23 +00:00
return common;
}(window));