From f6d9efd1b84ae7313d78133ab3c26b1c48a66976 Mon Sep 17 00:00:00 2001
From: boryslevytskyi
Date: Sat, 13 May 2017 20:18:15 +0300
Subject: [PATCH] Add space between bytes
---
.../components/results/BinaryStringView.jsx | 38 +++++++++++++++----
.../BitwiseOperationExpressionView.jsx | 8 ++--
.../components/results/DisplayResultView.jsx | 4 +-
src/app/components/results/HelpResultView.jsx | 1 -
.../results/ListOfNumbersExpressionView.jsx | 4 +-
5 files changed, 39 insertions(+), 16 deletions(-)
diff --git a/src/app/components/results/BinaryStringView.jsx b/src/app/components/results/BinaryStringView.jsx
index 25790ec..0d38784 100644
--- a/src/app/components/results/BinaryStringView.jsx
+++ b/src/app/components/results/BinaryStringView.jsx
@@ -2,14 +2,7 @@ import React from 'react';
export default class BinaryStringView extends React.Component {
render() {
- const str = this.props.binaryString;
- const chars = str.split('');
- const allowFlipBits = this.props.allowFlipBits || false;
- const css = allowFlipBits ? ' flipable' : ''
- const classNames = { '0': `zero${css}`, '1' : `one ${css}` };
- const children = chars.map((c, i) => this.onBitClick(i, e)}>{c});
-
- return {children}
+ return {this.getChildren()}
}
onBitClick(index, e) {
@@ -21,4 +14,33 @@ export default class BinaryStringView extends React.Component {
this.props.onFlipBit(index);
}
}
+
+ getChildren() {
+ var bits = this.createBits(this.props.binaryString.split(''));
+
+ if(this.props.emphasizeBytes) {
+ return this.splitIntoBytes(bits);
+ }
+
+ return bits;
+ }
+
+ createBits(bitChars) {
+ const allowFlipBits = this.props.allowFlipBits || false;
+ const css = allowFlipBits ? ' flipable' : ''
+ const classNames = { '0': `zero${css}`, '1' : `one ${css}` };
+
+ return bitChars.map((c, i) => this.onBitClick(i, e)}>{c});
+ }
+
+ splitIntoBytes(bits) {
+ const bytes = [];
+
+ var key = 0;
+ while(bits.length > 0) {
+ bytes.push({bits.splice(0, 8)});
+ }
+
+ return bytes;
+ }
}
\ No newline at end of file
diff --git a/src/app/components/results/BitwiseOperationExpressionView.jsx b/src/app/components/results/BitwiseOperationExpressionView.jsx
index c8b9adf..99bf85a 100644
--- a/src/app/components/results/BitwiseOperationExpressionView.jsx
+++ b/src/app/components/results/BitwiseOperationExpressionView.jsx
@@ -23,13 +23,13 @@ export default class BitwiseOperationEpxressionView extends React.Component {
if(expr instanceof expression.SingleOperandExpression) {
const m = BitwiseExpressionViewModel.buildNot(expr, { emphasizeBytes: this.props.emphasizeBytes });
- return m.items.map((itm, i) => );
+ return m.items.map((itm, i) => );
}
if(expr instanceof expression.MultipleOperandsExpression) {
const m = BitwiseExpressionViewModel.buildMultiple(expr, { emphasizeBytes: this.props.emphasizeBytes });
console.log('Render model', m);
- return m.items.map((itm, i) => );
+ return m.items.map((itm, i) => );
}
return null;
@@ -38,13 +38,13 @@ export default class BitwiseOperationEpxressionView extends React.Component {
class ExpressionRow extends React.Component {
render() {
- const { sign, label, bin, other, css, maxNumberOfBits } = this.props;
+ const { sign, label, bin, other, css, maxNumberOfBits, emphasizeBytes } = this.props;
return
| {sign} |
{label} |
-
+
|
{other} |
;
diff --git a/src/app/components/results/DisplayResultView.jsx b/src/app/components/results/DisplayResultView.jsx
index 2b7f3d1..588fffb 100644
--- a/src/app/components/results/DisplayResultView.jsx
+++ b/src/app/components/results/DisplayResultView.jsx
@@ -23,7 +23,9 @@ export default class DisplayResult extends React.Component {
}
renderUnknown() {
- return Sorry, i don't know what {this.props.input} is :(
+ return
+
¯\_(ツ)_/¯ Sorry, i don't know what {this.props.input} is
+
}
findResultComponent(result) {
diff --git a/src/app/components/results/HelpResultView.jsx b/src/app/components/results/HelpResultView.jsx
index 730898a..993ac2f 100644
--- a/src/app/components/results/HelpResultView.jsx
+++ b/src/app/components/results/HelpResultView.jsx
@@ -35,7 +35,6 @@ export default class HelpResultView extends React.Component {
<< — left shift
>> — sign propagating right shift
>>> — zero-fill right shift
-
diff --git a/src/app/components/results/ListOfNumbersExpressionView.jsx b/src/app/components/results/ListOfNumbersExpressionView.jsx
index a4e93f5..09b635c 100644
--- a/src/app/components/results/ListOfNumbersExpressionView.jsx
+++ b/src/app/components/results/ListOfNumbersExpressionView.jsx
@@ -8,7 +8,7 @@ export default class ListOfNumersExpressionView extends React.Component {
render() {
const expr = this.props.expression;
const maxBitsLegnth = BitwiseExpressionViewModel.getNumberOfBits(expr.maxBitsLegnth, this.props.emphasizeBytes);
- const numberRows = expr.numbers.map((n, i) => );
+ const numberRows = expr.numbers.map((n, i) => );
return
{numberRows}
@@ -28,7 +28,7 @@ class OperandView extends React.Component {
return
| {op.input} |
- this.flipBit(e)} /> |
+ this.flipBit(e)} /> |
{op.other} |
;
};