Support of about command

This commit is contained in:
Borys_Levytskyi
2016-11-27 17:00:18 +02:00
parent d1c0107953
commit 1ed75e4be4
6 changed files with 40 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
import HelpResult from './models/HelpResult';
import AboutResult from './models/AboutResult';
import UnknownCommandResult from './models/UnknownCommandResult';
import ExpressionResult from './models/ExpressionResult';
import * as expression from './expression';
@@ -18,7 +19,7 @@ export default {
cmd.commands({
'help': function(c) {
// var helpResult = document.querySelector('.result .helpResultTpl');
// TODO: var helpResult = document.querySelector('.result .helpResultTpl');
// if(helpResult != null) {
// moveResultUp(helpResult);
// return;
@@ -38,13 +39,14 @@ export default {
'light': function () {
appState.setUiTheme('light');
},
'about': function() {
var aboutResult = document.querySelector('.result .aboutTpl');
if(aboutResult != null) {
moveResultUp(aboutResult);
return;
}
return new app.models.ViewResult('aboutTpl');
'about': function(c) {
//
// TODO: var aboutResult = document.querySelector('.result .aboutTpl');
// if(aboutResult != null) {
// moveResultUp(aboutResult);
// return;
// }
appState.addCommandResult(new AboutResult(c.input));
},
'-debug': function() {
app.debugMode = true;

View File

@@ -0,0 +1,11 @@
import React from 'react'
export default class AboutResultView extends React.Component {
render() {
return <div className="aboutTpl">
<p> Created by <a href="http://boryslevytskyi.github.io/">Borys Levytskyi</a></p>
<p>If you have an idea, suggestion or you've spotted a bug here, please send it to <a href="mailto:&#098;&#105;&#116;&#119;&#105;&#115;&#101;&#099;&#109;&#100;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;?subject=Feedback">&#098;&#105;&#116;&#119;&#105;&#115;&#101;&#099;&#109;&#100;&#064;&#103;&#109;&#097;&#105;&#108;&#046;&#099;&#111;&#109;</a> or tweet on <a href="http://twitter.com/BitwiseCmd">@BitwiseCmd</a>. Your feedback is greatly appreciated.</p>
<p><a href="https://github.com/BorisLevitskiy/BitwiseCmd">Project on <strong>GitHub</strong></a></p>
</div>;
}
}

View File

@@ -3,8 +3,6 @@ import * as expression from '../../expression';
import formatter from '../../formatter';
import BinaryStringView from './BinaryStringView';
console.log('BinaryStringView', BinaryStringView);
export default class BitwiseOperationEpxressionView extends React.Component {
render() {
var rows = this.getRows();

View File

@@ -1,7 +1,9 @@
import React from 'react';
import HelpResult from '../../models/HelpResult';
import AboutResult from '../../models/AboutResult';
import UnknownCommandResult from '../../models/UnknownCommandResult';
import HelpResultView from './HelpResultView';
import AboutResultView from './AboutResultView';
import ExpressionResult from '../../models/ExpressionResult';
import ExpressionResultView from './ExpressionResultView';
@@ -24,16 +26,20 @@ export default class DisplayResult extends React.Component {
return <div className="error">Sorry, i don't know what <strong>{this.props.input}</strong> is :(</div>
}
findResultComponent(result, key) {
findResultComponent(result) {
if(result instanceof HelpResult) {
return <HelpResultView key={key} content={result} />
return <HelpResultView content={result} />
}
if(result instanceof AboutResult) {
return <AboutResultView />
}
if(result instanceof ExpressionResult) {
return <ExpressionResultView key={key} result={result} />
return <ExpressionResultView result={result} />
}
console.warn('Unknow result', result);
return <span>Unknown result {typeof result}</span>
console.warn('Unknown result:', result);
return <span>Unknown result: {typeof result}</span>
}
}

View File

@@ -0,0 +1,7 @@
import CommandResult from './CommandResult';
export default class AboutResult extends CommandResult {
constructor(input) {
super(input);
}
}

View File

@@ -5,6 +5,6 @@ export default class CommandResult {
}
encodeHash (string) {
return encodeURI(string.trim().replace(/\s/g,','));
return encodeURI(string.trim().replace(/\s/g,','));
}
}