Lint all the things
This commit is contained in:
@ -1 +1,2 @@
|
|||||||
public/**/*.js
|
public/**/*.js
|
||||||
|
client/main.js
|
||||||
|
@ -224,8 +224,8 @@
|
|||||||
"no-plusplus": 0,
|
"no-plusplus": 0,
|
||||||
|
|
||||||
"react/display-name": 1,
|
"react/display-name": 1,
|
||||||
"react/jsx-boolean-value": 1,
|
"react/jsx-boolean-value": [1, "always"],
|
||||||
"react/jsx-quotes": [1, "single", "avoid-escape"],
|
"jsx-quotes": [1, "prefer-single"],
|
||||||
"react/jsx-no-undef": 1,
|
"react/jsx-no-undef": 1,
|
||||||
"react/jsx-sort-props": 1,
|
"react/jsx-sort-props": 1,
|
||||||
"react/jsx-uses-react": 1,
|
"react/jsx-uses-react": 1,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import React, { createClass, PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import { Alert } from 'react-bootstrap';
|
import { Alert } from 'react-bootstrap';
|
||||||
|
|
||||||
export default createClass({
|
export default React.createClass({
|
||||||
displayName: 'FlashQueue',
|
displayName: 'FlashQueue',
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
@ -9,9 +9,9 @@ export default createClass({
|
|||||||
},
|
},
|
||||||
|
|
||||||
renderMessages(messages) {
|
renderMessages(messages) {
|
||||||
return messages.map(message => {
|
return messages.map(() => {
|
||||||
return (
|
return (
|
||||||
<Alert>
|
<Alert />
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
var Action = require('thundercats').Action,
|
|
||||||
executeBonfire = require('./executeBonfire'),
|
|
||||||
getModel = require('../../utils/getModel'),
|
|
||||||
debug = require('debug')('freecc:common:bonfires');
|
|
||||||
|
|
||||||
var BonfireActions = Action.createActions([
|
|
||||||
'setUserCode',
|
|
||||||
'testUserCode',
|
|
||||||
'setResults',
|
|
||||||
'setDisplay',
|
|
||||||
'setBonfire',
|
|
||||||
'getBonfire',
|
|
||||||
'handleBonfireError',
|
|
||||||
'openCompletionModal'
|
|
||||||
]);
|
|
||||||
|
|
||||||
BonfireActions
|
|
||||||
.getBonfire
|
|
||||||
.subscribe(function(params) {
|
|
||||||
var Bonfire = getModel('bonfire');
|
|
||||||
var bonfireName = params.bonfireName ?
|
|
||||||
params.bonfireName.replace(/\-/g, ' ') :
|
|
||||||
'meet bonfire';
|
|
||||||
debug('getting bonfire for: ', bonfireName);
|
|
||||||
var regQuery = { name: { like: bonfireName, options: 'i' } };
|
|
||||||
Bonfire.find(
|
|
||||||
{ where: regQuery },
|
|
||||||
function(err, bonfire) {
|
|
||||||
if (err) {
|
|
||||||
return debug('bonfire get err', err);
|
|
||||||
}
|
|
||||||
if (!bonfire || bonfire.length < 1) {
|
|
||||||
return debug('404 no bonfire found for ', bonfireName);
|
|
||||||
}
|
|
||||||
bonfire = bonfire.pop();
|
|
||||||
if (bonfire) {
|
|
||||||
debug(
|
|
||||||
'found bonfire %s for route %s',
|
|
||||||
bonfire.name,
|
|
||||||
bonfireName
|
|
||||||
);
|
|
||||||
}
|
|
||||||
BonfireActions.setBonfire(bonfire);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
BonfireActions
|
|
||||||
.testUserCode
|
|
||||||
.subscribe(function({ userCode, tests }) {
|
|
||||||
debug('test bonfire');
|
|
||||||
executeBonfire(userCode, tests, function(err, { output, results }) {
|
|
||||||
if (err) {
|
|
||||||
debug('error running tests', err);
|
|
||||||
return BonfireActions.setDisplay(err);
|
|
||||||
}
|
|
||||||
BonfireActions.setDisplay(output);
|
|
||||||
BonfireActions.setResults(results);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = BonfireActions;
|
|
@ -1,67 +0,0 @@
|
|||||||
var BonfiresActions = require('./Actions');
|
|
||||||
var { Store, setStateUtil } = require('thundercats');
|
|
||||||
|
|
||||||
var BonfiresStore = Store.create({
|
|
||||||
|
|
||||||
getInitialValue: function() {
|
|
||||||
return {
|
|
||||||
userCode: 'console.log(\'FreeCodeCamp!\')',
|
|
||||||
difficulty: 0,
|
|
||||||
description: [
|
|
||||||
'default state'
|
|
||||||
],
|
|
||||||
tests: [],
|
|
||||||
results: null
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
getOperations: function() {
|
|
||||||
var {
|
|
||||||
setBonfire,
|
|
||||||
setUserCode,
|
|
||||||
setResults,
|
|
||||||
setDisplay
|
|
||||||
} = BonfiresActions;
|
|
||||||
|
|
||||||
return [
|
|
||||||
setBonfire
|
|
||||||
.map(function(bonfire) {
|
|
||||||
var {
|
|
||||||
name,
|
|
||||||
description,
|
|
||||||
difficulty,
|
|
||||||
tests
|
|
||||||
} = bonfire;
|
|
||||||
var userCode = bonfire.challengeSeed;
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
userCode,
|
|
||||||
tests,
|
|
||||||
description,
|
|
||||||
difficulty
|
|
||||||
};
|
|
||||||
})
|
|
||||||
.map(setStateUtil),
|
|
||||||
|
|
||||||
setUserCode
|
|
||||||
.map(function(userCode) {
|
|
||||||
return { userCode };
|
|
||||||
})
|
|
||||||
.map(setStateUtil),
|
|
||||||
|
|
||||||
setDisplay
|
|
||||||
.map(function(display) {
|
|
||||||
return { display };
|
|
||||||
})
|
|
||||||
.map(setStateUtil),
|
|
||||||
|
|
||||||
setResults
|
|
||||||
.map(function(results) {
|
|
||||||
return { results };
|
|
||||||
})
|
|
||||||
.map(setStateUtil)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = BonfiresStore;
|
|
@ -1,99 +0,0 @@
|
|||||||
var React = require('react'),
|
|
||||||
|
|
||||||
// ## mixins
|
|
||||||
{ ObservableStateMixin } = require('thundercats'),
|
|
||||||
|
|
||||||
// ## components
|
|
||||||
SidePanel = require('./SidePanel.jsx'),
|
|
||||||
Results = require('./Results.jsx'),
|
|
||||||
Display = require('../displayCode'),
|
|
||||||
Editor = require('../editor'),
|
|
||||||
{ Grid, Row, Col } = require('react-bootstrap'),
|
|
||||||
|
|
||||||
// ## flux
|
|
||||||
BonfireActions = require('./Actions'),
|
|
||||||
BonfireStore = require('./Store');
|
|
||||||
|
|
||||||
var Bonfire = React.createClass({
|
|
||||||
|
|
||||||
mixins: [ObservableStateMixin],
|
|
||||||
|
|
||||||
contextTypes: {
|
|
||||||
makePath: React.PropTypes.func.isRequired,
|
|
||||||
replaceWith: React.PropTypes.func.isRequired
|
|
||||||
},
|
|
||||||
|
|
||||||
getObservable: function() {
|
|
||||||
return BonfireStore;
|
|
||||||
},
|
|
||||||
|
|
||||||
componentDidMount: function() {
|
|
||||||
// get history object
|
|
||||||
var his = typeof window !== 'undefined' ? window.history : null;
|
|
||||||
// spinal-case bonfireName
|
|
||||||
var bonfireName = this.state.name.toLowerCase().replace(/\s/g, '-');
|
|
||||||
// create proper URI from react-router
|
|
||||||
var path = this.context.makePath('bonfires', { bonfireName: bonfireName });
|
|
||||||
|
|
||||||
// if html5 push state exists, update URI
|
|
||||||
// else we are using hash location and should just cause a re render
|
|
||||||
if (his) {
|
|
||||||
his.replaceState({ path: path }, '', path);
|
|
||||||
} else {
|
|
||||||
this.context.replaceWith('bonfires', { bonfireName: bonfireName});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_onTestBonfire: function() {
|
|
||||||
BonfireActions.testUserCode({
|
|
||||||
userCode: this.state.userCode,
|
|
||||||
tests: this.state.tests
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
var {
|
|
||||||
name,
|
|
||||||
userCode,
|
|
||||||
difficulty,
|
|
||||||
description,
|
|
||||||
results,
|
|
||||||
display
|
|
||||||
} = this.state;
|
|
||||||
var brief = description.slice(0, 1).pop();
|
|
||||||
|
|
||||||
// convert bonfire difficulty from floating point string
|
|
||||||
// to integer.
|
|
||||||
var difficultyInt = Math.floor(+difficulty);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Grid>
|
|
||||||
<Row>
|
|
||||||
<Col
|
|
||||||
xs={ 12 }
|
|
||||||
md={ 4 }>
|
|
||||||
<SidePanel
|
|
||||||
name={ name }
|
|
||||||
brief={ brief }
|
|
||||||
difficulty={ difficultyInt }
|
|
||||||
onTestBonfire={ this._onTestBonfire }
|
|
||||||
description={ description.length > 1 ? description : [] }/>
|
|
||||||
<Display
|
|
||||||
value={ display }/>
|
|
||||||
<Results
|
|
||||||
results={ results }/>
|
|
||||||
</Col>
|
|
||||||
<Col
|
|
||||||
xs={ 12 }
|
|
||||||
md={ 8 }>
|
|
||||||
<Editor
|
|
||||||
onValueChange={ BonfireActions.setUserCode }
|
|
||||||
value={ userCode }/>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = Bonfire;
|
|
@ -1,62 +0,0 @@
|
|||||||
var React = require('react'),
|
|
||||||
classNames = require('classnames'),
|
|
||||||
{ Grid, Row, Col } = require('react-bootstrap');
|
|
||||||
|
|
||||||
var Results = React.createClass({
|
|
||||||
|
|
||||||
propTypes: {
|
|
||||||
results: React.PropTypes.array
|
|
||||||
},
|
|
||||||
|
|
||||||
_renderText: function(text, textClass) {
|
|
||||||
return (
|
|
||||||
<Col
|
|
||||||
xs={ 11 }
|
|
||||||
className={ classNames(textClass) }>
|
|
||||||
{ text }
|
|
||||||
</Col>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
_renderResult: function(results) {
|
|
||||||
return results.map(function(result, idx) {
|
|
||||||
var err = result.err;
|
|
||||||
var iconClass = {
|
|
||||||
'ion-close-circled big-error-icon': err,
|
|
||||||
'ion-checkmark-circled big-success-icon': !err
|
|
||||||
};
|
|
||||||
var textClass = {
|
|
||||||
'test-output wrappable': true,
|
|
||||||
'test-vertical-center': !err
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<div key={ idx }>
|
|
||||||
<Row>
|
|
||||||
<Col
|
|
||||||
xs={ 1 }
|
|
||||||
className='text-center'>
|
|
||||||
<i className={ classNames(iconClass) }></i>
|
|
||||||
</Col>
|
|
||||||
{ this._renderText(result.text, textClass) }
|
|
||||||
{ err ? this._renderText(err, textClass) : null }
|
|
||||||
</Row>
|
|
||||||
<div className='ten-pixel-break'></div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
var results = this.props.results;
|
|
||||||
if (!results || results.length && results.length === 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<Grid>
|
|
||||||
{ this._renderResult(this.props.results) }
|
|
||||||
</Grid>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = Results;
|
|
@ -1,129 +0,0 @@
|
|||||||
var React = require('react'),
|
|
||||||
|
|
||||||
// ## components
|
|
||||||
{
|
|
||||||
Well,
|
|
||||||
Row,
|
|
||||||
Col,
|
|
||||||
Button,
|
|
||||||
} = require('react-bootstrap');
|
|
||||||
|
|
||||||
var SidePanel = React.createClass({
|
|
||||||
|
|
||||||
propTypes: {
|
|
||||||
name: React.PropTypes.string,
|
|
||||||
brief: React.PropTypes.string,
|
|
||||||
description: React.PropTypes.array,
|
|
||||||
difficulty: React.PropTypes.number,
|
|
||||||
onTestBonfire: React.PropTypes.func
|
|
||||||
},
|
|
||||||
|
|
||||||
getDefaultProps: function() {
|
|
||||||
return {
|
|
||||||
name: 'Welcome to Bonfires!',
|
|
||||||
difficulty: 5,
|
|
||||||
brief: 'This is a brief description'
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
getInitialState: function() {
|
|
||||||
return {
|
|
||||||
isMoreInfoOpen: false
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
_toggleMoreInfo: function() {
|
|
||||||
this.setState({
|
|
||||||
isMoreInfoOpen: !this.state.isMoreInfoOpen
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
_renderFlames: function() {
|
|
||||||
var difficulty = this.props.difficulty;
|
|
||||||
|
|
||||||
return [1, 2, 3, 4, 5].map(num => {
|
|
||||||
var className = 'ion-ios-flame';
|
|
||||||
if (num > difficulty) {
|
|
||||||
className += '-outline';
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<i
|
|
||||||
key={ num }
|
|
||||||
className={ className }/>
|
|
||||||
);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
_renderMoreInfo: function(isDescription) {
|
|
||||||
var description = this.props.description.map((sentance, index) => {
|
|
||||||
return <p key={ index }>{ sentance }</p>;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (isDescription && this.state.isMoreInfoOpen) {
|
|
||||||
return (
|
|
||||||
<Row>
|
|
||||||
<Col xs={ 12 }>
|
|
||||||
{ description }
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
_renderMoreInfoButton: function(isDescription) {
|
|
||||||
if (isDescription) {
|
|
||||||
return (
|
|
||||||
<Button
|
|
||||||
onClick={ this._toggleMoreInfo }
|
|
||||||
bsStyle='primary'
|
|
||||||
block={ true }
|
|
||||||
className='btn-primary-ghost'>
|
|
||||||
<span className='ion-arrow-down-b'></span>
|
|
||||||
More information
|
|
||||||
</Button>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
var isDescription = this.props.description &&
|
|
||||||
this.props.description.length > 1;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<h1 className='text-center'>{ this.props.name }</h1>
|
|
||||||
<h2 className='text-center'>
|
|
||||||
<div className='bonfire-flames'>
|
|
||||||
Difficulty:
|
|
||||||
{ this._renderFlames() }
|
|
||||||
</div>
|
|
||||||
</h2>
|
|
||||||
<Well>
|
|
||||||
<Row>
|
|
||||||
<Col xs={ 12 }>
|
|
||||||
<div className='bonfire-instructions'>
|
|
||||||
<p>{ this.props.brief }</p>
|
|
||||||
<div>
|
|
||||||
{ this._renderMoreInfo(isDescription) }
|
|
||||||
{ this._renderMoreInfoButton(isDescription) }
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Well>
|
|
||||||
<Button
|
|
||||||
bsStyle='primary'
|
|
||||||
block={ true }
|
|
||||||
className='btn-big'
|
|
||||||
onClick={ this.props.onTestBonfire }>
|
|
||||||
Run Code (ctrl + enter)
|
|
||||||
</Button>
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = SidePanel;
|
|
@ -1,27 +0,0 @@
|
|||||||
var debug = require('debug')('freecc:executebonfire');
|
|
||||||
var {
|
|
||||||
addTests,
|
|
||||||
runTests,
|
|
||||||
testCode
|
|
||||||
} = require('../../utils');
|
|
||||||
|
|
||||||
module.exports = executeBonfire;
|
|
||||||
|
|
||||||
function executeBonfire(userCode, tests, cb) {
|
|
||||||
|
|
||||||
// TODO: move this into componentDidMount
|
|
||||||
// ga('send', 'event', 'Bonfire', 'ran-code', bonfireName);
|
|
||||||
var testSalt = Math.random();
|
|
||||||
var { preppedCode, userTests } = addTests(userCode, tests, testSalt);
|
|
||||||
|
|
||||||
debug('sending code to web worker for testing');
|
|
||||||
testCode(preppedCode, function(err, data) {
|
|
||||||
if (err) { return cb(err); }
|
|
||||||
var results = runTests(userTests, data, testSalt);
|
|
||||||
debug('testing complete', results);
|
|
||||||
cb(null, {
|
|
||||||
output: data.output,
|
|
||||||
results
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
/*
|
|
||||||
export default {
|
|
||||||
path: 'bonfires/(:bonfireName)'
|
|
||||||
getComponents(cb) {
|
|
||||||
// TODO(berks): add bonfire component
|
|
||||||
}
|
|
||||||
};
|
|
||||||
*/
|
|
@ -1,8 +1,8 @@
|
|||||||
import React, { createClass } from 'react';
|
import React from 'react';
|
||||||
import { LinkContainer } from 'react-router-bootstrap';
|
import { LinkContainer } from 'react-router-bootstrap';
|
||||||
import { Button, Row, Col, Panel } from 'react-bootstrap';
|
import { Button, Row, Col, Panel } from 'react-bootstrap';
|
||||||
|
|
||||||
export default createClass({
|
export default React.createClass({
|
||||||
displayName: 'NoJobFound',
|
displayName: 'NoJobFound',
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -162,16 +162,16 @@ export default contain({
|
|||||||
|
|
||||||
handleSubmit(e) {
|
handleSubmit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const props = this.props;
|
const pros = this.props;
|
||||||
let valid = true;
|
let valid = true;
|
||||||
checkValidity.forEach((prop) => {
|
checkValidity.forEach((prop) => {
|
||||||
// if value exist, check if it is valid
|
// if value exist, check if it is valid
|
||||||
if (props[prop].value && props[prop].type !== 'boolean') {
|
if (pros[prop].value && pros[prop].type !== 'boolean') {
|
||||||
valid = valid && !!props[prop].valid;
|
valid = valid && !!pros[prop].valid;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!valid || !props.isFrontEndCert && !props.isFullStackCert ) {
|
if (!valid || !pros.isFrontEndCert && !pros.isFullStackCert ) {
|
||||||
debug('form not valid');
|
debug('form not valid');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { createClass, PropTypes } from 'react';
|
import React, { PropTypes } from 'react';
|
||||||
import { Button } from 'react-bootstrap';
|
import { Button } from 'react-bootstrap';
|
||||||
|
|
||||||
const followLink = 'https://twitter.com/intent/follow?' +
|
const followLink = 'https://twitter.com/intent/follow?' +
|
||||||
@ -9,7 +9,7 @@ function commify(count) {
|
|||||||
return Number(count).toLocaleString('en');
|
return Number(count).toLocaleString('en');
|
||||||
}
|
}
|
||||||
|
|
||||||
export default createClass({
|
export default React.createClass({
|
||||||
|
|
||||||
displayName: 'FollowButton',
|
displayName: 'FollowButton',
|
||||||
|
|
||||||
|
@ -1,51 +0,0 @@
|
|||||||
var React = require('react'),
|
|
||||||
Tailspin = require('tailspin');
|
|
||||||
|
|
||||||
var Editor = React.createClass({
|
|
||||||
|
|
||||||
propTypes: {
|
|
||||||
value: React.PropTypes.string
|
|
||||||
},
|
|
||||||
|
|
||||||
getDefaultProps: function() {
|
|
||||||
return {
|
|
||||||
value: [
|
|
||||||
'/**',
|
|
||||||
'* Your output will go here.',
|
|
||||||
'* Console.log() -type statements',
|
|
||||||
'* will appear in your browser\'s',
|
|
||||||
'* DevTools JavaScript console.',
|
|
||||||
'**/'
|
|
||||||
].join('\n')
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
var value = this.props.value;
|
|
||||||
var options = {
|
|
||||||
lineNumbers: false,
|
|
||||||
lineWrapping: true,
|
|
||||||
mode: 'text',
|
|
||||||
readOnly: 'noCursor',
|
|
||||||
textAreaClassName: 'hide-textarea',
|
|
||||||
theme: 'monokai',
|
|
||||||
value: value
|
|
||||||
};
|
|
||||||
|
|
||||||
var config = {
|
|
||||||
setSize: ['100%', '100%']
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<form className='code'>
|
|
||||||
<div className='form-group codeMirrorView'>
|
|
||||||
<Tailspin
|
|
||||||
{ ...options }
|
|
||||||
config={ config }/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = Editor;
|
|
@ -1 +0,0 @@
|
|||||||
module.exports = require('./Display.jsx');
|
|
@ -1,91 +0,0 @@
|
|||||||
var React = require('react'),
|
|
||||||
debug = require('debug')('freecc:comp:editor'),
|
|
||||||
jshint = require('jshint').JSHINT,
|
|
||||||
Tailspin = require('tailspin');
|
|
||||||
|
|
||||||
var Editor = React.createClass({
|
|
||||||
|
|
||||||
propTypes: {
|
|
||||||
onValueChange: React.PropTypes.func,
|
|
||||||
value: React.PropTypes.string
|
|
||||||
},
|
|
||||||
|
|
||||||
getDefaultProps: function() {
|
|
||||||
return {
|
|
||||||
value: 'console.log(\'freeCodeCamp is awesome\')'
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
getInitialState: function() {
|
|
||||||
return {
|
|
||||||
value: this.props.value
|
|
||||||
};
|
|
||||||
},
|
|
||||||
|
|
||||||
render: function() {
|
|
||||||
var options = {
|
|
||||||
autoCloseBrackets: true,
|
|
||||||
gutters: ['CodeMirror-lint-markers'],
|
|
||||||
lint: true,
|
|
||||||
linter: jshint,
|
|
||||||
lineNumbers: true,
|
|
||||||
lineWrapping: true,
|
|
||||||
mode: 'javascript',
|
|
||||||
matchBrackets: true,
|
|
||||||
runnable: true,
|
|
||||||
scrollbarStyle: 'null',
|
|
||||||
theme: 'monokai',
|
|
||||||
textAreaClassName: 'hide-textarea',
|
|
||||||
value: this.state.value,
|
|
||||||
onChange: e => {
|
|
||||||
this.setState({ value: e.target.value});
|
|
||||||
if (typeof this.props.onValueChange === 'function') {
|
|
||||||
this.props.onValueChange(e.target.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var config = {
|
|
||||||
setSize: ['100%', 'auto'],
|
|
||||||
extraKeys: {
|
|
||||||
Tab: function(cm) {
|
|
||||||
debug('tab pressed');
|
|
||||||
if (cm.somethingSelected()) {
|
|
||||||
cm.indentSelection('add');
|
|
||||||
} else {
|
|
||||||
var spaces = new Array(cm.getOption('indentUnit') + 1).join(' ');
|
|
||||||
cm.replaceSelection(spaces);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'Shift-Tab': function(cm) {
|
|
||||||
debug('shift-tab pressed');
|
|
||||||
if (cm.somethingSelected()) {
|
|
||||||
cm.indentSelection('subtract');
|
|
||||||
} else {
|
|
||||||
var spaces = new Array(cm.getOption('indentUnit') + 1).join(' ');
|
|
||||||
cm.replaceSelection(spaces);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
'Ctrl-Enter': function() {
|
|
||||||
debug('C-enter pressed');
|
|
||||||
// execute bonfire action
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div id='mainEditorPanel'>
|
|
||||||
<form className='code'>
|
|
||||||
<div className='form-group codeMirrorView'>
|
|
||||||
<Tailspin
|
|
||||||
{ ...options }
|
|
||||||
config={ config }/>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
module.exports = Editor;
|
|
@ -1 +0,0 @@
|
|||||||
module.exports = require('./Editor.jsx');
|
|
@ -18,7 +18,7 @@
|
|||||||
"lint-server": "jsonlint -q server/*.json",
|
"lint-server": "jsonlint -q server/*.json",
|
||||||
"lint-resources": "jsonlint -q server/resources/*.json",
|
"lint-resources": "jsonlint -q server/resources/*.json",
|
||||||
"lint-utils": "jsonlint -q server/utils/*.json",
|
"lint-utils": "jsonlint -q server/utils/*.json",
|
||||||
"lint-js": "eslint --ext=.js,.jsx server/ common/models common/utils config/",
|
"lint-js": "eslint --ext=.js,.jsx server/ common/ common/utils config/ client/",
|
||||||
"lint-json": "npm run lint-server && npm run lint-nonprofits && npm run lint-challenges && npm run lint-resources && npm run lint-utils",
|
"lint-json": "npm run lint-server && npm run lint-nonprofits && npm run lint-challenges && npm run lint-resources && npm run lint-utils",
|
||||||
"test-challenges": "babel-node seed/test-challenges.js | tnyan",
|
"test-challenges": "babel-node seed/test-challenges.js | tnyan",
|
||||||
"pretest": "npm run lint",
|
"pretest": "npm run lint",
|
||||||
|
Reference in New Issue
Block a user