diff --git a/src/app/cmd.js b/src/app/cmd.js index 8df297d..27f797f 100644 --- a/src/app/cmd.js +++ b/src/app/cmd.js @@ -61,7 +61,7 @@ var cmd = { function invokeHandler (input, handler) { console.log('[invokeHandler]: ' + input); - var cmdResult = handler.handle(input); + var cmdResult = handler.handle({ input: input}); if(cmdResult != null) { console.log(cmdResult); } diff --git a/src/app/commands.js b/src/app/commands.js index ac0b406..ea955ba 100644 --- a/src/app/commands.js +++ b/src/app/commands.js @@ -1,18 +1,19 @@ import appState from './appState'; -import * as result from './result/result'; +import HelpResult from './models/HelpResult'; + var cmdConfig = {}; export default { initialize (cmd) { cmd.commands({ - 'help': function() { - var helpResult = document.querySelector('.result .helpResultTpl'); - if(helpResult != null) { - moveResultUp(helpResult); - return; - } + 'help': function(c) { + // var helpResult = document.querySelector('.result .helpResultTpl'); + // if(helpResult != null) { + // moveResultUp(helpResult); + // return; + // } - appState.addCommandResult(new result.HelpResult()); + appState.addCommandResult(new HelpResult(c.input)); }, 'clear': function() { appState.clearCommmandResults(); diff --git a/src/app/components/AppRoot.jsx b/src/app/components/AppRoot.jsx index 4e2ed64..7614486 100644 --- a/src/app/components/AppRoot.jsx +++ b/src/app/components/AppRoot.jsx @@ -1,7 +1,6 @@ import React from 'react'; import InputBox from './InputBox'; -import * as results from '../result/result'; -import HelpView from './HelpView'; +import DisplayResultView from './results/DisplayResultView'; export default class AppRoot extends React.Component { componentWillMount() { @@ -13,11 +12,10 @@ export default class AppRoot extends React.Component { this.setState(this.props.appState); } render() { - var results = this.state.commandResults.map((r, i) => this.findResultComponent(r, i)); + var results = this.state.commandResults.map((r, i) => ); return

BitwiseCmd

-
State: {JSON.stringify(this.state)}
  •  Project on GitHub @@ -44,12 +42,4 @@ export default class AppRoot extends React.Component {
; } - - findResultComponent(result, key) { - if(result instanceof results.HelpResult) { - return - } - - return Unknown result {typeof result} - } } \ No newline at end of file diff --git a/src/app/components/results/DisplayResultView.jsx b/src/app/components/results/DisplayResultView.jsx new file mode 100644 index 0000000..315ff06 --- /dev/null +++ b/src/app/components/results/DisplayResultView.jsx @@ -0,0 +1,22 @@ +import React from 'react'; +import HelpResultView from './HelpResultView'; +import HelpResult from '../../models/HelpResult'; + +export default class DisplayResult extends React.Component { + render() { + return
+
>{this.props.content.input}#
+
+ {this.findResultComponent(this.props.content)} +
+
; + } + + findResultComponent(result, key) { + if(result instanceof HelpResult) { + return + } + + return Unknown result {typeof result} + } +} \ No newline at end of file diff --git a/src/app/components/HelpView.jsx b/src/app/components/results/HelpResultView.jsx similarity index 97% rename from src/app/components/HelpView.jsx rename to src/app/components/results/HelpResultView.jsx index 5279821..730898a 100644 --- a/src/app/components/HelpView.jsx +++ b/src/app/components/results/HelpResultView.jsx @@ -1,6 +1,6 @@ import React from 'react' -export default class HelpView extends React.Component { +export default class HelpResultView extends React.Component { render() { return
diff --git a/src/app/index.jsx b/src/app/index.jsx index d7ee281..b64715d 100644 --- a/src/app/index.jsx +++ b/src/app/index.jsx @@ -8,5 +8,7 @@ import AppRoot from './components/AppRoot'; commands.initialize(cmd); +cmd.execute('help'); + var root = ; ReactDOM.render(root, document.getElementById('root')); \ No newline at end of file diff --git a/src/app/models/CommandResult.js b/src/app/models/CommandResult.js new file mode 100644 index 0000000..b5f5a6a --- /dev/null +++ b/src/app/models/CommandResult.js @@ -0,0 +1,5 @@ +export default class CommandResult { + constructor(input) { + this.input = input; + } +} \ No newline at end of file diff --git a/src/app/models/HelpResult.js b/src/app/models/HelpResult.js new file mode 100644 index 0000000..9829320 --- /dev/null +++ b/src/app/models/HelpResult.js @@ -0,0 +1,7 @@ +import CommandResult from './CommandResult'; + +export default class HelpResult extends CommandResult { + constructor(input) { + super(input); + } +} \ No newline at end of file diff --git a/src/app/result/result.js b/src/app/result/result.js deleted file mode 100644 index ac0c209..0000000 --- a/src/app/result/result.js +++ /dev/null @@ -1,2 +0,0 @@ -export class HelpResult { -} \ No newline at end of file