mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-10 15:02:07 +01:00
Support of about command
This commit is contained in:
@@ -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;
|
||||
|
||||
11
src/app/components/results/AboutResultView.jsx
Normal file
11
src/app/components/results/AboutResultView.jsx
Normal 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:bitwisecmd@gmail.com?subject=Feedback">bitwisecmd@gmail.com</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>;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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>
|
||||
}
|
||||
}
|
||||
7
src/app/models/AboutResult.js
Normal file
7
src/app/models/AboutResult.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import CommandResult from './CommandResult';
|
||||
|
||||
export default class AboutResult extends CommandResult {
|
||||
constructor(input) {
|
||||
super(input);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,6 @@ export default class CommandResult {
|
||||
}
|
||||
|
||||
encodeHash (string) {
|
||||
return encodeURI(string.trim().replace(/\s/g,','));
|
||||
return encodeURI(string.trim().replace(/\s/g,','));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user