More refactoring
This commit is contained in:
53
client/commonFramework/output-display.js
Normal file
53
client/commonFramework/output-display.js
Normal file
@@ -0,0 +1,53 @@
|
||||
window.common = (function(global) {
|
||||
const {
|
||||
CodeMirror,
|
||||
document: doc,
|
||||
common = { init: [] }
|
||||
} = global;
|
||||
|
||||
const { challengeType = '0' } = common;
|
||||
|
||||
if (
|
||||
!CodeMirror ||
|
||||
challengeType === '0' ||
|
||||
challengeType === '7'
|
||||
) {
|
||||
common.updateOutputDisplay = () => {};
|
||||
common.appendToOutputDisplay = () => {};
|
||||
return common;
|
||||
}
|
||||
|
||||
var codeOutput = CodeMirror.fromTextArea(
|
||||
doc.getElementById('codeOutput'),
|
||||
{
|
||||
lineNumbers: false,
|
||||
mode: 'text',
|
||||
theme: 'monokai',
|
||||
readOnly: 'nocursor',
|
||||
lineWrapping: true
|
||||
}
|
||||
);
|
||||
|
||||
codeOutput.setValue(`
|
||||
/**
|
||||
* Your output will go here.
|
||||
* Console.log() -type statements
|
||||
* will appear in your browser\'s
|
||||
* DevTools JavaScript console.
|
||||
*/'
|
||||
`);
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
return common;
|
||||
}(window));
|
Reference in New Issue
Block a user