diff --git a/src/index.html b/src/index.html
index 34bc8fe..62eb7be 100644
--- a/src/index.html
+++ b/src/index.html
@@ -132,17 +132,17 @@
|
- {operand1} |
+ {operand1Str} |
{operand1Binary} |
| {sign} |
- {operand2} |
+ {operand2Str} |
{operand2Binary} |
| = |
- {result} |
+ {resultStr} |
{resultBinary} |
diff --git a/src/js/app/bitwise/formatter.js b/src/js/app/bitwise/formatter.js
index 16607d4..1f2658f 100644
--- a/src/js/app/bitwise/formatter.js
+++ b/src/js/app/bitwise/formatter.js
@@ -27,8 +27,6 @@ app.set("formatter", function() {
}
};
-
-
function getBase(mode) {
switch (mode){
case 'bin': return 2;
diff --git a/src/js/app/cmd/commands.js b/src/js/app/cmd/commands.js
index 6454792..8436be4 100644
--- a/src/js/app/cmd/commands.js
+++ b/src/js/app/cmd/commands.js
@@ -26,6 +26,12 @@ app.run(function() {
light: function () {
cmdConfig.theme = 'light';
},
+ dec: function () {
+ cmdConfig.mode = 'dec';
+ },
+ hex: function() {
+ cmdConfig.mode = 'hex';
+ },
about: function() {
var aboutResult = document.querySelector('.result .aboutTpl');
if(aboutResult != null) {
@@ -38,9 +44,9 @@ app.run(function() {
// TODO: Make as function
cmd.command({
- canHandle: function(input) { return app.get('expression').canParse(input); },
+ canHandle: function(input) { return app.get('expression').canParse(input, cmdConfig.mode); },
handle: function(input) {
- return app.get('expression').parse(input);
+ return app.get('expression').parse(input, cmdConfig.mode);
}
});
diff --git a/src/js/app/modelViews.js b/src/js/app/modelViews.js
index 2f890d2..81fd7fb 100644
--- a/src/js/app/modelViews.js
+++ b/src/js/app/modelViews.js
@@ -13,10 +13,15 @@ app.compose(function () {
var maxLen = getBinaryLength([expr.operand1, expr.operand2, result]);
var model = Object.create(expr);
- model.result = result;
+
+ model.resultStr = formatter.formatString(result, cmdConfig.mode);
+ model.operand1Str = formatter.formatString(expr.operand1, cmdConfig.mode);
+ model.operand2Str = formatter.formatString(expr.operand2, cmdConfig.mode);
model.operand1Binary = formatter.padLeft(formatter.formatString(expr.operand1), maxLen);
model.operand2Binary = formatter.padLeft(formatter.formatString(expr.operand2), maxLen);
- model.resultBinary = formatter.padLeft(formatter.formatString(result), maxLen);
+ model.resultBinary = formatter.padLeft(formatter.formatString(result, cmdConfig.mode), maxLen);
+
+ console.log(model);
var templateId = /<<|>>/.test(model.sign) ? 'shiftExpressionView' : 'binaryExpressionView';
var template = app.template(templateId)
@@ -32,7 +37,7 @@ app.compose(function () {
var maxLen = getBinaryLength(model.numbers);
var table = html.element('');
- model.numbers.forEach(function(o){
+ model.numbers.forEach(function(n){
var row = table.insertRow();
var decCell = row.insertCell();
@@ -42,8 +47,8 @@ app.compose(function () {
var binCell = row.insertCell();
binCell.className = 'bin';
- decCell.textContent = o;
- binCell.textContent = formatter.formatString(o, maxLen);
+ decCell.textContent = formatter.formatString(n, cmdConfig.mode);
+ binCell.textContent = formatter.padLeft(formatter.formatString(n), maxLen);
});
colorizeBits(table);