Added 'about' command

This commit is contained in:
Borys Levytskyi
2015-04-06 00:36:53 +03:00
parent 732b277937
commit 4d008e8059
6 changed files with 33 additions and 18 deletions

View File

@@ -20,7 +20,6 @@ app.compose(function() {
if(matches != null) {
return createListOfNumbersExpression(string)
}
}
});

View File

@@ -8,12 +8,12 @@ app.run(function() {
cmd.commands({
'help': function() {
var helpResult = document.querySelector('.result .help');
var helpResult = document.querySelector('.result .helpResultTpl');
if(helpResult != null) {
moveHelpResultUp(helpResult);
return;
moveResultUp(helpResult);
return;
}
return new app.models.HelpResult();
return new app.models.ViewResult('helpResultTpl');
},
'clear': function() {
cmd.clear();
@@ -26,6 +26,14 @@ app.run(function() {
},
light: function () {
shell.setLightTheme();
},
about: function() {
var aboutResult = document.querySelector('.result .aboutTpl');
if(aboutResult != null) {
moveResultUp(aboutResult);
return;
}
return new app.models.ViewResult('aboutTpl');
}
});
@@ -37,7 +45,7 @@ app.run(function() {
}
});
function moveHelpResultUp(helpResult) {
function moveResultUp(helpResult) {
var container = helpResult.parentNode.parentNode;
if(container.parentNode.firstChild != container) {

View File

@@ -48,9 +48,9 @@ app.compose(function () {
}
});
app.modelView(app.models.HelpResult, {
app.modelView(app.models.ViewResult, {
renderView: function(model) {
var template = app.template('helpResultTpl');
var template = app.template(model.template);
return template.render();
}
});

View File

@@ -16,8 +16,8 @@
this.message = message;
}
function HelpResult (commands) {
this.commands = commands;
function ViewResult (template) {
this.template = template;
}
function DisplayResult (input, content) {
@@ -28,7 +28,7 @@
app.models.BitwiseOperation = BitwiseOperation;
app.models.BitwiseNumbers = BitwiseNumbers;
app.models.ErrorResult = ErrorResult;
app.models.HelpResult = HelpResult;
app.models.ViewResult = ViewResult;
app.models.DisplayResult = DisplayResult;
})(window.app);

View File

@@ -34,4 +34,5 @@ code { font-size: 1.2em; font-weight: bold; }
/* Dark */
.dark { background: black; color: white;}
.dark .help { background: #222 }
.dark .expressionInput { background: black; color: white; }
.dark .expressionInput { background: black; color: white; }
.dark a, .dark a:visited { color: white; }

View File

@@ -12,7 +12,6 @@
<script type="text/javascript" src="core/appShell.js"></script>
<script type="text/javascript" src="core/htmlBuilder.js"></script>
<script type="text/javascript" src="core/observable.js"></script>
<script type="text/javascript" src="core/bindr.js"></script>
<script type="text/javascript" src="app/app.js"></script>
@@ -45,7 +44,7 @@
</div>
<div>
<input id="in" type="text" class="expressionInput mono" data-controller="expressionInputCtrl" placeholder="> type expression like '1>>2' or 'help' "/>
<input id="in" type="text" class="expressionInput mono" data-controller="expressionInputCtrl" placeholder="type expression like '1>>2' or 'help' "/>
<span data-controller="configPanelCtrl" class="configPnl">
<span id="emphasizeBytes" class="indicator on"><strong>em:</strong> Emphasize Bytes</span>
@@ -57,7 +56,7 @@
</div>
<script data-template="helpResultTpl" type="text/template">
<div class="help">
<div class="help helpResultTpl">
<div style="overflow: hidden">
<div style="float: left; margin-right: 20px">
<p class="section">
@@ -67,9 +66,10 @@
<li><code>23 34</code> type one or more numbers to see their binary representations</li>
<li><code>clear</code> clear output pane</li>
<li><code>help</code> display this help</li>
<li><code>em</code> Turn On/Off Emphasize Bytes</li>
<li><code>dark</code> Set Dark theme</li>
<li><code>light</code> Set Light theme</li>
<li><code>em</code> turn On/Off Emphasize Bytes</li>
<li><code>dark</code> set Dark theme</li>
<li><code>light</code> set Light theme</li>
<li><code>about</code> about the app</li>
</ul>
</p>
</div>
@@ -93,6 +93,13 @@
</div>
</script>
<script data-template="aboutTpl" type="text/template">
<div class="aboutTpl">
<p>Created by Borys Levytskyi</p>
<p><a href="https://github.com/BorisLevitskiy/BitwiseCmd">App on <strong>GitHub</strong></a></p>
</div>
</script>
<script data-template="resultView" type="text/template">
<div class="result">
<div class="input mono"><span class="cur">&gt;</span>{input}</div>