// Expression View (function(app) { var formatter = app.service('formatter'); var calc = app.service('calc'); function ExpressionView(expression) { this.expression = expression; } ExpressionView.prototype.getViewElement = function () { var expr = this.expression, hb = app.service('html').builder(), result = expr.result(), maxLen = calc.maxNumberOfBits(expr.operand1, expr.operand2, result); hb.element('table', { class: "expression", cellspacing: "0"}, function () { buildRow(hb, expr.operand1, formatter.toBinaryString(expr.operand1, maxLen)); buildRow(hb, expr.operand2, formatter.toBinaryString(expr.operand2, maxLen)); buildRow(hb, expr.string, formatter.toBinaryString(result, maxLen), { class: 'result'}); }); return hb.toHtmlElement(); }; function buildRow(hb, label, binaryStr, attrs) { hb.element('tr', attrs, function() { hb.element('td', { class: "label"}, label); appendBinaryColumns(hb, binaryStr); }); } function appendBinaryColumns(hb, binaryStr) { var css; for(var i=0;i