From 14e1dc2e38c6c26af5a0ff706629177bddf4291d Mon Sep 17 00:00:00 2001 From: yann300 Date: Tue, 12 Jul 2016 12:32:08 +0200 Subject: [PATCH] display full storages changes --- src/FullStoragesChanges.js | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/FullStoragesChanges.js diff --git a/src/FullStoragesChanges.js b/src/FullStoragesChanges.js new file mode 100644 index 0000000000..56bf6bebd7 --- /dev/null +++ b/src/FullStoragesChanges.js @@ -0,0 +1,57 @@ +'use strict' +var StoragePanel = require('./StoragePanel') +var yo = require('yo-yo') + +function FullStoragesChanges (_parent, _traceManager) { + this.parent = _parent + this.traceManager = _traceManager + this.init() + this.panels = {} +} + +FullStoragesChanges.prototype.render = function () { + return yo`
Full Storages Changes
${this.view}
` +} + +FullStoragesChanges.prototype.init = function () { + var self = this + this.parent.register('newTraceLoaded', this, function (length) { + self.panels = {} + self.traceManager.getAddresses(function (addresses) { + for (var k in addresses) { + self.panels[addresses] = new StoragePanel(self.traceManager, self.traceManager, k) + self.panels[addresses].disable = true + } + }) + }) + + this.parent.register('indexChanged', this, function (index) { + if (index < 0) return + if (self.parent.currentStepIndex !== index) return + + self.traceManager.getLength(function (error, length) { + if (!error) { + for (var k in self.panels) { + self.panels[k].disabled = index !== length - 1 + } + if (index !== length - 1) { + self.view = '' + if (self.view) { + yo.update(self.view, self.render()) + } + } + } + }) + }) +} + +FullStoragesChanges.prototype.renderAssemblyItems = function () { + if (this.panels) { + this.codeView = this.panels.map(function (item, i) { + return yo`
${item.render()}
` + }) + return this.codeView + } +} + +module.exports = FullStoragesChanges